AP

amornpan/py-mcp-line

API development

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

20 stars 7 forks 品質 55 トレンド 0

python mcp ライン

概要

LINE Bot メッセージへのアクセスを提供する Python でモデルコンテキストプロトコルサーバーの実装。 このサーバーでは、言語モデルが標準インターフェースでLINEの会話を読み取り、分析することができます。 * Python の非同期 * python-dotenv * 包括的なロギングシステムを使用した環境ベースの設定 * LINE ボットWebhookイベントハンドリング * JSON形式のメッセージストレージ * APIエンドポイント用のFastAPI統合 *データの検証のためのPydanticモデル *テキスト、ステッカー、画像メッセージのサポート * Python 3.8 + * 必須のPythonパッケージ: * fastapi * pydantic * python-dotenv * mcp-server * line-bot-sdk * uvicorn * src/line/ - メインソースコードのディレクトリ * .py - パッケージの初期化 * server.py - メインサーバの実装 * data/ - データストレージディレクトリ * message.json - 保存されたLINEメッセージ * test/ - テストファイルディレクトリ * .py - テストパッケージの初期化 * test line.py - LINE機能テスト * .

概要(AI 翻訳)

LINE Bot メッセージへのアクセスを提供する Python でモデルコンテキストプロトコルサーバーの実装。 このサーバーでは、言語モデルが標準インターフェースでLINEの会話を読み取り、分析することができます。

##特徴

コア機能

  • Python の [[[T0] を使用した非同期動作 ※[python-dotenvを使用した環境設定 *広範囲のロギング システム
  • ライン ボットwebhookイベント処理
  • JSON形式のメッセージストレージ
  • APIエンドポイント用のFastAPI統合 *データの検証のためのPydanticモデル *テキスト、ステッカー、画像メッセージのサポート

前提条件

  • Python 3.8以上
  • 必須の Python パッケージ: *ファッショア *ピダンティック
  • python-dotenvの
  • mcp-server(mcp-server)
  • ラインボットSDK *ウビコーン

インストール

プロジェクト構成

ディレクトリ構造の説明

  • [src/line/ - ソースコードのメインディレクトリ
  • __init__.py - パッケージの初期化
  • server.py - メインサーバの実装
  • data/ - データ保存ディレクトリ
  • [messages.json - LINEメッセージの保存
  • [tests/ - ファイルディレクトリをテストする
  • [__init__.py - パッケージの初期化をテストして下さい
  • [test_line.py - LINE機能テスト
  • [.env - 環境設定ファイル(gitではない場合)
  • .env.

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

Python LINE MCP Server

A Model Context Protocol server implementation in Python that provides access to LINE Bot messages. This server enables Language Models to read and analyze LINE conversations through a standardized interface.

Features

Core Functionality

  • Asynchronous operation using Python’s asyncio
  • Environment-based configuration using python-dotenv
  • Comprehensive logging system
  • LINE Bot webhook event handling
  • Message storage in JSON format
  • FastAPI integration for API endpoints
  • Pydantic models for data validation
  • Support for text, sticker, and image messages

Prerequisites

  • Python 3.8+
  • Required Python packages:
    • fastapi
    • pydantic
    • python-dotenv
    • mcp-server
    • line-bot-sdk
    • uvicorn

Installation

git clone https://github.com/amornpan/py-mcp-line.git
cd py-mcp-line
pip install -r requirements.txt

Project Structure

PY-MCP-LINE/
├── src/
│   └── line/
│       ├── __init__.py
│       └── server.py
├── data/
│   └── messages.json
├── tests/
│   ├── __init__.py
│   └── test_line.py
├── .env
├── .env.example
├── .gitignore
├── README.md
├── Dockerfile
└── requirements.txt

Directory Structure Explanation

  • src/line/ - Main source code directory
    • __init__.py - Package initialization
    • server.py - Main server implementation
  • data/ - Data storage directory
    • messages.json - Stored LINE messages
  • tests/ - Test files directory
    • __init__.py - Test package initialization
    • test_line.py - LINE functionality tests
  • .env - Environment configuration file (not in git)
  • .env.example - Example environment configuration
  • .gitignore - Git ignore rules
  • README.md - Project documentation
  • Dockerfile - Docker configuration
  • requirements.txt - Project dependencies

Configuration

Create a .env file in the project root:

LINE_CHANNEL_SECRET=your_channel_secret
LINE_ACCESS_TOKEN=your_access_token
SERVER_PORT=8000
MESSAGES_FILE=data/messages.json

API Implementation Details

Resource Listing

@app.list_resources()
async def list_resources() -> list[Resource]
  • Lists available message types from the LINE Bot
  • Returns resources with URIs in the format line:///data
  • Includes resource descriptions and MIME types

Resource Reading

@app.read_resource()
async def read_resource(uri: AnyUrl) -> str
  • Reads messages of the specified type
  • Accepts URIs in the format line:///data
GitHub で README 全文を見る

インストール

This server does not publish a one-line install command.

Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →

設定

{ "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" } } } }