Telegram MCP Server
This MCP server lets an AI coding agent use Telegram as a remote notification, approval, reply, and file-sharing channel.
Send structured Telegram notifications for completed/error/question/progress events with short summaries and optional details.
Wait for and receive user replies or next instructions via blocking polling, with a default wait up to 7 days.
Send free-form messages, syntax-highlighted code snippets, images, and arbitrary files.
Retrieve and send session context such as token usage, runtime, system info, and Telegram configuration.
Run an unattended remote task loop: complete work, notify the user, wait for the next Telegram instruction, and exit on command or interrupt.
Support mobile interaction with coding agents without wrapping or spawning vendor CLIs, per the README's ToS-safe MCP design.
Provides comprehensive Telegram Bot integration with tools for sending messages, files, images, code snippets, and managing two-way communication sessions with smart polling mechanisms
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Telegram MCP Server enter unattended mode and refactor the authentication module"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Telegram MCP Server v2.0
100% Pure Official MCP Mobile Remote Control Hub for AI Coding Agents Native support for Antigravity Desktop App /
agyCLI · Claude Code Desktop App /claudeCLI · Claude Desktop · Codex Desktop App /codexCLI
English | 简体中文
ToS Compliance by Design
In 2026, Google (Antigravity Additional Terms Section 6), Anthropic (Claude Code Legal & Compliance), and OpenAI all restrict third-party wrappers, OAuth credential extraction, and cross-agent CLI orchestration on personal subscriptions.
Telegram MCP Server v2.0 is deliberately 100% pure MCP:
Zero OAuth access: never reads, proxies, or stores vendor login tokens.
Zero CLI wrapping or cross-agent spawning: never launches
agy/claude/codexsubprocesses on your behalf.100% official MCP protocol: you launch official Antigravity, Claude Code, or Codex sessions yourself; this server solely bridges structured reports, approvals, questions, files, and human instructions with your Telegram app.
Related MCP server: Claude Code Telegram Bridge
Highlights of v2.0
MCP 2.x Native (
MCPServer): Supports bothstdioandstreamable-httptransports, MCProots/listworkspace discovery,client_infofingerprinting, one-commandtgbotprompt, and read-onlytelegram://sessionsresource.Built for Both Desktop Apps & CLIs:
Collision-free session IDs (
agy-app-webapp-7f2c,claude-api-9a1e,codex-cli-4d8b) + short aliases (/rename).24-hour persistent waiting (
86400sdefault on Antigravity App/CLI, Claude Code App/CLI, and Codex App/CLI;50schunked wait on standalone Claude Desktop) + 15s MCP progress heartbeats so long sessions never disconnect or spam duplicate sessions.Explicit
telegram_register_session(project_path=...)so Desktop Apps launched from/or$HOMEalways bind to the real workspace.
SQLite WAL Multi-Process Store + Resilient Leader Failover:
Replaces legacy JSON files with ACID SQLite WAL (
~/.telegram-mcp/state.db), cross-platform atomic OS file locks (flock/msvcrt), and automatic standby takeover within 2.5s.0.5-second local wakeup when you reply on Telegram (down from 30–120s in v0.2.x).
Optional Dedicated Hub Daemon (
telegram-mcp-server daemon start):Keep one stable Bot process running in the background while opening/closing Desktop Apps and terminals freely; add
--http --port 8765for a shared MCP Streamable HTTP endpoint.
Hardened Security & Reliability:
Strict Chat/User ID allowlist on every command, message, attachment, and callback.
Workspace-jailed
/fileand/ls(blocks../traversal).HTML-safe Telegram rendering with auto-chunking and plain-text fallback.
Exact
message_id -> (session_id, question_id)swipe-reply routing.
Quick Start
1. Install
# Recommended: install latest v2.0 directly from GitHub via uv
uv tool install --force git+https://github.com/archetyx/telegram-mcp-server.git
# Or via pip:
pip install --upgrade git+https://github.com/archetyx/telegram-mcp-server.git
# Or from a local checkout:
uv tool install --force .Note: verify you are running v2.0 with
telegram-mcp-server --version(PyPI may still serve legacy0.2.4until2.0.0is published).
2. Guided Multi-Client Setup
telegram-mcp-server setupDetects and configures:
Antigravity Desktop App / IDE /
agyCLI →~/.gemini/config/mcp_config.jsonClaude Code CLI / Desktop App →
~/.claude.json+~/.claude/settings.jsonClaude Desktop → OS-specific
claude_desktop_config.jsonCodex Desktop App /
codexCLI →~/.codex/config.tomlShared credentials in
~/.telegram-mcp/config.json(0600) + one-command/tgbotslash-command skill installation (telegram-mcp-server install-skill) across Antigravity (~/.gemini/config/skills/tgbot/SKILL.md), Claude Code (~/.claude/skills/tgbot/SKILL.md+~/.claude/commands/tgbot.md), and Codex (~/.codex/skills/tgbot/SKILL.md+~/.codex/prompts/tgbot.md).
3. One-Command Activation: Just Type /tgbot
After restarting Antigravity, Claude Code, or Codex, simply type:
/tgbot— registers the current workspace, sends a ready card with starter buttons to Telegram, and enters the unattended remote loop./tgbot <your task>— registers the workspace, executes the task, reports results with action buttons, and waits for your next mobile instruction./tgbot once <your task>— non-blocking mode: executes the task, sends the report to Telegram, and immediately returns control to your desktop chat without enteringtelegram_wait.
4. Optional Dedicated Hub Daemon & Diagnostics
telegram-mcp-server daemon start
# Or with shared MCP Streamable HTTP at http://127.0.0.1:8765/mcp:
telegram-mcp-server daemon start --http --port 8765
# Diagnostics
telegram-mcp-server doctorCore MCP Tools (8 Pure MCP Tools)
Tool | Purpose |
| Bind/update session alias & real workspace |
| Send structured reports ( |
| Atomic question / decision / approval prompt + wait with 15s MCP progress heartbeats |
| Wait for next instruction ( |
| Non-blocking inbox peek/pop for mid-task course corrections |
| Syntax-highlighted code/diff sender (auto-uploads as file when large) |
| Smart image (photo) or document sender resolved relative to |
| Context, token usage, uptime & read-only peer session overview |
Telegram Commands
/sessions(/s) — Interactive multi-session dashboard (switch, inspect, prune offline)/use <id|alias|off>— Pin/unpin active session/to <id|alias> [message]— Send instruction & switch active session (supports alias or unique prefix/suffix)/status [id]— Detailed session state, PID, queue depth & last report/rename [id] <alias>— Assign a short friendly alias/exit [id]— Exit remote wait mode gracefully and release your desktop chat/stop [id]//clear [id]//close <id>— Signal stop, clear inbox queue, or close session/ls [id] [subpath]//file [id] <path> [download]— Sandboxed workspace browser & file viewer/launch— ToS-safe manual launch tips for Antigravity, Claude Code & Codex
Development & Tests
uv venv .venv
uv pip install --python .venv/bin/python -e ".[dev]"
.venv/bin/pytest -vLicense
MIT License — see LICENSE.
Available Tools
8 toolstelegram_get_context_infoA
获取并发送当前会话的上下文信息到 Telegram
⚠️ 重要:调用此工具时,你应该:
1. 检查系统提供的 token 使用量信息(<budget:token_budget> 标签)
2. 将 token 使用情况包含在发送的信息中
3. 发送完整的上下文信息(会话信息 + token 使用情况)
返回信息应包括:
- 会话 ID 和项目路径
- Token 使用量(已使用 / 总量 / 剩余 / 使用率)
- 会话运行时间
- 系统信息
- Telegram 配置
示例输出格式:
📊 会话上下文信息
🆔 会话: testtg
📁 项目: /path/to/project
💾 Token 使用:
- 已使用: 41,853 tokens
- 总容量: 1,000,000 tokens
- 剩余: 958,147 tokens
- 使用率: 4.2%
⏱️ 运行时间: 15 分钟
🖥️ 系统: Darwin 24.6.0
🐍 Python: 3.14.0
Inputs: token_total, token_used.
telegram_notifyA
发送结构化通知到 Telegram
参数:
- event: 事件类型(completed/error/question/progress)
- summary: 简短总结,必填,限制200字以内
- details: 详细信息,可选
最佳实践:
1. summary 必须简洁明了(1-2句话),说明做了什么、结果如何
2. 不要包含思考过程、不要包含代码片段
3. 需要用户决策时,清晰说明选项
示例:
telegram_notify(
event="completed",
summary="修复了 auth.py:45 的空指针异常,所有测试通过",
details="修改文件: auth.py, test_auth.py\n测试: 12/12 passed"
)
telegram_notify(
event="question",
summary="发现3种修复方案:1)添加空值检查 2)使用Optional类型 3)重构整个模块。推荐方案1,是否继续?"
)
Inputs: event (required), summary (required), details.
telegram_sendA
发送自由格式消息到 Telegram(不推荐,请优先使用 telegram_notify)
自动处理:
- 超过300字自动截断
- 会提示使用 telegram_notify 发送结构化消息
Inputs: message (required).
telegram_send_codeA
发送代码段到 Telegram(带语法高亮)
⚠️ 使用场景(仅在必要时使用):
- 遇到关键错误需要展示问题代码
- 修复了重要 bug,需要展示修复方案
- 用户明确要求查看某段代码
- 需要用户 review 关键代码片段
❌ 不要使用的场景:
- 一般性任务完成(使用 telegram_notify)
- 创建了新文件(使用 telegram_send_file)
- 例行操作(使用 telegram_notify 总结即可)
参数:
- code: 代码内容(建议不超过50行)
- language: 编程语言(python/javascript/go/rust/bash/json/yaml等)
- caption: 可选说明文字(建议填写,解释发送这段代码的原因)
示例:
telegram_send_code(
code="def hello():\n print('Hello')",
language="python",
caption="修复了空指针异常的关键函数"
)
Inputs: code (required), caption, language.
telegram_send_fileA
发送文件到 Telegram
⚠️ 使用场景(仅在必要时使用):
- 用户明确要求查看某个文件:"查看 config.json"、"发送 main.py 给我"
- 创建了重要的输出文件需要用户确认(如配置文件、报告等)
- 生成了图表、图片等需要展示的文件
- 需要用户下载某个文件进行后续操作
❌ 不要使用的场景:
- 创建普通代码文件(用 telegram_notify 总结即可)
- 修改了文件但不需要用户查看内容
- 例行的文件操作
优先级:
1. 优先使用 telegram_notify 总结文件变更
2. 如果用户明确要求,或确实需要查看,才发送文件
3. 对于代码文件,如果只需要展示关键片段,优先使用 telegram_send_code
参数:
- file_path: 文件路径(相对于项目目录或绝对路径)
- caption: 可选说明文字
支持:
- 文本文件、代码文件
- 图片、PDF、文档等任意文件类型
- 自动处理大文件
示例:
telegram_send_file(
file_path="src/main.py",
caption="修复后的主文件(用户要求查看)"
)
Inputs: file_path (required), caption.
telegram_send_imageA
发送图片到 Telegram
⚠️ 使用场景:
- 生成了图表、可视化结果
- 创建了截图、示意图
- 需要用户查看图片内容
- 图片格式:PNG, JPG, GIF, WebP 等
参数:
- image_path: 图片文件路径(相对于项目目录或绝对路径)
- caption: 可选说明文字
示例:
telegram_send_image(
image_path="output/chart.png",
caption="性能测试结果图表"
)
Inputs: image_path (required), caption.
telegram_unattended_modeA
进入无人值守模式 - 智能远程任务循环
工作流程:
1. 执行当前任务
2. 根据情况智能选择通知方式:
- 默认:使用 telegram_notify 发送总结
- 遇到关键问题/错误:使用 telegram_send_code 展示问题代码
- 用户明确要求:使用 telegram_send_file 发送文件
3. 调用 telegram_unattended_mode 等待下一步指令(静默等待,不发送额外提示)
4. 收到指令后执行,重复循环
⚠️ 重要:
- 完成任务后必须调用 telegram_notify 发送结果
- telegram_unattended_mode 本身不发送消息,只等待
- 这样用户每次只收到任务结果,不会有重复的等待提示
📋 通知内容最佳实践:
✅ 优先发送总结:
- "修复了 auth.py 的空指针异常,测试通过"
- "创建了 3 个文件:main.py, utils.py, test.py"
- "代码重构完成,性能提升 30%"
⚠️ 仅在必要时发送代码:
- 遇到无法自动修复的错误,需要展示错误代码
- 修复了关键 bug,展示修复前后对比
- 用户明确要求:"查看 main.py"、"发送代码给我"
🎯 智能判断示例:
- 创建新文件 → telegram_notify("创建了 config.json")
- 修复 bug → telegram_notify("修复了登录异常") + 如果复杂就 telegram_send_code
- 用户问"文件内容是什么" → telegram_send_file
退出方式:
- Telegram 发送 "退出" 或 "exit"
- Claude Code 按 Ctrl+C 或 ESC
轮询策略:
- 前10分钟:每30秒检查一次
- 10分钟-1小时:每60秒检查一次
- 1小时以上:每120秒检查一次
参数:
- current_status: 当前任务状态的简短总结(1-2句话)
- max_wait: 每次等待的最长时间(秒),默认604800(7天)
- silent: 静默模式(不发送等待提示,默认 false)
- 首次进入时使用 false(发送提示)
- 后续循环使用 true(减少噪音)
返回:
- next_instruction: 用户的下一步指令
- should_exit: 是否应该退出无人值守模式
- interrupted: 是否被用户中断(Ctrl+C/ESC)
Inputs: current_status, max_wait.
telegram_wait_replyA
等待用户回复(阻塞式轮询)
参数:
- max_wait: 最长等待时间(秒),默认604800(7天/1周)
行为:
- 前10分钟:每30秒检查一次
- 10分钟-1小时:每60秒检查一次
- 1小时以上:每120秒检查一次
- 用户可以按 Ctrl+C 中断等待
- 超时返回 timeout: true
返回:
- reply: 用户回复内容
- timeout: 是否超时
- interrupted: 是否被用户中断
Inputs: max_wait.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Most tools have distinct purposes: get_context_info for session info, notify for structured notifications, send for free messages, send_code for code snippets, send_file for files, send_image for images, unattended_mode for task loops, and wait_reply for blocking replies. However, send and notify could be confused as both send messages, though descriptions clarify notify is preferred for structured content.
All tools follow a consistent 'telegram_' prefix with snake_case naming (e.g., telegram_get_context_info, telegram_notify). The verb-noun pattern is clear and uniform across all eight tools, making them easily identifiable and predictable.
With 8 tools, the set is well-scoped for a Telegram integration server. It covers core functionalities like sending messages, files, images, and code, plus advanced features like context retrieval and unattended modes, without being overwhelming or lacking essential operations.
The toolset provides comprehensive coverage for Telegram communication, including sending various content types, receiving replies, and managing sessions. A minor gap is the lack of tools for managing Telegram-specific entities like chats or users, but the focus on agent notification workflows is well-covered.
Maintenance
Related MCP Connectors
Project memory, tasks and Telegram notifications for your coding agent. Chip account required.
Let AI assistants post to your Telegram chats, groups and channels. Not affiliated with Telegram.
Send AI results to Telegram as private notifications or channel posts. No copy-pasting - connect your Telegram account and publish directly from AI assistants.
Your Telegram, WhatsApp, Instagram, mail and calendar in Claude or ChatGPT. Never sends messages.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceConnects Claude Code sessions to Telegram, enabling AI-powered code assistance and file management directly from Telegram chats.88MIT
- AlicenseNot gradedqualityCmaintenanceEnables remote control of Claude Code through Telegram, letting users start or resume sessions, review tool calls with approve/deny buttons, and manage long-running work from a phone.Apache 2.0
- AlicenseNot gradedqualityAmaintenanceEnables users to run and control Claude Code from Telegram around the clock, with two-way voice notes, persistent memory across restarts, live tool-call progress, scheduled reminders/calendar, and daemon-backed session management.MIT
- AlicenseNot gradedqualityAmaintenanceEnables running Claude Code continuously from Telegram, with two-way voice notes, persistent memory across restarts, a self-restarting daemon, and live visibility into every tool call. It lets users drive coding sessions, approve permission prompts, schedule messages, and manage Google Calendar directly from chat.MIT