Telegram MCP

io.github.n24q02mPublished by GitHub account n24q02mv4.23.0Updated Oct 29, 2026

Telegram for AI agents: messages, chats, media, and contacts in bot and user-account modes.

Overview

AI-generated overview

Telegram MCP server that lets an AI assistant send and manage messages, chats, media and contacts via a bot token or a user account.

What you can do
  • Send, edit, delete, forward, pin, react to, search and browse message history
  • List, create, join, leave and administer chats, groups and channels, including members and forum topics
  • Send photos, files, voice notes and videos, and download media from messages
  • List, search and add contacts, and block or unblock users in user mode
  • Read server status, adjust runtime settings and clear cache, plus built-in help and documentation resources
When to use it
Useful when an assistant should work inside Telegram: drafting and sending messages, triaging chats and channels, forwarding or pinning content, or pulling media and history into a workflow. Bot mode suits channel and group automation; user-account mode is needed for acting as a person, including contact blocking.
Requirements
Runs locally over stdio via uvx (Python package n24q02m-telegram) or Docker. Bot mode needs TELEGRAM_BOT_TOKEN; user mode needs a phone number plus OTP and optional 2FA, with TELEGRAM_API_ID and TELEGRAM_API_HASH optionally overriding a bundled API pair. Credentials can be saved with the telegram auth command or supplied by environment variable. Optional HTTP mode with bearer-token auth.
Before you install
The server acts on a real Telegram account: tools can send, edit, delete, forward, pin and react to messages, create or leave chats, and block users, so mistakes are visible to other people. User mode stores a Telethon session and credentials on disk, readable by anyone with access to the OS account. Treat TELEGRAM_BOT_TOKEN and TELEGRAM_API_HASH as secrets. HTTP mode without auth is loopback-only; exposing it elsewhere needs a TLS proxy and token auth.

Installation

In SourceWeft

  1. Open Telegram MCP in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

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)
ProjectTaglineTag
agent-chat-pluginPeer AI agents chat in a shared folder — no human relay, no orchestrator, wor...Tooling
better-code-review-graphKnowledge graph for token-efficient code reviews -- semantic search and call-...MCP
better-drive2-way Google Drive sync with .driveignore filter — rclone engine, Windows trayTooling
better-email-mcpIMAP/SMTP email for AI agents -- read, send, organize folders, and manage att...MCP
better-godot-mcpComposite MCP server for Godot Engine -- 17 composite tools for AI-assisted g...MCP
better-notion-mcpMarkdown-first Notion for AI agents -- pages, databases, blocks, and comments...MCP
better-semantic-releaseDrop-in python-semantic-release fork with built-in release-safety guards (orp...Tooling
better-telegram-mcpTelegram for AI agents -- messages, chats, media, and contacts across both bo...MCP
better-workspace-mcpGoogle Workspace MCP server (Docs/Drive/Calendar/Gmail/Sheets/Slides/Tasks/Ch...MCP
claude-pluginsClaude Code plugin marketplace for the n24q02m MCP servers -- install web sea...Marketplace
imagine-mcpImage and video understanding + generation for AI agents -- across Gemini, Op...MCP
jules-task-archiverChrome Extension for bulk operations on Jules tasks via batchexecute API -- a...Tooling
mcp-coreShared foundation for building MCP servers -- Streamable HTTP transport, OAut...MCP
mnemo-mcpPersistent AI memory with hybrid search and embedded sync. Open, free, unlimi...MCP
qwen3-embedLightweight Qwen3 text embedding and reranking via ONNX Runtime and GGUFLibrary
skretSecrets without the server.CLI
tacetA self-distilling neuro-symbolic cascade that amortises LLM cost across knowl...Tooling
web-coreShared web infrastructure package for search, scraping, HTTP security, and st...Library
wet-mcpOpen-source MCP server for AI agents: web search, content extraction, and lib...MCP

Table of contents

[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 a bot token for bot mode, or a phone number for user mode
  • Local CLI auth -- telegram auth handles 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

bash
# Claude Code plugin (stdio, bot mode)/plugin marketplace add n24q02m/claude-plugins/plugin install better-telegram-mcp@n24q02m-plugins
# Direct uvx invocation (stdio, bot mode)claude mcp add telegram -e TELEGRAM_BOT_TOKEN=123456:ABC-DEF -- uvx n24q02m-telegram
# Docker stdiodocker run -i --rm -e TELEGRAM_BOT_TOKEN=123456:ABC-DEF n24q02m/telegram

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

ClientInstall
Claude Code/plugin marketplace add n24q02m/claude-plugins + /plugin install better-telegram-mcp@n24q02m-plugins (stdio bot mode), or claude mcp add as in the block above
Cursor / Windsurf / Gemini CLI / any MCP clientmcpServers JSON in the client's config: stdio command, or type: "http" + url pointing at a server you run (see HTTP mode)

Install with AI agent -- paste this to your AI coding agent:

Install MCP server telegram following 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:

bash
telegram auth --bot-token 123456:ABC-DEF

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.

bash
telegram auth --phone +15551234567

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.

VariableRequiredDescription
TELEGRAM_BOT_TOKENBot modeBot token from @BotFather (format 123456789:ABCdef...)
TELEGRAM_PHONEUser modePhone number in +<country><number> form
TELEGRAM_API_ID / TELEGRAM_API_HASHNoOverride the bundled public API pair
USE_BUNDLED_TELEGRAM_CLIENTNoSet to false to require your own API pair
TELEGRAM_SESSION_NAMENoTelethon session file name (default default)
TELEGRAM_DATA_DIRNoSession directory (default ~/.telegram)
MCP_TRANSPORTNoSet to http to start in HTTP mode (--http or TRANSPORT_MODE=http also work)

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:

toml
[server]host = "127.0.0.1"   # default; --host overridesport = 8000          # default; --port overridesauth = "token"       # "no-auth" | "token" | "multi"token_hash = "scrypt$..."
authWho can connectCredentials used
no-authAnyone who can reach the port; loopback binds only (a non-loopback host is refused)The default credentials
tokenClients sending Authorization: Bearer <token> matching token_hashThe default credentials
multiUsers listed in users.toml (default ~/.telegram/users.toml), each with their own tokenEach user's own namespace

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:

toml
[users.alice]token_hash = "scrypt$..."enabled = truenamespace = "alice"

Then authorize Telegram for that user on the server machine:

bash
telegram auth --phone +15551234567 --user alice

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).

bash
telegram            # start the MCP server (stdio)telegram --http     # start in HTTP modetelegram --version  # print the version
SubcommandUsageDescription
authauth --bot-token <token> or auth --phone <+number>, optional --user <ns>Authorize this machine. Bot mode validates the token; phone mode runs the interactive OTP/2FA flow and stores the Telethon session on disk
loginSame arguments as authDeprecated alias of auth
logoutlogout [--yes] [--user <ns>]Revoke the Telegram session, delete the session file and the saved credentials
configconfig status, config delete --yesShow or delete the saved credential config
statusstatusShow whether credentials are configured
doctordoctorPrint environment diagnostics
tokentoken hashHash a bearer token for config.toml / users.toml

--user selects the storage namespace (default default, used by stdio and the no-auth / token HTTP modes). Unknown subcommands exit with status 2.

Tools

ToolActionsDescription
messagesend, edit, delete, forward, pin, react, search, historySend, edit, delete, forward messages. Pin, react, search, browse history
chatlist, info, create, join, leave, members, admin, settings, topicsList and manage chats, groups, channels. Members, admin, forum topics
mediasend_photo, send_file, send_voice, send_video, downloadSend photos, files, voice notes, videos. Download media from messages
contactlist, search, add, blockList, search, add contacts. Block/unblock users (user mode only)
configstatus, set, cache_clearServer status, runtime settings (message_limit, timeout), cache
help--Full documentation for any topic

MCP Resources

URIContent
telegram://docs/messagesMessage operations reference
telegram://docs/chatsChat management reference
telegram://docs/mediaMedia send/download reference
telegram://docs/contactsContact management reference
telegram://statsAll documentation combined

Comparison

How telegram stacks up against direct competitors in each pillar:

Capabilitytelegramchigwell/telegram-mcpsparfenyuk/mcp-telegramguangxiangdebizi/telegram-mcp
Bot API mode (bot token)Yes (httpx)NoNoYes
MTProto user-account modeYes (Telethon)YesYesNo
Send / edit / delete messagesYesYesNo (read-only, draft only)Yes (send only)
Media download from messagesYesYesYesNo (send only)
Contact management (add / block)Yes (user mode)YesPartial (list only)No
Multi-user HTTP, per-user isolationYes (per-user tokens and namespaces)NoNoNo
SSRF protectionYes (URL validation + DNS-rebinding)??No
Path-traversal preventionYesYes (real-path allowed-root)?No
Self-hostableYesYesYesYes

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

bash
git clone https://github.com/n24q02m/telegram.gitcd telegramuv syncuv run telegram

Trust Model

The project does not operate a hosted Telegram endpoint. The server runs on infrastructure you control, and credentials never leave that machine.

DataLocationProtection
Saved credentials (bot token / phone)~/.telegram/config.json; ~/.telegram/subs/<ns>/config.json in multi modeAES-256-GCM with the machine key ~/.telegram/.secret
Telethon sessions~/.telegram/<name>.session; ~/.telegram/subs/<ns>/ in multi modeFile permission 0600
HTTP bearer tokenstoken_hash in config.toml / users.tomlStored only as scrypt hashes

Anyone with access to your OS user account can read these files.

License

Apache-2.0 -- See LICENSE.

Source: README.md at commit 1942026

Tools

0
SourceWeft started this package once in an isolated sandbox, without credentials, to list its tools. That failed: the package did not install.

Version history

2
  1. v4.23.0LatestOct 29, 2026
  2. v4.22.0Sep 16, 2026

Score

50% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts

    Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.

  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listed15 pts

    Answer tools/list without a credential, or ship a package that starts in a sandbox without one.

  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts