TT

timoncool/telegram-api-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

34 stars 12 forks 质量 83 趋势 20MIT

终极 Telegram 机器人 API MCP 服务器——完整覆盖 v9.6,元模式,速率限制,断路器。TypeScript。

概览

185/185 机器人 API 方法,具备 Zod 验证、令牌掩蔽、工具注释和零臃肿(2 个依赖)。 - — 消息、媒体、投票、聊天、论坛、贴纸、支付、商业、故事、礼物、游戏、内联、托管机器人 - — 发布最多32768字符,包含标题、表格、列表、拼贴、幻灯片、脚注和最多50个内联媒体,取代1024字符的标题上限 - (2026年7月)— 丰富消息、短暂消息、实时照片、访客模式、加入请求查询、投票媒体 - — 服务器在发送前会解释rich_message、媒体、reply_markup、投票等的具体形状,因此代理无需猜语法(也作为MCP资源 telegram://format/......

概述(AI 翻译)

Telegram Bot API 终极 MCP 服务器——185 种方法,完整覆盖 v10.2,丰富消息,元模式,速率限制,断路器。

185/185 机器人 API 方法,具备 Zod 验证、令牌掩蔽、工具注释和零臃肿(2 个依赖)。

特色

  • 185/185 机器人API方法 — 消息、媒体、投票、聊天、论坛、贴纸、支付、商业、故事、礼物、游戏、内联、托管机器人
  • 丰富信息 — 最多可发布32768字符,包含标题、表格、列表、拼贴、幻灯片、脚注及多达50个内联媒体,取代了1024字符的说明上限
  • Bot API 10.2(2026年7月)— 富消息、临时消息、实时照片、访客模式、加入请求查询、投票媒体
  • telegram_format 工具 — 服务器在发送前会解释 rich_message、media、reply_markup、poll 等的具体形状,因此代理无需猜测语法(也作为 MCP 资源在 telegram://format/… 下展示)
  • 元模式 — 2个工具代替185个,节省~99%的上下文标记
  • 速率限制 — 全局(30 req/sec)+ 每个聊天(20 msg/min),带异步互斥器的令牌桶

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

185/185 Bot API methods with Zod validation, token masking, tool annotations, and zero bloat (2 dependencies).

Features

  • 185/185 Bot API methods — messages, media, polls, chats, forums, stickers, payments, business, stories, gifts, games, inline, managed bots
  • Rich messages — post up to 32768 characters with headings, tables, lists, collages, slideshows, footnotes and up to 50 inline media, instead of the 1024-character caption ceiling
  • Bot API 10.2 (July 2026) — rich messages, ephemeral messages, live photos, guest mode, join-request queries, poll media
  • telegram_format tool — the server explains the exact shape of rich_message, media, reply_markup, poll and more before you send, so an agent never has to guess the syntax (also exposed as MCP resources under telegram://format/…)
  • Meta-mode — 2 tools instead of 185, saves ~99% context tokens
  • Rate limiting — global (30 req/sec) + per-chat (20 msg/min), token bucket with async mutex
  • Circuit breaker — 3-state (closed/open/half-open), auto-recovery
  • Retry with backoff — respects Telegram 429 retry_after, exponential backoff on 5xx
  • Zod validation — every parameter validated before hitting Telegram API
  • Token masking — bot token never appears in responses, logs, or error messages
  • File upload security — path traversal protection, configurable allowed directories
  • Tool annotations — all 185 methods annotated (readOnly, destructive, idempotent, openWorld)
  • Docs mirror + audit — npm run docs:refresh re-downloads the official spec, npm run audit fails if any method or parameter drifts from it
  • Response truncation — 100K char limit to prevent context overflow
  • Zero bloat — only 2 dependencies: @modelcontextprotocol/sdk + zod

Quick Start

Claude Code

claude mcp add telegram -- npx telegram-api-mcp -e TELEGRAM_BOT_TOKEN=your_token

With meta-mode (recommended for large conversations):

claude mcp add telegram -- npx telegram-api-mcp \
  -e TELEGRAM_BOT_TOKEN=your_token \
  -e TELEGRAM_META_MODE=true

Claude Desktop

Add to claude_desktop_config.json:

在 GitHub 查看完整 README

安装

npx telegram-api-mcp
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "telegram": { "command": "npx", "args": ["telegram-api-mcp"], "env": { "TELEGRAM_BOT_TOKEN": "your_token_from_botfather" } } } }