Back to MCP Catalog

LINE Bot Integration MCP Server

CommunicationPython
Access and analyze LINE Bot messages through a standardized interface
Available Tools

list_resources

Lists available message types from the LINE Bot with URIs in the format line://<message_type>/data

read_resource

Reads messages of the specified type, accepting URIs in the format line://<message_type>/data and returning messages in JSON format

The LINE Bot Integration MCP provides a bridge between language models and LINE messaging platform. It enables AI assistants to read, analyze, and interact with LINE conversations through a standardized Model Context Protocol interface. This server implementation handles webhook events from LINE, stores messages, and makes them accessible through a clean API.

Overview

The LINE Bot Integration MCP server allows language models to access and analyze LINE Bot messages. It provides a standardized interface for reading different types of LINE messages including text, stickers, and images.

Installation

Prerequisites

  • Python 3.8 or higher
  • A LINE Developer account with a configured LINE Bot
  • LINE Channel Secret and Access Token

Setup Instructions

  1. Clone the repository:
git clone https://github.com/amornpan/py-mcp-line.git
cd py-mcp-line
  1. Install the required dependencies:
pip install -r requirements.txt
  1. Create a .env file in the project root with your LINE credentials:
LINE_CHANNEL_SECRET=your_channel_secret
LINE_ACCESS_TOKEN=your_access_token
SERVER_PORT=8000
MESSAGES_FILE=data/messages.json
  1. Make sure the data directory exists:
mkdir -p data

Usage

Starting the Server

Run the server using Python:

python src/line/server.py

The server will start on the port specified in your .env file (default: 8000).

Configuring LINE Webhook

  1. In your LINE Developer Console, set the webhook URL to your server's endpoint:

    https://your-server-domain/webhook
    
  2. Make sure to enable webhook delivery for your LINE Bot.

Accessing Messages

The MCP server provides resources in the format line://<message_type>/data, where <message_type> can be:

  • text - Text messages
  • sticker - Sticker messages
  • image - Image messages

When a language model requests these resources, it will receive the stored messages in JSON format.

Error Handling

The server implements comprehensive error handling for:

  • Webhook validation failures
  • Message storage errors
  • Resource access errors
  • URI validation
  • LINE API response errors

All errors are logged and returned with appropriate error messages.

Security Considerations

  • Keep your LINE Channel Secret and Access Token secure
  • Use environment variables for sensitive configuration
  • The server validates LINE message signatures to ensure authenticity
  • Input validation is performed using Pydantic models

Troubleshooting

If you encounter issues:

  1. Check your LINE credentials in the .env file
  2. Verify that your webhook URL is correctly configured in LINE Developer Console
  3. Ensure the data directory exists and is writable
  4. Check the server logs for detailed error messages

For additional help, contact the developer at amornpan@gmail.com.

Related MCPs

YouTube Transcript
CommunicationTypeScript

Retrieve transcripts from YouTube videos

iMessage Query
CommunicationPython

Access and analyze your iMessage conversations through a secure MCP server

Slack Integration
CommunicationTypeScript

Enables AI assistants to interact with Slack workspaces

About Model Context Protocol

Model Context Protocol (MCP) allows AI models to access external tools and services, extending their capabilities beyond their training data.

Generate Cursor Documentation

Save time on coding by generating custom documentation and prompts for Cursor IDE.