Telegram Mcp Server 65w

Telegram Mcp Server 65w

🚀 Telegram MCP 服务器

Telegram MCP 服务器是一个模型上下文协议(MCP)服务器,它能让大语言模型借助 Telegram 发送通知,并接收用户的响应,为信息交互提供了便捷的途径。

🚀 快速开始

Telegram MCP 服务器允许大语言模型通过 Telegram 与用户进行交互。在使用前,请确保满足以下先决条件,并完成相应的安装和配置。

✨ 主要特性

  • 可向 Telegram 聊天发送文字通知,且紧急程度可自定义。
  • 能够等待并检索用户的回应。
  • 可与 Cline 和其他 MCP 兼容的 LLM 应用程序集成。

📦 安装指南

通过 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 机器人令牌。
  • TELEGRAM_CHAT_ID:您的 Telegram 聊天 ID。

获取 Telegram 机器人令牌

  1. 在 Telegram 上与 @BotFather 开始对话。
  2. 发送命令 /newbot
  3. 按照指示创建一个新的机器人。
  4. BotFather 将为您提供新的机器人令牌。

查找您的聊天 ID

  1. 与新机器人开始对话。
  2. 向机器人发送一条消息。
  3. 访问 https://api.telegram.org/bot/getUpdates
  4. 在响应中查找 chat 对象并记录 id 字段。

💻 使用示例

单独运行

# 设置环境变量
export TELEGRAM_BOT_TOKEN="your_bot_token"
export TELEGRAM_CHAT_ID="your_chat_id"

# 运行服务器
telegram-mcp

与 Cline 集成

在您的 Cline MCP 设置文件中添加以下内容:

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

然后运行命令:

clarity run mcp-telegram-config.js

与 Clarice Desktop 集成

在您的 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

🧪 测试脚本示例

Linux/MacOS

创建 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

Windows

创建 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 许可证。

  • 0 关注
  • 0 收藏,28 浏览
  • system 提出于 2025-10-03 11:30

相似服务问题

相关AI产品