返回 MCP 目录
public公开dns本地运行

mcp-communicator-telegram

一个通过Telegram实现用户交互的MCP服务器,提供问答、通知、文件传输和项目打包功能

article

README

🚀 MCP 通信器(Telegram)

MCP 通信器(Telegram)是一个 MCP 服务器,可借助 Telegram 与用户展开通信。它提供了丰富工具,能通过 Telegram 机器人与用户互动,涵盖提问、发送通知、共享文件以及创建项目存档等功能。

🚀 快速开始

在使用 MCP 通信器(Telegram)之前,你需要满足以下先决条件:

  • Node.js (v14 或更高版本)
  • Telegram 机器人令牌(从@BotFather获得)
  • 你的 Telegram 聊天 ID(使用随附工具获取)

📦 安装指南

通过 npm(全局)

npm install -g mcp-communicator-telegram

使用 npx(按需)

npx mcptelegram

获取你的 Telegram 聊天 ID:

npx mcptelegram-chatid

克隆仓库安装

  1. 克隆仓库:
git clone https://github.com/qpd-v/mcp-communicator-telegram.git
cd mcp-communicator-telegram
  1. 安装依赖项:
npm install
  1. 创建 Telegram 机器人并获取令牌。

  2. 使用以下命令获取你的 Telegram 聊天 ID:

npx mcptelegram-chatid

✨ 主要特性

  • 通过 Telegram 向用户提问
  • 向用户发送通知(无需响应)
  • 通过 Telegram 发送文件给用户
  • 创建并发送项目的 ZIP 文件(尊重.gitignore 规则)
  • 异步接收用户响应(无限等待响应)
  • 支持回复 - based 消息跟踪
  • 安全聊天 ID 验证
  • 错误处理和日志记录

📚 详细文档

配置

将服务器添加到 MCP 设置文件中:

config/mcp.json 中添加以下内容:

{
  "telegram": {
    "botToken": "your_bot_token",
    "chatId": "your_chat_id"
  }
}

可用工具

ask_user

通过 Telegram 提问。

输入模式
{
  "type": "question",
  "question": "你的问题?",
  "messageId": "string" // 可选的Telegram消息ID,用于关联答案
}
示例用法:
await useMCP({
  server: 'telegram',
  tool: 'ask_user',
  arguments: {
    question: '你最喜欢的颜色是什么?',
    messageId: '12345'
  }
});

notify_user

通过 Telegram 发送通知。

输入模式
{
  "type": "notification",
  "message": "你的消息。",
  "messageId": "string" // 可选的Telegram消息ID
}
示例用法:
await useMCP({
  server: 'telegram',
  tool: 'notify_user',
  arguments: {
    message: '系统状态已更新。',
    messageId: '67890'
  }
});

send_file

通过 Telegram 发送文件。

输入模式
{
  "type": "file",
  "filePath": "path/to/file", // 可选的文件路径,默认为当前目录
  "message": "可选的消息内容"
}
示例用法:
  • 发送默认目录中的文件:
await useMCP({
  server: 'telegram',
  tool: 'send_file',
  arguments: {}
});
  • 发送特定路径的文件:
await useMCP({
  server: 'telegram',
  tool: 'send_file',
  arguments: {
    filePath: '/path/to/your/file'
  }
});

zip_project

创建并发送项目的 ZIP 文件。

输入模式
{
  "type": "directory",
  "directory": "string" // 可选的目录路径,默认为当前工作目录
}
示例用法:
  • 使用默认目录(当前工作目录):
await useMCP({
  server: 'telegram',
  tool: 'zip_project',
  arguments: {}
});
  • 指定特定目录:
await useMCP({
  server: 'telegram',
  tool: 'zip_project',
  arguments: {
    directory: '/path/to/specific/directory'
  }
});
help

运行方式说明

cloud

托管运行

托管运行通常表示这个 MCP Server 由服务方环境承载,用户一般按页面提供的连接方式或授权流程接入,不需要在本地长期启动一个 MCP 进程

  1. 打开服务方连接页
  2. 完成授权或复制端点
  3. 在 MCP 客户端中连接
terminal

本地运行 / 其它方式

本地运行通常需要用户在自己的电脑或服务器上安装依赖,把 server_config 复制到 MCP 客户端,并按 env_schema 补齐环境变量、密钥或其它配置

  1. 复制 server_config
  2. 安装所需依赖
  3. 补齐环境变量后重启客户端