SuperAPIAI Directory

mcp-telegram

github.com · AI coding

Telegram via MTProto: read chats, search messages, download media and manage contacts, with QR code login.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsmacOS · Linux · API

About this tool

  1. Purpose mcp-telegram is a server based on MCP (Model Context Protocol), used to connect AI assistants (such as Claude, ChatGPT, Cursor, or any MCP client) to Telegram. Unlike ordinary bots, it runs as a userbot under your personal Telegram account, is based on GramJS, and directly accesses the Telegram API through the MTProto protocol (rather than the feature-limited Bot API), so it can fully access your chats, contacts, and message history.

  2. Main Capabilities Comprehensive tool coverage: It is officially said to provide about 182 tools, making it one of the most fully featured Telegram MCP servers currently available. Messages and interactions: sending and receiving messages, reactions, polls, scheduled messages, stickers, media, contacts, etc. Forum Topics: list topics, read messages in each topic, send to a specified topic, and count unread messages by topic. Stickers: search sticker packs, browse installed/recently used stickers, and send stickers to any chat. Account and profile management: update profile, set emoji status, birthday, personal channel, profile photo, manage privacy settings, sessions, and auto-delete timers. Chat folders: create, edit, delete, and reorder folders, switch folder tabs, and read suggested folders (v1.33.0). Global privacy: read and set account-level privacy settings (v1.33.0). Global search: search messages across all chats at once. Real-time polling: fetch updates through stateless cursors; the agent itself holds the {pts, qts, date} state. Inline bots and buttons: query inline bots, send results, and press callback buttons. Stories: read peer stories, view story view statistics; publish/edit/delete stories, react, pin, stealth mode, archive, report (v1.30.0). Discussion groups: get discussion group information for channel posts with comments, and list groups that can participate in discussions (v1.30.0). Read receipts: see who has read a message in small groups and when your private messages were read (v1.30.0). Admin controls: toggle channel signatures, anti-spam, forum mode, and pre-history; approve join requests. Statistics: channel and supergroup analytics (GetBroadcastStats / GetMegagroupStats). Boost and Business: boost status, booster list, Telegram Business chat link CRUD, working hours, location, greeting/away/intro messages. Star gifts: browse available and saved gifts, save/convert gifts, manage Stars balance and subscriptions (requires opt-in via MCP_TELEGRAM_ENABLE_STARS=1, v1.34.0). Shared daemon: a single background process serves multiple MCP clients through a single Telegram session (v1.38.0). QR code login: complete authentication by scanning with the Telegram app. Session persistence: log in once, stay connected after restarts. Readable output: sender names are resolved instead of only showing numeric IDs. Compatible with any MCP client: Claude Code, Claude Desktop, ChatGPT, Cursor, VS Code, Mastra, etc.

  3. How to Use Prerequisites: Node.js 18 or higher; and Telegram API credentials from my.telegram.org (API_ID and API_HASH).

  4. Get Telegram API credentials

  • Visit my.telegram.org and log in with your phone number.
  • Go to API development tools.
  • Create a new app (name and platform can be anything).
  • Copy the App api_id and App api_hash.

Login: a QR code will appear in the terminal. Open Telegram on your phone, go to Settings > Devices > Link Desktop Device, and scan the QR code. The session is saved to ~/.mcp-telegram/session and reused automatically. You can customize the session path via TELEGRAM_SESSION_PATH=/path/to/session. If the account has two-step verification enabled (cloud password), scanning the QR code alone is not enough; you also need to provide the password via TELEGRAM_2FA_PASSWORD. This password is used only locally to answer Telegram's SRP challenge and is not persisted.

  1. Add to Claude: once done, you can have Claude run telegram-status to verify.

Multiple accounts: use TELEGRAM_SESSION_PATH to run multiple Telegram accounts in parallel, then add each as a separate MCP server; each account has its own session file, so they do not conflict with each other.

Multiple agents / concurrent clients (shared daemon): if one account needs to be driven simultaneously by multiple clients (multiple Claude Code windows, parallel sub-agents, or multiple IDEs), the regular approach will cause them to kick each other out due to AUTH_KEY_DUPLICATED. serve mode solves this: run a single persistent daemon that holds the sole Telegram connection, and other processes automatically discover the daemon via a PID lock and proxy tool calls through a local Unix socket. Each MCP client points to the same installation and uses the same TELEGRAM_SESSION_PATH (without the serve parameter), and will automatically connect to the daemon; closing any client will not disconnect the shared connection. Credentials only need to be provided by the daemon (owner); client commands can omit TELEGRAM_API_ID / TELEGRAM_API_HASH.

Network-restricted scenarios: if Telegram is blocked or you are running in a container environment (Docker, K3s), you can use SOCKS5 or MTProxy; if outbound port 443 is available but the default MTProto port 80 is not (some cloud providers block port 80 for Telegram DC ranges), you can connect via WSS (port 443).

Installation options

  • npx (recommended, zero install): no need to clone or install, just use npx @overpod/mcp-telegram directly.
  • Prebuilt binary (no runtime required): download a standalone single-file binary from Releases, with zero dependencies. Login requires running once in an interactive terminal (the session is persisted in ~/.mcp-telegram and reused automatically), after which you can run the MCP server.

Working with MCP clients

  • Claude Code (CLI).
  • Claude Desktop: the config file is ~/Library/Application Support/Claude/claude_desktop_config.json on macOS, and %APPDATA%\Claude\claude_desktop_config.j on Windowsson; restart after adding the Telegram server. You can have Claude run telegram-login, a QR code will appear (if the image is not visible it will also be saved to ~/.mcp-telegram/qr-login.png), scan it in Telegram (Settings > Devices > Link Desktop Device); then run telegram-status to verify. This method requires no terminal, and login is completed entirely through Claude Desktop.
  • Claude Desktop (binary): same configuration, but use a prebuilt binary instead of npx.
  • Claude Desktop (Docker): you must first log in in the terminal, then add the configuration and restart, and run telegram-status to verify.
  • Cursor / VS Code: add the same JSON configuration to the MCP settings (Cursor Settings > MCP, or VS Code MCP configuration). All tools are automatically discovered through MCP; after connecting, the AI client will see the full list with parameters and descriptions. You can ask the AI assistant "what Telegram tools are available" to get the full list.

Optional features: some tools are disabled by default and require opt-in via environment variables, which can be added to a .env file or the MCP client configuration.

Tech stack: TypeScript (ES2022, ESM modules), GramJS (telegram) MTProto client, @modelcontextprotocol/sdk (MCP server framework), Zod (runtime schema validation for tool parameters), Biome (linter and formatter), tsx (run TypeScript without a build step), dotenv (environment variable management).

IV. Use cases Suitable for scenarios that require directly operating a personal Telegram account within an AI client, such as searching messages across chats, reading and sending messages, managing contacts, handling media, viewing channel statistics, managing Business settings, publishing or managing Stories, etc., and can serve as a single Telegram connection shared by multiple clients.

V. Limitations and security

  • A session can only be used by one process at a time; if AUTH_KEY_DUPLICATED appears, it means another process is already using the same session file, and you need to create one for each environmentan independent session and set TELEGRAM_SESSION_PATH accordingly.
  • API credentials are stored in .env (already gitignored); the session is stored in ~/.mcp-telegram/session with permissions 0600 (accessible only by the owner), and the session directory permissions are 0700.
  • No phone number is required—QR authentication only; no data is sent to third-party services, and all communication goes directly to Telegram servers via MTProto; the QR login code is generated locally and never leaves your machine.
  • This is a userbot (personal account), not a bot, and you must comply with the Telegram Terms of Service.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools