Telegram MCP
In the provided schema, this server lets you authenticate to Telegram and perform allowlisted read operations plus approval-gated plain-text sending.
Check login status and complete phone, code, and two-step password authentication.
Log out and destroy local Telegram session data, with confirmation.
Discover chats by metadata or list configured allowlisted chats and resolution errors.
Get allowlisted chat details such as type, username, member count, and description.
Read allowlisted chat history with pagination and optional date/message-id filters.
Search message text within one allowlisted chat or across all allowlisted chats.
Fetch a single message by id from an allowlisted chat.
Send plain-text messages to an allowlisted chat only after explicit user approval, optionally as a reply or silently.
Connects to a personal Telegram account via TDLib to read messages from an allowlist of chats, search message history, fetch chat and message details, and optionally send text messages after explicit user approval.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Telegram MCP search my Telegram chats for messages about the project deadline"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Telegram MCP
A local Model Context Protocol server that connects to your personal Telegram account through TDLib, Telegram's official client library. It is read-only by default, limited to an explicit allowlist of chats, with optional approval-gated sending of text, photos, and documents.
Every tool resolves its target and rejects anything outside the allowlist.
Sending is off unless enabled, and every message, photo, or document requires your explicit approval in an approval prompt. The AI agent cannot approve on your behalf.
No edit, delete, forward, join, leave, or reaction operations exist in the server.
The Telegram session, database, and config stay on your machine and are gitignored.
One shared daemon owns TDLib, so any number of MCP client sessions can use it at once.
Requirements
Node.js 20 or newer
A Telegram account
Telegram API credentials from my.telegram.org
Related MCP server: telegram-mcp
Setup
git clone https://github.com/aminkh17/telegrammcp.git
cd telegrammcp
npm install
npm run build
cp config.example.json config.jsonThen edit config.json and set apiId and apiHash.
API credentials
This project does not ship API credentials. Create your own application at
my.telegram.org → API development tools, then copy its api_id
and api_hash into config.json:
{
"apiId": 123456,
"apiHash": "your_api_hash_here"
}config.json is ignored by git and never leaves your machine.
Authentication
Authentication is done through MCP tools, so it works entirely from your MCP client:
auth_status— see what step is needed.auth_startwith your international phone number, e.g.+14155550123.auth_codewith the code Telegram sent.auth_passwordwith your two-step verification password, if enabled.
The session is persisted under data/tdlib, so this is a one-time flow. auth_logout destroys
the local session and cached Telegram data.
MCP client setup
OpenCode
Add the server to your global ~/.config/opencode/opencode.json:
{
"mcp": {
"telegram": {
"type": "local",
"command": ["node", "/absolute/path/to/telegrammcp/dist/index.js"],
"enabled": true
}
}
}Other MCP clients
Use the built entry point as a stdio server:
{
"mcpServers": {
"telegram": {
"command": "node",
"args": ["/absolute/path/to/telegrammcp/dist/index.js"]
}
}
}Tools
Tool | Purpose |
| Check login state and required step |
| Phone login flow |
| Destroy the local session (requires |
| List chat ids/titles (metadata only) to build the allowlist |
| Show resolved allowlist entries and errors |
| Chat details: type, username, member count, description |
| Read history, oldest first, with pagination |
| Search text in one or all allowlisted chats |
| Fetch one message by id |
| Send a plain-text message to an allowlisted chat, only after user approval |
| Send a local JPEG/PNG/WebP photo, only after user approval |
| Send a local file as a document, only after user approval |
Sending (approval required)
Sending is disabled by default. To enable it, set this in config.json:
{
"allowSending": true
}There are three send tools:
send_message— plain text, up to 4096 characters.send_photo— a local JPEG, PNG, or WebP photo, up to 10 MB.send_document— any local file, up tomaxUploadBytes(50 MB by default).
Every send works like this:
The server checks that sending is enabled and that the chat is allowlisted, then stores an exact short-lived draft. Text is stored as text. A file is copied into a private per-draft directory under
data/outbox, so the bytes you approve are the bytes sent even if the original file changes afterwards.The server asks you to approve it through an MCP approval prompt (form elicitation). The prompt shows the target chat and reply target, plus either the full text or the file name, size, MIME type, full path, and caption.
Only if you turn on Send this message, Send this photo, or Send this file and submit is that exact draft sent. Declining, cancelling, or ignoring the prompt for 10 minutes sends nothing.
The approval prompt comes from the server, not from the AI, so the agent cannot approve its own messages. If your MCP client does not support approval prompts, sending is refused.
Captions are optional and limited to 1024 characters. Sends can optionally reply to a message in
the same chat or be sent silently. Sending uses the same allowlist as reading. Photos must be
JPEG, PNG, or WebP, at most 10 MB (or maxUploadBytes if you set it lower). Documents may be any
type. Albums, voice notes, video, stickers, and polls are not supported.
Allowlist
Only chats listed in allowedChats can be read. Each entry accepts:
Form | Example |
Username |
|
Public link |
|
Numeric chat id |
|
Exact chat title |
|
Numeric ids and usernames are the most stable. If two chats share a title, resolution fails and asks for an id or username.
To find chats:
Keep
"allowChatDiscovery": true(default).Call
discover_chats, optionally with a query, to get ids and titles.Add the ids or usernames to
allowedChatsinconfig.json.Optionally set
"allowChatDiscovery": falseto make even chat metadata unavailable.
config.json is re-read on every tool call, so allowlist and limit changes apply immediately.
No restart is needed.
Discovery never returns message contents.
Configuration reference
config.json:
Key | Default | Meaning |
| unset | Telegram API credentials from my.telegram.org |
|
| Chats that may be read |
|
| Enable |
|
| Enable |
|
| Default page size |
|
| Upper bound for |
|
| Max characters per message text |
|
| Max size for documents, and for photos if lower than 10 MB |
|
| Idle time before the shared daemon exits |
|
| TDLib log verbosity (stderr) |
Environment overrides:
TELEGRAM_MCP_CONFIG— absolute path toconfig.jsonTELEGRAM_MCP_DATA_DIR— absolute path for the TDLib database and filesTELEGRAM_MCP_DEBUG=1— verbose MCP-level logging to stderr
Shared daemon
TDLib allows only one process to open a database at a time. MCP clients usually start one server
process per session, so every dist/index.js is a thin proxy: the first tool call starts a
detached dist/daemon.js that owns TDLib, and all sessions talk to it over data/daemon.sock.
The daemon starts automatically on demand. There is only ever one.
After
daemonIdleTimeoutSecondsof inactivity it closes TDLib, removes the socket, and exits. The next tool call starts a fresh daemon.config.jsonis reloaded per request. ChangingallowedChatsor limits takes effect immediately; changingapiId/apiHashrecreates the TDLib client on the next request.Daemon logs go to
data/daemon.log(rotated todata/daemon.log.oldat 5 MB).The socket is created with mode
0600.Staged uploads live under
data/outbox/<draft>/(directory mode0700, file mode0600). They are deleted when a draft is sent, declined, or expires, and the outbox is cleared when the daemon starts or stops. Leftovers from a crash are cleaned up after one hour.
Useful commands:
# Show daemon health and PID
curl --unix-socket data/daemon.sock http://localhost/health
# Run the daemon in the foreground for debugging
npm run daemon
# Stop it manually (it restarts on the next tool call)
pkill -f 'telegrammcp/dist/daemon.js'Security model
Reads only use TDLib
get*andsearch*methods. The only writes aresendMessagecalls for an approved text, photo, or document.The allowlist is enforced before any history, search, or send call.
Sending requires
allowSending: trueplus explicit user approval of each exact text, file, and caption. The approval prompt is issued by the server, not by the agent.Local files are staged as private copies. The prompt shows the canonical path, file name, size, and MIME type. The agent can request any file your user can read, so check the path before approving.
Chat discovery is metadata-only and can be disabled.
All logs go to stderr; stdout is reserved for MCP JSON-RPC.
Daemon RPC uses a Unix socket with mode
0600, so only your user can connect.API credentials, session data, and
config.jsonare gitignored; nothing sensitive is in the repo.
The MCP client (your AI agent) can read messages from allowlisted chats. That is the intended trust boundary. Do not allowlist chats you do not want an agent to read.
Approval is enforced on the MCP tool path. Any program running as your user, including an agent with unrestricted shell access, could still use your local Telegram session directly. If that matters, restrict shell access with your MCP client's permission settings.
Troubleshooting
"Telegram API credentials are not configured" — set
apiIdandapiHashinconfig.json.Daemon problems — check
data/daemon.log; delete a staledata/daemon.sockif no daemon is running.Signed out — call
auth_status, thenauth_startto log in again."Sending is disabled" — set
"allowSending": trueinconfig.json."This MCP client does not support approval prompts" — use a client that supports MCP form elicitation; sending is refused otherwise.
"is not a JPEG, PNG, or WebP image" —
send_photoonly accepts those formats; usesend_documentfor other files."the limit is ..." — photos are capped at 10 MB; documents at
maxUploadBytes."Cannot read ..." — the path is resolved against the MCP client's working directory. Use an absolute path if the file is elsewhere.
Reboots — nothing to do. The daemon starts again on the next tool call.
Limitations
Media is described, not downloaded. Message text and captions only.
Sending supports one plain-text message, one photo, or one document per call. No albums, voice notes, video, stickers, or polls.
Photo dimensions and aspect ratio are validated by Telegram, not locally, so an extreme photo may be rejected after approval.
Secret chats and email-only login are not supported.
Reading user accounts through unofficial automation is a grey area under Telegram's terms; this server is intentionally conservative: allowlisted reads and approval-gated, low-volume writes.
Each machine or separate
data/directory needs its own login and daemon.
License
Available Tools
12 toolsauth_codeSubmit Telegram login codeC
Submit the login code Telegram sent to the account.
Inputs: code (required).
auth_logoutLog out of TelegramADestructive
Log out and destroy all local Telegram session data. This requires network access and cannot be undone without logging in again.
Inputs: confirm (required).
auth_passwordSubmit Telegram two-step passwordA
Submit the two-step verification password, if the account has one enabled.
Inputs: password (required).
auth_startStart Telegram loginA
Start phone-number login. Telegram sends a login code to the account. After calling this, call auth_code with the code, and auth_password if two-step verification is enabled.
Inputs: phoneNumber (required).
auth_statusTelegram auth statusARead-only
Check whether the Telegram session is signed in and which login step is required. Start here if Telegram tools return an authentication error.
Inputs: no named parameters.
discover_chatsDiscover Telegram chatsARead-only
List chat ids and titles to help populate the allowlist. This returns metadata only, never message contents. Requires allowChatDiscovery in config.json. Pass a query to search, or omit it to list top chats.
Inputs: limit, query.
get_chatGet chat infoARead-only
Get details about one allowlisted chat: title, type, username, member count, and description.
Inputs: chat (required).
get_messageGet one messageARead-only
Fetch a single message by id from an allowlisted chat.
Inputs: chat (required), messageId (required).
get_messagesRead chat historyARead-only
Read recent messages from one allowlisted chat, oldest first. Paginate older messages by passing the previous nextBeforeMessageId as beforeMessageId.
Inputs: chat (required), limit, sinceDate, beforeMessageId.
list_allowed_chatsList allowlisted chatsBRead-only
List every chat in the allowlist, with ids, types, usernames, and any resolution errors.
Inputs: no named parameters.
search_messagesSearch messagesARead-only
Search messages by text inside one allowlisted chat, or across all allowlisted chats. Results are newest first.
Inputs: query (required), chat, limit.
send_messageSend message (requires user approval)A
Send a plain-text message to one allowlisted chat as the signed-in user. Requires allowSending in config.json. Every call shows the user an approval prompt with the exact chat and text; nothing is sent unless the user approves. Returns sent: false if the user declines. Do not retry a declined message unless the user asks.
Inputs: chat (required), text (required), replyToMessageId, disableNotification.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Each tool has a distinct purpose: authentication steps are sequential and clearly separated, chat tools cover discovery/listing/details, and message tools cover listing, searching, fetching one, and sending. There is little risk of confusing one tool for another.
All tool names use consistent snake_case with clear verb_noun or auth_* prefixes. The pattern is predictable across authentication, chat, and message operations.
Twelve tools is well-scoped for a Telegram MCP server, covering authentication, chat discovery, message reading, search, and sending without excessive surface area.
The server covers the core lifecycle: login/logout/status, chat discovery and allowlist inspection, message reading/searching, and sending. Minor gaps exist around message editing/deletion, replies, and media, but core workflows are supported.
Related MCP Connectors
Search, read and reply to your Telegram Business chats, transcribed voice included.
WhatsApp and Telegram for AI agents, behind a policy gateway. OAuth or access key.
Telegram automation for AI: read and search channel summaries, get digests, manage auto-publishing.
Your Telegram, WhatsApp, Instagram, mail and calendar in Claude or ChatGPT. Never sends messages.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to scoped, permissioned access to Telegram chats with per-chat read/write levels and human approval for sending messages.2MIT
- AlicenseNot gradedqualityCmaintenanceA read-only Telegram MCP server that only exposes a user-defined allowlist of chats, providing tools to list chats, fetch messages, search, and get context while stripping untrusted text and with no write capabilities.MIT
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients to read Telegram chat history and search messages only within an explicit fail-closed allowlist, with no write, edit, or delete operations.MIT
- AlicenseNot gradedqualityBmaintenanceA read-only server that lets any MCP client or model list, search, and read your own Telegram chats, including chat details, forum topics, message history, and surrounding context. It never sends, edits, or deletes anything, and stores your Telegram credentials encrypted at rest.MIT