
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 分