Telegram MCP Server

Telegram MCP Server

site icon
2025.03.22 2
JavaScript通知服务用户交互交流协作
Telegram MCP Server 是一个基于 Model Context Protocol (MCP) 的服务,它使大型语言模型(LLMs)能够通过 Telegram 发送通知并接收用户响应。该服务支持与 Cline 和其他兼容 MCP 的 LLM 应用程序集成,提供灵活的通知发送和响应接收功能。
View on GitHub

Overview

基本能力

产品定位

Telegram MCP Server 是一个用于增强 LLMs 与用户交互能力的中间件服务,通过 Telegram 实现通知的发送和响应的接收。

核心功能

  • 发送文本通知到 Telegram 聊天,支持自定义紧急级别
  • 等待并获取用户响应
  • 与 Cline 和其他 MCP 兼容的 LLM 应用程序集成

适用场景

  • 需要 LLMs 向用户发送通知并等待响应的场景
  • 需要集成 Telegram 通知功能的 LLM 应用
  • 需要自定义通知紧急级别的应用场景

工具列表

  1. send_notification: 发送通知消息到配置的 Telegram 聊天
  2. 参数: message(必需)、project(必需)、urgency(可选)
  3. check_notification_response: 检查用户是否已响应之前发送的通知
  4. 参数: message_id(必需)、timeout_seconds(可选)

常见问题解答

  1. 如何获取 Telegram Bot Token?
  2. 与 @BotFather 聊天,发送 /newbot 命令,按照指示创建新 bot
  3. 如何找到 Chat ID?
  4. 发送消息到你的 bot,访问 https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates,查找响应中的 chat 对象的 id 字段

使用教程

使用依赖

  • Node.js 16 或更高版本
  • Telegram bot token(从 @BotFather 获取)
  • 你的 Telegram chat 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 bot token - TELEGRAM_CHAT_ID: 你的 Telegram chat ID

调试方式

独立运行

export TELEGRAM_BOT_TOKEN="your_bot_token"
export TELEGRAM_CHAT_ID="your_chat_id"
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": []
    }
  }
}

许可证

该项目遵循 MIT 开源许可条款,请参阅 MIT 了解完整条款。