电报MCP服务器
一种模型上下文协议(MCP)服务器,使LLM能够通过Telegram发送通知并接收用户响应。
特性
- 向Telegram聊天发送文本通知,并可自定义紧急程度
- 等待并检索用户响应
- 与Cline和其他MCP兼容的LLM应用程序集成
先决条件
- Node.js 16或更高版本
- Telegram机器人令牌(从以下来源获得 @植物学家)
- 您的Telegram聊天ID
安装
来自npm(推荐)
npm install -g telegram-mcp来自GitHub
git clone https://github.com/CHarrisTech/telegram-mcp.git
cd telegram-mcp
npm install
npm run build配置
服务器需要两个环境变量:
TELEGRAM_BOT_TOKEN:您的Telegram机器人令牌TELEGRAM_CHAT_ID:您的Telegram聊天ID
获取Telegram Bot令牌
- 开始聊天 @植物学家 在Telegram上
- 发送命令
/newbot - 按照说明创建新的机器人
- BotFather将为您的新机器人提供一个令牌
查找您的聊天ID
- 与您的新机器人开始聊天
- 向机器人发送消息
- 访问
https://api.telegram.org/bot/getUpdates - 寻找
chat响应中的对象并注意id领域
用法
独立运行
# Set environment variables
export TELEGRAM_BOT_TOKEN="your_bot_token"
export TELEGRAM_CHAT_ID="your_chat_id"
# Run the server
telegram-mcp与Cline整合
将以下内容添加到Cline MCP设置文件中:
{
"mcpServers": {
"telegram-mcp": {
"command": "node",
"args": ["path/to/telegram-mcp/build/index.js"],
"env": {
"TELEGRAM_BOT_TOKEN": "your_bot_token",
"TELEGRAM_CHAT_ID": "your_chat_id"
},
"disabled": false,
"autoApprove": []
}
}
}与Claude Desktop集成
将以下内容添加到您的Claude Desktop配置文件中:
{
"mcpServers": {
"telegram-mcp": {
"command": "node",
"args": ["path/to/telegram-mcp/build/index.js"],
"env": {
"TELEGRAM_BOT_TOKEN": "your_bot_token",
"TELEGRAM_CHAT_ID": "your_chat_id"
},
"disabled": false,
"autoApprove": []
}
}
}可用工具
send_通知
向配置的Telegram聊天发送通知消息。
参数:
message(必填):要发送给用户的消息project(必填):法学硕士正在进行的项目名称urgency(可选):紧急程度(“低”、“中”或“高”)
检查通知响应
检查用户是否已对之前发送的通知做出响应。
参数:
message_id(必填):用于检查响应的消息的IDtimeout_seconds(可选):放弃前等待响应的时间(默认值:30)
发展
# Clone the repository
git clone https://github.com/CHarrisTech/telegram-mcp.git
cd telegram-mcp
# Install dependencies
npm install
# Build the project
npm run build
# Watch for changes during development
npm run watch
# Test with the MCP Inspector
npm run inspector本地测试
存储库包括帮助您在本地测试服务器的脚本:
视窗
# Set environment variables
set TELEGRAM_BOT_TOKEN=your_bot_token
set TELEGRAM_CHAT_ID=your_chat_id
# Run the test script
test-server.batmacOS/Linux
# Set environment variables
export TELEGRAM_BOT_TOKEN=your_bot_token
export TELEGRAM_CHAT_ID=your_chat_id
# Make the script executable (first time only)
chmod +x test-server.sh
# Run the test script
./test-server.sh例子
这 examples 目录包含演示如何使用Telegram MCP服务器的示例代码:
programmatic-usage.js:演示如何在自己的Node.js应用程序中以编程方式使用服务器
举个例子:
# Set required environment variables
export TELEGRAM_BOT_TOKEN="your_bot_token"
export TELEGRAM_CHAT_ID="your_chat_id"
# Run the example
node examples/programmatic-usage.js许可证
麻省理工学院
