关于 MCP Communicator (Telegram)
MCP Communicator (Telegram) 是一个通过 Telegram 机器人与用户通信的 MCP 服务。它允许 AI 在执行任务时向用户提问并等待回复,也可以发送通知、文件或项目压缩包。适合需要在离开电脑时与 Agent 保持沟通的开发者。
主要功能
- 01通过 Telegram 向用户提问并等待回复
- 02发送无需回复的通知消息
- 03向用户发送文件
- 04打包项目为 zip 并发送(遵循 .gitignore)
- 05基于聊天 ID 的消息校验
适用场景
- 01Agent 执行任务时需要用户确认或补充信息
- 02任务完成后通过 Telegram 收到通知
- 03将项目压缩包或生成的文件发送到手机
MCP 相关
该项目是一个 MCP 服务,向 MCP 客户端提供 ask_user、notify_user、send_file 和 zip_project 等工具,用于通过 Telegram 与用户交互。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
MCP 通信器(Telegram)
一个可通过 Telegram 与用户通信的 MCP 服务。此服务提供通过 Telegram 机器人与用户交互的工具,包括提问、发送通知、共享文件和创建项目归档。
安装
通过 npm(全局安装)
npm install -g mcp-communicator-telegram
通过 npx(按需运行)
npx mcptelegram
获取 Telegram 聊天 ID:
npx mcptelegram-chatid
功能
- 通过 Telegram 向用户提问
- 向用户发送通知(无需回复)
- 通过 Telegram 向用户发送文件
- 创建并发送项目 zip 文件(遵循 .gitignore)
- 异步接收回复(无限期等待回复)
- 支持基于回复的消息追踪
- 安全验证聊天 ID
- 错误处理和日志记录
先决条件
- Node.js(v14 或更高版本)
- Telegram 机器人令牌(从 @BotFather 获取)
- 您的 Telegram 聊天 ID(可使用随附的实用工具获取)
安装
- 克隆仓库:
git clone https://github.com/qpd-v/mcp-communicator-telegram.git
cd mcp-communicator-telegram
- 安装依赖项:
npm install
-
创建 Telegram 机器人:
- 打开 Telegram 并搜索 @BotFather
- 发送
/newbot并按照说明操作 - 保存收到的机器人令牌
-
获取您的聊天 ID:
- 将
.env.example复制为.env - 将机器人令牌添加到
.env文件中:TELEGRAM_TOKEN=your_bot_token_here - 运行聊天 ID 实用工具:
npm run build node build/get-chat-id.js - 向您的机器人发送任意消息
- 复制控制台中显示的聊天 ID
- 将聊天 ID 添加到
.env文件中:TELEGRAM_TOKEN=your_bot_token_here CHAT_ID=your_chat_id_here
- 将
配置
将此服务添加到您的 MCP 设置文件中(在 Windows 上通常位于 %APPDATA%\Code\User\globalStorage\rooveterinaryinc.roo-cline\settings\cline_mcp_settings.json):
{
"mcpServers": {
"mcp-communicator-telegram": {
"command": "node",
"args": ["path/to/mcp-communicator-telegram/build/index.js"],
"env": {
"TELEGRAM_TOKEN": "your_bot_token_here",
"CHAT_ID": "your_chat_id_here"
}
}
}
}
可用工具
ask_user
通过 Telegram 向用户提问并等待回复。
输入架构:
{
"type": "object",
"properties": {
"question": {
"type": "string",
"description": "The question to ask the user"
}
},
"required": ["question"]
}
使用示例:
const response = await use_mcp_tool({
server_name: "mcp-communicator-telegram",
tool_name: "ask_user",
arguments: {
question: "What is your favorite color?"
}
});
notify_user
通过 Telegram 向用户发送通知消息(无需回复)。
输入架构:
{
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "The message to send to the user"
}
},
"required": ["message"]
}
使用示例:
await use_mcp_tool({
server_name: "mcp-communicator-telegram",
tool_name: "notify_user",
arguments: {
message: "Task completed successfully!"
}
});
send_file
通过 Telegram 向用户发送文件。
输入架构:
{
"type": "object",
"properties": {
"filePath": {
"type": "string",
"description": "The path to the file to send"
}
},
"required": ["filePath"]
}
使用示例:
await use_mcp_tool({
server_name: "mcp-communicator-telegram",
tool_name: "send_file",
arguments: {
filePath: "path/to/file.txt"
}
});
zip_project
创建项目目录的 zip 文件(遵循 .gitignore 模式),并通过 Telegram 发送给用户。
输入架构:
{
"type": "object",
"properties": {
"directory": {
"type": "string",
"description": "Directory to zip (defaults to current working directory)"
}
},
"required": []
}
使用默认目录(当前工作目录)的示例:
await use_mcp_tool({
server_name: "mcp-communicator-telegram",
tool_name: "zip_project",
arguments: {}
});
使用指定目录的示例:
await use_mcp_tool({
server_name: "mcp-communicator-telegram",
tool_name: "zip_project",
arguments: {
directory: "/path/to/your/project"
}
});
功能:
- 根据目录名称创建名为
[project-name]-project.zip的 zip 文件 - 可压缩任何指定目录或当前工作目录
- 遵循 .gitignore 模式
- 在归档中保留正确的文件路径
- 发送后自动清理 zip 文件
- 支持最大 2GB 的文件
开发
构建项目:
npm run build
以开发模式运行:
npm run dev
监视更改:
npm run watch
清理构建目录:
npm run clean
安全
- 服务仅响应来自已配置聊天 ID 的消息
- 使用环境变量存储敏感配置
- 使用消息 ID 追踪问题与答案的对应关系
- 机器人会忽略缺少适当上下文的消息
许可证
ISC
作者
qpd-v
版本
0.2.1 # 新增功能:notify_user、send_file 和 zip_project 工具
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。