Skip to main content

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.

CI codecov PyPI Docker License: MIT

Python Telegram MCP semantic-release Renovate

better-telegram-mcp MCP server

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

Setup

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

License

MIT -- See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

better_telegram_mcp-4.6.7.tar.gz (203.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

better_telegram_mcp-4.6.7-py3-none-any.whl (72.5 kB view details)

Uploaded Python 3

File details

Details for the file better_telegram_mcp-4.6.7.tar.gz.

File metadata

  • Download URL: better_telegram_mcp-4.6.7.tar.gz
  • Upload date:
  • Size: 203.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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

Hashes for better_telegram_mcp-4.6.7.tar.gz
Algorithm Hash digest
SHA256 9482e9b3e3a0da9fcbcad824c688807a461aa068462871868dc1dc8ed26d7b00
MD5 975ce7a404ab253b84d90dbaf383f868
BLAKE2b-256 b5f63d07d5226f77e848abf948e60f0db2abf7e0789f26df282d2e475edfac89

See more details on using hashes here.

File details

Details for the file better_telegram_mcp-4.6.7-py3-none-any.whl.

File metadata

  • Download URL: better_telegram_mcp-4.6.7-py3-none-any.whl
  • Upload date:
  • Size: 72.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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

Hashes for better_telegram_mcp-4.6.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ae99941d4d7f05c6dee1d17eeeb0e9d9c01630b8742b9da26ee2dbd8fe3213f6
MD5 c474731a8a2453c2a5e14ef0c32a4c5b
BLAKE2b-256 c41da8e7dbbe54ab89836e534ad6b59e320eeeb460f8a6099c996660e4f4b1ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page