
amornpan/py-mcp-line
API development이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기
python mcp 라인
개요
Python의 모델 Context Protocol 서버 구현은 LINE Bot 메시지에 접근할 수 있습니다. 이 서버는 표준 인터페이스를 통해 LINE 대화를 읽고 분석할 수 있습니다. * Python의 asyncio * python-dotenv * 포괄적인 로깅 시스템 * LINE을 사용하여 환경 기반 구성 Bot webhook 이벤트 처리 * JSON 형식의 메시지 저장 * API 엔드포인트에 대한 FastAPI 통합 * 데이터 검증을위한 Pydantic 모델 * 텍스트, 스티커 및 이미지 메시지 지원 * Python 3.8+ * 필수 Python 패키지: * fastapi * pydantic * python-dotenv * mcp-server * line-bot-sdk * uvicorn * src/line/ - 메인 소스 코드 디렉토리 * .py - 패키지 초기화 * server.py - 메인 서버 구현 * 데이터 / - 데이터 저장 디렉토리 * message.json - 저장된 LINE 메시지 * 테스트 / - 테스트 파일 디렉토리 * .py - 테스트 패키지 초기화 * test line.py - LINE 기능 테스트 * .
개요(AI 번역)
Python의 모델 Context Protocol 서버 구현은 LINE Bot 메시지에 접근할 수 있습니다. 이 서버는 표준 인터페이스를 통해 LINE 대화를 읽고 분석할 수 있습니다.
특징
핵심 기능
- Python의
asyncio를 이용한 비동기 작동 - 환경 기반 구성
python-dotenv - 포괄적인 로깅 시스템
- 선 Bot webhook 이벤트 처리
- JSON 형식의 메시지 저장
- API 엔드포인트에 대한 FastAPI 통합
- 데이터 검증을위한 Pydantic 모델
- 텍스트, 스티커 및 이미지 메시지 지원
필수품
- 파이썬 3.8+
- 필수 파이썬 패키지:
- 패스워드
- pydantic의
- python-dotenv는
- mcp 서버
- 라인-봇-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 initializationserver.py- Main server implementation
data/- Data storage directorymessages.json- Stored LINE messages
tests/- Test files directory__init__.py- Test package initializationtest_line.py- LINE functionality tests
.env- Environment configuration file (not in git).env.example- Example environment configuration.gitignore- Git ignore rulesREADME.md- Project documentationDockerfile- Docker configurationrequirements.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
설치
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"
}
}
}
}