一个强大的模型上下文协议(MCP)服务器,用于与Telegram Bot API无缝集成,具有智能消息分割、全面错误处理和NPX支持。
npx telegram-bot-mcp-server 直接运行,无需安装# 直接运行,无需安装
npx telegram-bot-mcp-server
# 全局安装
npm install -g telegram-bot-mcp-server
# 或者本地安装
npm install telegram-bot-m
/newbot在您的MCP客户端(如Claude Desktop等)中添加以下配置:
{
"mcpServers": {
"telegram_bot": {
"command": "npx",
"args": ["telegram-bot-mcp-server"],
"env": {
"TELEGRAM_BOT_API_TOKEN": "your_bot_token_here"
}
}
}
}
全局安装:
{
"mcpServers": {
"telegram_bot": {
"command": "telegram-bot-mcp-server",
"env": {
"TELEGRAM_BOT_API_TOKEN": "your_bot_token_here"
}
}
}
}
本地安装:
{
"mcpServers": {
"telegram_bot": {
"command": "node",
"args": ["./node_modules/.bin/telegram-bot-mcp-server"],
"env": {
"TELEGRAM_BOT_API_TOKEN": "your_bot_token_here"
}
}
}
}
send-message发送文本消息,对于长内容自动分割。
chatId(字符串),text(字符串)send-photo发送带有标题的照片,自动处理长标题。
chatId(字符串),media(字符串),text(可选字符串)send-photo发送一张可选标题的照片。
chatId:目标聊天ID或用户名media:文件ID、URL或上传的文件text(可选):照片的标题kick-chat-member禁止用户在一个群组、超级群组或频道中。
chatId:目标聊天userId:被禁止的用户un-ban-chat-member解除之前被禁止用户的禁令。
chatId:目标聊天userId:被解除禁令的用户get-chat获取完整的聊天元数据和详情。
chatId:目标聊天get-chat-member-count获取群组或频道中的总成员数。
chatId:目标聊天get-chat-member获取群组或频道中特定成员的详细信息。
chatId:目标聊天userId:目标用户set-my-short-description更新机器人的简短描述(显示在个人资料和分享中)。
short_description:新的简短描述(最多120个字符)get-my-short-description获取当前机器人的简短描述。
set-my-commands设置出现在Telegram UI中的命令列表。
commands:命令对象数组get-my-commands获取当前配置给机器人的命令列表。
set-my-name更新机器人的名称。
name:新的机器人名称get-my-name检索当前机器人的名称。
set-my-description更新机器人的完整描述(显示在空闲聊天中)。
description:新的机器人描述(最多512个字符)kick-chat-member / un-ban-chat-member管理聊天成员,提供详细的错误报告。
chatId(字符串),userId(数字)get-chat / get-chat-member / get-chat-member-count检索详细的聊天和成员信息。
chatId(字符串),userId(数字,用于成员信息)get-me测试机器人认证并检索机器人信息。
set-my-name / get-my-name配置和检索机器人名称。
name(字符串,0-64个字符)set-my-description / get-my-description配置和检索机器人描述。
description(字符串,0-512个字符)set-my-short-description / get-my-short-description配置和检索机器人简短描述。
short_description(字符串,0-120个字符)set-my-commands / get-my-commands配置和检索机器人命令。
commands(命令对象数组)npx telegram-bot-mcp-server 直接运行❌ 错误:缺少Telegram Bot Token
解决方案:设置 TELEGRAM_BOT_API_TOKEN 环境变量:
export TELEGRAM_BOT_API_TOKEN="your_token_here"
npx telegram-bot-mcp-server
已被详细错误消息取代。更新到最新版本以获得更好的错误报告。
解决方案:确保已安装Node.js 18+:
node --version # 应该是18.0.0或更高版本
npm --version # 应该随Node.js一起包含
解决方案:在Unix系统上,您可能需要使用 sudo 进行全局安装:
sudo npm install -g telegram-bot-mcp-server
设置 NODE_ENV=development 以获取额外的调试信息:
NODE_ENV=development npx telegram-bot-mcp-server
// 通过MCP客户端
await sendMessage({
chatId: "@username",
text: "你好!这是一条测试消息。"
});
// 超过4096字符的消息会自动分割
await sendMessage({
chatId: "123456789",
text: "非常长的消息内容..." // 将自动分割
});
await sendPhoto({
chatId: "123456789",
media: "https://example.com/photo.jpg",
text: "非常长的标题..." // 如果需要,将被分割
});
git checkout -b feature-namegit commit -am '添加功能'git push origin feature-name此项目根据MIT许可证发布 - 查看LICENSE文件以获取详细信息。
如果您发现这个项目有用,请考虑支持开发者: