
Telegram MCP
io.github.n24q02m由 GitHub 帳號 n24q02m 發布v4.23.0更新於 Oct 29, 2026
Telegram for AI agents: messages, chats, media, and contacts in bot and user-account modes.
概覽
Telegram MCP 伺服器,讓 AI 助理透過機器人權杖或使用者帳號收發與管理訊息、聊天、媒體和聯絡人。
- 可以做什麼
- 傳送、編輯、刪除、轉寄、置頂、回應訊息,並搜尋與瀏覽歷史紀錄
- 列出、建立、加入、離開與管理聊天、群組和頻道,包含成員與論壇話題
- 傳送照片、檔案、語音和影片,並從訊息下載媒體
- 列出、搜尋、新增聯絡人,並在使用者模式下封鎖或解除封鎖使用者
- 查看伺服器狀態、調整執行期設定、清除快取,並提供內建說明與文件資源
- 適用情境
- 適合讓助理直接在 Telegram 中工作:草擬並傳送訊息、整理聊天與頻道、轉寄或置頂內容,或把媒體與歷史紀錄帶入工作流程。機器人模式適合頻道與群組自動化;需要以個人身分操作(包含封鎖聯絡人)時則需使用者帳號模式。
- 執行需求
- 以 stdio 方式在本機執行,可透過 uvx(Python 套件 n24q02m-telegram)或 Docker 啟動。機器人模式需要 TELEGRAM_BOT_TOKEN;使用者模式需要手機號碼並完成 OTP 及選用的 2FA,可用 TELEGRAM_API_ID 與 TELEGRAM_API_HASH 覆寫內建 API 組。憑證可用 telegram auth 指令儲存或透過環境變數提供。選用 HTTP 模式,支援 bearer 權杖驗證。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Telegram MCP,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
telegram
mcp-name: io.github.n24q02m/better-telegram-mcp
Telegram for AI agents: messages, chats, media, and contacts in bot and user-account modes.
[Mode] [CI] [codecov] [PyPI] [Docker] [License: Apache-2.0]
[Python] [Telegram] [MCP] [semantic-release] [Renovate]
Sister projects from n24q02m (click to expand)
Table of contents
- Features
- Install
- Setup
- Smithery
- Configuration
- HTTP mode
- CLI
- Tools
- Comparison
- Security
- Build from Source
- Trust Model
- License
Features
- Dual mode -- Bot API (httpx) for bots, MTProto (Telethon) for user accounts
- 6 tools with action dispatch:
message,chat,media,contact,config,help - Auto-detect mode -- Set a bot token for bot mode, or a phone number for user mode
- Local CLI auth --
telegram authhandles the bot token, or phone + OTP + 2FA, on the machine that runs the server - Stdio or HTTP -- stdio by default; HTTP with no-auth (loopback only), a single bearer token, or per-user tokens
- Tool annotations -- Each tool declares
readOnlyHint,destructiveHint,idempotentHint,openWorldHint - MCP Resources -- Documentation available as
telegram://docs/*resources - Security hardened -- SSRF protection, path traversal prevention, error sanitization, prompt-injection boundary tags on Telegram content
Install
The package is n24q02m-telegram (formerly better-telegram-mcp; the old
package receives one final release then freezes). The MCP Registry id stays
io.github.n24q02m/better-telegram-mcp, the Docker image is
n24q02m/telegram, and the legacy better-telegram-mcp command is kept as an
alias of telegram. Local data moves once from ~/.better-telegram-mcp to
~/.telegram on first start.
Install matrix
Install with AI agent -- paste this to your AI coding agent:
Install MCP server
telegramfollowing the steps at https://raw.githubusercontent.com/n24q02m/claude-plugins/main/plugins/better-telegram-mcp/setup-with-agent.md
Setup
Credentials are configured on the machine that runs the server.
Bot mode: set TELEGRAM_BOT_TOKEN in the client config, or save it once:
User mode: sign in interactively with your phone number. Telegram sends an OTP; a 2FA password is prompted if the account has one. The Telethon session is stored on disk.
Check the result with telegram status. The server reads saved credentials at
startup, so restart it after telegram auth. Without any credentials the
stdio server prints these instructions to stderr and exits with status 1.
Smithery
Also listed on Smithery.
Per smithery.yaml, Smithery starts the server over stdio with
uvx --python 3.13 n24q02m-telegram and takes no install-time configuration
(empty configSchema). Credentials come from the TELEGRAM_BOT_TOKEN env var or
a prior telegram auth (see Setup).
Configuration
Settings load from TELEGRAM_-prefixed environment variables (Pydantic Settings).
Env vars take precedence over credentials saved by telegram auth.
There is no TELEGRAM_PASSWORD env var: telegram auth prompts for the 2FA
password and never stores it in the environment.
HTTP mode
telegram --http serves MCP at /mcp and an unauthenticated GET /health.
Settings live in ~/.telegram/config.toml:
Create a token hash with telegram token hash (it reads the token from stdin
or a prompt, never from the command line). In multi mode, add users by
editing users.toml and restarting the server:
Then authorize Telegram for that user on the server machine:
To reach a server on another machine, put it behind a TLS-terminating reverse
proxy or a private network and use token or multi auth.
CLI
The telegram console script (installed by uvx / pip; better-telegram-mcp
is a legacy alias) starts the MCP server when run without a subcommand. Flags
that are not a subcommand are passed through to the server (for example
--http, --host, --port).
--user selects the storage namespace (default default, used by stdio and
the no-auth / token HTTP modes). Unknown subcommands exit with status 2.
Tools
MCP Resources
Comparison
How telegram stacks up against direct competitors in each pillar:
Security
- SSRF Protection -- All URLs validated against internal/private IP ranges, DNS rebinding blocked
- Path Traversal Prevention -- File paths validated, sensitive directories blocked
- Session File Security -- 600 permissions; the 2FA password is prompted, never stored in env vars
- Error Sanitization -- Credentials and bot tokens are never leaked in error messages or logs
- Prompt-injection boundaries -- Telegram content returned by tools is wrapped in untrusted-content tags
Build from Source
Trust Model
The project does not operate a hosted Telegram endpoint. The server runs on infrastructure you control, and credentials never leave that machine.
Anyone with access to your OS user account can read these files.
License
Apache-2.0 -- See LICENSE.
來源:README.md,提交 1942026
工具
0版本歷史
2- v4.23.0最新Oct 29, 2026
- v4.22.0Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分