telegram-mcp
Provides read-only access to a pre-approved allowlist of Telegram chats, with tools for listing chats, retrieving chat info, fetching messages, viewing message context, and searching messages across allowed chats.
Click on "Install 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-mcpshow the latest messages in the team chat"
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 — read-only Telegram MCP server with a per-chat allowlist
An MCP server that lets an assistant read only the chats you list by hand, and nothing else — no private conversations, no chats you forgot about, no writes at all.
Why another Telegram MCP server
Existing servers expose your whole account. A Telegram MTProto session sees every dialog, and none of the popular servers can narrow that down to a set of chats: in chigwell/telegram-mcp that is open issue #116. Read-only modes exist, but "read-only" there still means "read everything you have".
If you want an assistant in your work chats without handing it your family group, that gap is the whole point of this server:
This server | Typical Telegram MCP server | |
Chats reachable | only those in | every dialog of the account |
Write tools | none exist in the code | usually present, sometimes toggled off |
Untrusted text | control and zero-width characters stripped, length capped | as-is |
Tools exposed | 5 | 40–80 |
Related MCP server: telemcp
Security model
Closed list.
allowed_chats.jsonis the single source of truth. Anything not in it is denied — by id, by alias and by title.Denial happens before the network. Every handler asks the allowlist first, so a forbidden chat never becomes a Telegram request. There is a test that asserts exactly this over real stdio.
The answer is re-checked. After Telegram resolves an entity, its real id is matched against the allowlist again — a renamed or substituted chat cannot slip through.
No write path. There is no
send_messageto disable: the code does not contain one. All five tools are annotatedreadOnlyHint.Text is data, not instructions. Message texts, names and titles are sanitised (zero-width characters, bidi overrides, control characters) and truncated, and the tool descriptions tell the model to treat them as untrusted input.
The allowlist lives outside the installation. By default it is read from
~/.config/telegram-mcp/allowed_chats.json, so real chat ids never end up next to the code — which is what makes running straight from a git URL safe.
Tools
Tool | What it returns |
| the allowed chats with their current titles — start here |
| title, |
| latest messages, newest first, with paging via |
| messages around a given id, to reconstruct a thread |
| full-text search in one allowed chat or across all of them |
A chat is referenced by its alias (team), its exact title, or its id.
Requirements
Python 3.10+
uv (recommended — no clone or virtualenv needed)
A Telegram API application: https://my.telegram.org/apps →
api_idandapi_hash
Setup
1. Issue a session string
export TELEGRAM_API_ID=… TELEGRAM_API_HASH=…
uvx --from git+https://github.com/nskondratev/telegram-mcp telegram-mcp loginTelethon asks for your phone number, the login code and the 2FA password — you type them yourself, they are never stored. The command prints a session string.
⚠️ The session string grants full access to your Telegram account. Treat it like a password: never commit it, never paste it into a chat. It lives in your MCP client config (for Claude Code,
~/.claude.json), which is not in git.
2. Build the allowlist
export TELEGRAM_SESSION_STRING=…
uvx --from git+https://github.com/nskondratev/telegram-mcp telegram-mcp dialogs --filter acmeThe output is id kind title per dialog. Put the ones you want into
~/.config/telegram-mcp/allowed_chats.json, using allowed_chats.example.json
as the template:
{
"chats": [
{ "alias": "team", "id": -1001111111111, "title": "Team chat", "note": "main work chat" },
{ "alias": "alerts", "id": -1002222222222, "title": "Alerts", "note": "monitoring" }
]
}Field | Required | Meaning |
| yes | chat id as printed by |
| no | short latin handle used by the tools; defaults to the id |
| no | human-readable name; also accepted as a chat reference |
| no | free-form note, returned by |
Duplicate aliases or ids are a startup error, not a warning. dialogs --json prints a
ready-made skeleton you can edit.
3. Connect the server
Claude Code:
claude mcp add telegram -s user \
-e TELEGRAM_API_ID=… \
-e TELEGRAM_API_HASH=… \
-e TELEGRAM_SESSION_STRING=… \
-e TG_ALLOWED_CHATS_FILE=$HOME/.config/telegram-mcp/allowed_chats.json \
-- uvx --from git+https://github.com/nskondratev/telegram-mcp telegram-mcp serveAny MCP client works — the transport is stdio. The equivalent JSON:
{
"mcpServers": {
"telegram": {
"command": "uvx",
"args": [
"--from", "git+https://github.com/nskondratev/telegram-mcp",
"telegram-mcp", "serve"
],
"env": {
"TELEGRAM_API_ID": "…",
"TELEGRAM_API_HASH": "…",
"TELEGRAM_SESSION_STRING": "…",
"TG_ALLOWED_CHATS_FILE": "/home/you/.config/telegram-mcp/allowed_chats.json"
}
}
}
}4. Verify
uvx --from git+https://github.com/nskondratev/telegram-mcp telegram-mcp checkcheck reads every allowed chat and then tries a chat that is not on the list, so a
broken allowlist shows up here rather than mid-conversation.
Configuration
Variable | Meaning |
| credentials from https://my.telegram.org/apps |
| Telethon |
| path to the allowlist; default |
Every command also accepts --allowlist PATH. Editing the allowlist takes effect when the
MCP client restarts the server.
For convenience, login, dialogs and check fall back to the env block of a Telegram
MCP server in ~/.claude.json when the variables are not exported — so they keep working
right after the server is wired into Claude Code.
Development
git clone https://github.com/nskondratev/telegram-mcp
cd telegram-mcp
uv run --extra dev pytest # 54 tests, no account or network required
uv run --extra dev ruff check .The tests replace Telethon with a fake, so the allowlist logic, the sanitiser and the
refusal path are all covered offline. tests/test_server_integration.py additionally
starts the real server over stdio and asserts that a forbidden chat is rejected before
any Telegram credentials are even looked at.
Layout: core.py — allowlist and sanitising; handlers.py — the five read operations;
client.py — a Telethon wrapper that warms the dialog cache; server.py — MCP tool
definitions; cli.py — serve / login / dialogs / check.
The installable distribution is named telegram-allowlist-mcp; the import package and the
command are both telegram_mcp / telegram-mcp.
License
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityCmaintenanceA read-only MCP server that lets AI agents read personal Telegram chats from an allowlist of folders, with no send/edit/delete capability.Last updated40MIT
- Alicense-qualityAmaintenanceAn MCP server that gives AI assistants read-only access to your personal Telegram account via MTProto, enforcing a whitelist of allowed chats and never marking messages as read.Last updatedMIT
- Flicense-qualityBmaintenanceRead-only MCP server for self-hosted Telegram access via Telethon. Enables reading messages, chats, and media but disallows any write operations.Last updated
- Alicense-qualityBmaintenanceAn MCP server that connects to Telegram as your real user account and exposes read-only tools to read and search messages, list chats and folders, inspect group info, and download media.Last updated24MIT
Related MCP Connectors
Telegram bridge for your MCP-compatible agent. Bidirectional, no LLM in our stack.
Search your AI chat history (ChatGPT, Claude, Codex) from any MCP client. Remote, private, read-only
Read-only MCP server for Robinhood Chain token discovery, research, and due diligence via GMGN.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/nskondratev/telegram-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server