Telegram MCP 服务器是一个模型上下文协议(MCP)服务器,它能让大语言模型借助 Telegram 发送通知,并接收用户的响应,为信息交互提供了便捷的途径。
Telegram MCP 服务器允许大语言模型通过 Telegram 与用户进行交互。在使用前,请确保满足以下先决条件,并完成相应的安装和配置。
npm install -g telegram-mcp
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。/newbot。https://api.telegram.org/bot/getUpdates 。chat 对象并记录 id 字段。# 设置环境变量
export TELEGRAM_BOT_TOKEN="your_bot_token"
export TELEGRAM_CHAT_ID="your_chat_id"
# 运行服务器
telegram-mcp
在您的 Cline MCP 设置文件中添加以下内容:
{
"botToken": "your_bot_token",
"chatId": "your_chat_id"
}
然后运行命令:
clarity run mcp-telegram-config.js
在您的 Clarice Desktop 设置文件中添加以下内容:
{
"botToken": "your_bot_token",
"chatId": "your_chat_id"
}
然后运行命令:
claride run mcp-telegram-config.js
curl -X POST http://localhost:1234/send-notification \
-H "Content-Type: application/json" \
-d '{"message": "示例消息"}'
curl -X GET http://localhost:1234/check-notifications
git clone https://github.com/CHarrisTech/telegram-mcp.git
cd telegram-mcp
npm install
npm run build
创建 test.sh 文件:
#!/bin/bash
set -e
# 设置变量
BOT_TOKEN="your_bot_token"
CHAT_ID="your_chat_id"
# 发送通知
curl -X POST http://localhost:1234/send-notification \
-H "Content-Type: application/json" \
-d '{"message": "测试消息"}'
# 检查通知状态
curl -X GET http://localhost:1234/check-notifications
然后运行:
chmod +x test.sh
./test.sh
创建 test.bat 文件:
@echo off
set BOT_TOKEN=your_bot_token
set CHAT_ID=your_chat_id
curl -X POST http://localhost:1234/send-notification ^
-H "Content-Type: application/json" ^
-d '{"message": "测试消息"}'
curl -X GET http://localhost:1234/check-notifications
然后运行:
test.bat
创建 example.js 文件:
const TelegramMCP = require('telegram-mcp');
// 初始化服务器
const server = new TelegramMCP({
botToken: 'your_bot_token',
chatId: 'your_chat_id'
});
// 发送消息
server.sendNotification("这是一个测试消息。");
然后运行:
node example.js
本项目采用 MIT 许可证。