MCP-Communicator-Telegram

MCP-Communicator-Telegram

一个 MCP 服务器,可以通过 Telegram 与用户进行通信。该服务器提供一个工具,可以向用户提问并通过 Telegram 机器人接收他们的回复。

Git管理工具
访问服务器

README

MCP 通讯器 (Telegram)

一个 MCP 服务器,可以通过 Telegram 与用户进行通信。该服务器提供通过 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(可以使用提供的实用程序获取)

安装步骤

  1. 克隆仓库:
git clone https://github.com/qpd-v/mcp-communicator-telegram.git
cd mcp-communicator-telegram
  1. 安装依赖:
npm install
  1. 创建一个 Telegram 机器人:

    • 打开 Telegram 并搜索 @BotFather
    • 发送 /newbot 并按照说明操作
    • 保存您收到的机器人令牌
  2. 获取您的聊天 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 向用户提问并等待他们的回复。

输入 Schema:

{
  "type": "object",
  "properties": {
    "question": {
      "type": "string",
      "description": "要向用户提出的问题"
    }
  },
  "required": ["question"]
}

使用示例:

const response = await use_mcp_tool({
  server_name: "mcp-communicator-telegram",
  tool_name: "ask_user",
  arguments: {
    question: "你最喜欢的颜色是什么?"
  }
});

notify_user

通过 Telegram 向用户发送通知消息(无需回复)。

输入 Schema:

{
  "type": "object",
  "properties": {
    "message": {
      "type": "string",
      "description": "要发送给用户的消息"
    }
  },
  "required": ["message"]
}

使用示例:

await use_mcp_tool({
  server_name: "mcp-communicator-telegram",
  tool_name: "notify_user",
  arguments: {
    message: "任务已成功完成!"
  }
});

send_file

通过 Telegram 向用户发送文件。

输入 Schema:

{
  "type": "object",
  "properties": {
    "filePath": {
      "type": "string",
      "description": "要发送的文件的路径"
    }
  },
  "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 将其发送给用户。

输入 Schema:

{
  "type": "object",
  "properties": {
    "directory": {
      "type": "string",
      "description": "要压缩的目录(默认为当前工作目录)"
    }
  },
  "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 工具

推荐服务器

AIO-MCP Server

AIO-MCP Server

🚀 集成了 AI 搜索、RAG 和多服务(GitLab/Jira/Confluence/YouTube)的一体化 MCP 服务器,旨在增强 AI 驱动的开发工作流程。来自 Folk。

精选
本地
https://github.com/Streen9/react-mcp

https://github.com/Streen9/react-mcp

react-mcp 与 Claude Desktop 集成,能够根据用户提示创建和修改 React 应用程序。

精选
本地
mcp-codex-keeper

mcp-codex-keeper

作为开发知识的守护者,为 AI 助手提供精心策划的最新文档和最佳实践访问权限。

精选
db-mcp-tool

db-mcp-tool

一个强大的模型上下文协议(MCP)工具,用于探索和管理不同类型的数据库,包括 PostgreSQL、MySQL 和 Firestore。

精选
Project Handoffs MCP Server

Project Handoffs MCP Server

通过基于项目的组织方式,促进 AI 会话的交接和后续步骤的跟踪,从而支持任务优先级排序和无缝工作流程管理。

本地
Code Knowledge MCP Server

Code Knowledge MCP Server

为增强代码理解和管理,提供项目记忆库和 RAG 上下文提供器,通过向量嵌入,与 RooCode 和 Cline 集成。

本地
OSP Marketing Tools MCP Server

OSP Marketing Tools MCP Server

支持与任何支持 MCP 的 LLM 客户端无缝集成,以使用 Open Strategy Partners 的方法论创建和优化技术内容和产品定位。

本地
MCP Server Neurolorap

MCP Server Neurolorap

将文件和目录中的代码收集到一个 Markdown 文档中的 MCP 服务器。

本地
Linear MCP Server

Linear MCP Server

使 AI 代理能够以编程方式在 Linear 平台上管理问题、项目和团队。

本地
Dart MCP Server

Dart MCP Server

一个可分发的模型上下文协议(MCP)服务器,它公开 Dart SDK 命令,用于 AI 驱动的开发。该服务器通过实现模型上下文协议(MCP),弥合了 AI 编码助手与 Dart/Flutter 开发工作流程之间的差距。

本地