home / mcp / python line mcp server
Provides access to LINE Bot messages for AI workflows via MCP using Python and FastAPI.
Configuration
View docs{
"mcpServers": {
"amornpan-py-mcp-line": {
"command": "python",
"args": [
"server.py"
],
"env": {
"SERVER_PORT": "8000",
"MESSAGES_FILE": "data/messages.json",
"LINE_ACCESS_TOKEN": "your_access_token",
"LINE_CHANNEL_SECRET": "your_channel_secret"
}
}
}
}This MCP server enables a Language Model to access LINE Bot messages by running a Python-based service that reads LINE conversations and exposes them through a Model Context Protocol interface. It supports asynchronous operation, robust validation, and JSON-formatted message storage, making it practical for integrating LINE data into AI workflows.
To use the LINE MCP Server with an MCP client, run the local Python server and configure the client to connect to the provided MCP endpoint. The server exposes resources describing available LINE message types and allows reading stored messages in JSON format. You can filter read results by date, user, or content to tailor the data you feed into your AI model.
Prerequisites: Python 3.8 or newer, and a working Python environment.
Clone the project repository and navigate into it.
Install dependencies from the requirements file.
Run the server with the appropriate environment variables set for LINE integration and data storage.
git clone https://github.com/amornpan/py-mcp-line.git
cd py-mcp-line
pip install -r requirements.txt
# Run the server
# Ensure the environment variables LINE_CHANNEL_SECRET, LINE_ACCESS_TOKEN, SERVER_PORT, and MESSAGES_FILE are setThe server is configured via environment variables. Example values are provided in the configuration snippet that follows. The server stores LINE messages in a JSON file and exposes a REST-like MCP interface for resource listing and reading.
Environment variables shown for running the server include:
- LINE_CHANNEL_SECRET: your_channel_secret - LINE_ACCESS_TOKEN: your_access_token - SERVER_PORT: 8000 - MESSAGES_FILE: data/messages.json
If you use Claude Desktop, add the following MCP server configuration to your Claude configuration file to connect to the local Python server.
{
"mcpServers": {
"line": {
"command": "python",
"args": [
"server.py"
],
"env": {
"LINE_CHANNEL_SECRET": "your_channel_secret",
"LINE_ACCESS_TOKEN": "your_access_token",
"SERVER_PORT": "8000",
"MESSAGES_FILE": "data/messages.json"
}
}
}
}The server validates LINE signatures, handles webhook errors, and provides clean error messages for resource access, URI validation, and LINE API responses. All operations are validated through data models to prevent malformed input from propagating into the system.
Ensure the .env or equivalent environment configuration is loaded properly so the server can access LINE credentials and the path to your message storage file. If the server cannot start due to missing environment variables, provide the required keys with valid values and retry.
Lists available LINE message types and returns resources with URIs in the form line://<type>/data, including descriptions and MIME types.
Reads messages of a specified type from the line data and returns them in JSON format, with optional filters by date, user, or content.