Production-grade MCP server for Telegram — dual-mode Bot API + MTProto, domain-separated tools
Project description
Better Telegram MCP
mcp-name: io.github.n24q02m/better-telegram-mcp
MCP server for Telegram with dual-mode support: Bot API (httpx) for quick bot integrations and MTProto (Telethon) for full user-account access.
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 bot token for bot mode, or API credentials for user mode
- Web-based OTP auth -- Browser-based authentication with remote relay support for headless environments
- 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
Status
2026-05-02 -- Architecture stabilization update
Past months saw significant churn around credential handling and the daemon-bridge auto-spawn pattern. This caused multi-process races, browser tab spam, and inconsistent setup UX across plugins. As of v<auto>, the architecture is stable: 2 clean modes (stdio + HTTP), no daemon-bridge layer, no auto-spawn from stdio.
Apologies for the instability period. If you encountered issues with prior versions, please update to v<auto>+ and follow the current docs/setup-manual.md -- most prior workarounds are no longer needed.
Related plugins from the same author:
- wet-mcp -- Web search + content extraction
- mnemo-mcp -- Persistent AI memory
- imagine-mcp -- Image/video understanding + generation
- better-notion-mcp -- Notion API
- better-email-mcp -- Email management
- better-telegram-mcp -- Telegram
- better-godot-mcp -- Godot Engine
- better-code-review-graph -- Code review knowledge graph
All plugins share the same architecture -- install once, learn pattern transfers.
Setup
- Stdio mode (default) --
TELEGRAM_BOT_TOKENenv var, bot mode only. See setup-manual.md. - HTTP mode (encouraged) -- bot mode + user mode (MTProto via phone+OTP), browser-based setup with bundled api_id/hash. See setup-manual.md.
With AI Agent -- copy and send this to your AI agent:
Please set up better-telegram-mcp for me. Follow this guide: https://raw.githubusercontent.com/n24q02m/better-telegram-mcp/main/docs/setup-with-agent.md
Manual Setup -- follow docs/setup-manual.md
Tools
| Tool | Actions | Description |
|---|---|---|
message |
send, edit, delete, forward, pin, react, search, history |
Send, edit, delete, forward messages. Pin, react, search, browse history |
chat |
list, info, create, join, leave, members, admin, settings, topics |
List and manage chats, groups, channels. Members, admin, forum topics |
media |
send_photo, send_file, send_voice, send_video, download |
Send photos, files, voice notes, videos. Download media from messages |
contact |
list, search, add, block |
List, search, add contacts. Block/unblock users (user mode only) |
config |
status, set, cache_clear, setup_status, setup_start, setup_reset, setup_complete |
Server status, runtime settings, cache, credential setup (relay, status, reset, complete) |
help |
-- | Full documentation for any topic |
MCP Resources
| URI | Content |
|---|---|
telegram://docs/messages |
Message operations reference |
telegram://docs/chats |
Chat management reference |
telegram://docs/media |
Media send/download reference |
telegram://docs/contacts |
Contact management reference |
telegram://stats |
All documentation combined |
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, 2FA via web UI only (never stored in env vars)
- Error Sanitization -- Credentials never leaked in error messages
Build from Source
git clone https://github.com/n24q02m/better-telegram-mcp.git
cd better-telegram-mcp
uv sync
uv run better-telegram-mcp
Trust Model
This plugin implements TC-NearZK (in-memory, ephemeral). See mcp-core/docs/TRUST-MODEL.md for full classification.
| Mode | Storage | Encryption | Who can read your data? |
|---|---|---|---|
| HTTP n24q02m-hosted (default) | In-memory dict[sub] = MTProtoSession |
In-process only | Server process (cleared on restart) |
| HTTP self-host | Same as hosted | Same | Only you (admin = user) |
| stdio proxy | ~/.better-telegram-mcp/config.json |
AES-GCM, machine-bound key | Only your OS user (file perm 0600) |
License
MIT -- See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file better_telegram_mcp-4.9.0.tar.gz.
File metadata
- Download URL: better_telegram_mcp-4.9.0.tar.gz
- Upload date:
- Size: 197.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40132f3b7467278435b787074633e90fc0946a10b5b1871c8016f22112535fcf
|
|
| MD5 |
2b32d0411efe11fe4fb24ca9a9c9a83b
|
|
| BLAKE2b-256 |
cb55f23755d374857abb870e9e8c3843f720bbe0586a2232f20b728e0fe0a49b
|
File details
Details for the file better_telegram_mcp-4.9.0-py3-none-any.whl.
File metadata
- Download URL: better_telegram_mcp-4.9.0-py3-none-any.whl
- Upload date:
- Size: 63.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83ae38041616092692241c4b572795f6d59b754848a76f6465ca572fd3f4c61c
|
|
| MD5 |
1a276e83411573196582ef85f4bf2233
|
|
| BLAKE2b-256 |
39c208ad082badd269cf4d61a3b40fea2a883b9a6e1234a62178d3e933f78621
|