Skip to main content
Glama
Telegram MCP Server
by archetyx

Telegram MCP Server v2.0

100% Pure Official MCP Mobile Remote Control Hub for AI Coding Agents Native support for Antigravity Desktop App / agy CLI · Claude Code Desktop App / claude CLI · Claude Desktop · Codex Desktop App / codex CLI

Python MCP ToS Safe License

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 / codex subprocesses 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 both stdio and streamable-http transports, MCP roots/list workspace discovery, client_info fingerprinting, one-command tgbot prompt, and read-only telegram://sessions resource.

  • 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 (86400s default on Antigravity App/CLI, Claude Code App/CLI, and Codex App/CLI; 50s chunked 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 $HOME always 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 8765 for a shared MCP Streamable HTTP endpoint.

  • Hardened Security & Reliability:

    • Strict Chat/User ID allowlist on every command, message, attachment, and callback.

    • Workspace-jailed /file and /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 legacy 0.2.4 until 2.0.0 is published).

2. Guided Multi-Client Setup

telegram-mcp-server setup

Detects and configures:

  • Antigravity Desktop App / IDE / agy CLI → ~/.gemini/config/mcp_config.json

  • Claude Code CLI / Desktop App → ~/.claude.json + ~/.claude/settings.json

  • Claude Desktop → OS-specific claude_desktop_config.json

  • Codex Desktop App / codex CLI → ~/.codex/config.toml

  • Shared credentials in ~/.telegram-mcp/config.json (0600) + one-command /tgbot slash-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 entering telegram_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 doctor

Core MCP Tools (8 Pure MCP Tools)

Tool

Purpose

telegram_register_session

Bind/update session alias & real workspace project_path (essential for Desktop Apps)

telegram_report

Send structured reports (completed/progress/error/info) + up to 6 one-tap action buttons

telegram_ask

Atomic question / decision / approval prompt + wait with 15s MCP progress heartbeats

telegram_wait

Wait for next instruction (unattended) or reply (reply) with 0.5s wakeup & chunked timeout continuation

telegram_check_inbox

Non-blocking inbox peek/pop for mid-task course corrections

telegram_send_code

Syntax-highlighted code/diff sender (auto-uploads as file when large)

telegram_send_file

Smart image (photo) or document sender resolved relative to project_path

telegram_session_info

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 -v

License

MIT License — see LICENSE.

Available Tools

8 tools
telegram_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

    A4.4/5.0

    Scored across 8 tools

    Disambiguation4/5

    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.

    Naming Consistency5/5

    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.

    Tool Count5/5

    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.

    Completeness4/5

    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

    ActivityMaintained
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Connects Claude Code sessions to Telegram, enabling AI-powered code assistance and file management directly from Telegram chats.
      88
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables 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
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables 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