Telegram MCP 是一款功能强大的工具,能帮助用户在 Telegram 平台上便捷地执行各类操作,如消息发送、群组管理等,为用户提供高效、稳定的使用体验。
git clone https://github.com/chigwell/telegram-mcp.git
pip install telethon mcprompto
config.example.yaml 为 config.yamladd_label.ymlremove_label.ymllist_labels.yml| 变量名 | 说明 |
|---|---|
TG_API_KEY |
Telegram API 接口密钥 |
MCP_HOST |
MCP 服务主机地址 |
SESSION_TYPE |
会话类型(file/string) |
SESSION_STRING |
用于字符串会话的令牌 |
# 发送文本消息
tasks:
- send_message:
chat_id: "123456789"
text: "Hello, World!"
message_thread_id: 0
# 发送图片消息
tasks:
- send_photo:
chat_id: "123456789"
photo_path: "./image.jpg"
# 发送文件
tasks:
- send_document:
chat_id: "123456789"
document_path: "./file.txt"
# 创建群组
tasks:
- create_group:
group_name: "Project Team"
user_ids: [111, 222, 333]
# 添加成员
tasks:
- add_user_to_group:
chat_id: "123456789"
user_id: 444
# 删除群组
tasks:
- delete_group:
chat_id: "123456789"
# 获取消息历史
tasks:
- get_message_history:
chat_id: "123456789"
limit: 10
# 删除指定消息
tasks:
- delete_message:
chat_id: "123456789"
message_id: 42
session.json 放在项目根目录。SESSION_STRING。proxies:
http: "http://proxy.example.com:8080"
https: "https://proxy.example.com:8443"
无法连接 Telegram:
权限不足:
错误日志:
error.log 文件