telegram-mcp
Allows to list chats, read message history, search messages (in a chat or globally), and send messages through your own Telegram account.
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-mcpsearch all my chats for 'invoice'"
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 Server
A local Model Context Protocol server that gives an AI agent — Claude Code, Claude Desktop, or any MCP client — controlled access to your own Telegram account: list chats, read history, search, and send messages, through Telegram's MTProto API.
Built with Python + Telethon. Runs entirely on your machine; your login session never leaves it.
Why
Telegram's Bot API can't see your existing chats — a bot is a separate identity and only receives messages explicitly sent to it. To let an agent work with your real conversations you need the MTProto client API, authenticated as your user account. This project wraps that in a small, focused MCP server so any MCP-capable agent can read and act on your Telegram — without you writing glue code each time.
Related MCP server: telegram-mcp
Features
6 tools covering the common read/write actions (see below)
Local-only — credentials and session live in a git-ignored
.env; nothing is sent anywhere except TelegramStandard MCP stdio server — works with Claude Code, Claude Desktop, or any MCP client
One-time login — interactive script stores a reusable session string; no re-auth on every run
Small and readable — ~150 lines of Python, easy to audit and extend
Tools
Tool | Description |
| Return the connected account (sanity check) |
| Your most recent conversations |
| Recent messages from one chat |
| Search within one chat |
| Search across all your chats at once |
| Send a message as you |
chat accepts a username (@name), numeric id, phone number, t.me link, or the chat's display name.
Quickstart
1. Install
git clone https://github.com/<you>/telegram-mcp.git
cd telegram-mcp
python -m venv .venv
# Windows
.venv\Scripts\pip install -r requirements.txt
# macOS / Linux
.venv/bin/pip install -r requirements.txt2. Get API credentials
Go to my.telegram.org → API development tools → create an app → copy the api_id and api_hash.
3. Log in (one time)
# Windows
.venv\Scripts\python login.py
# macOS / Linux
.venv/bin/python login.pyEnter your api_id/api_hash, phone number (with country code), and the login code Telegram sends you (plus your 2FA password if set). This writes a reusable session to .env.
4. Register with your MCP client
Claude Code:
claude mcp add telegram --scope user -- "/abs/path/.venv/bin/python" "/abs/path/server.py"Claude Desktop — add to claude_desktop_config.json:
{
"mcpServers": {
"telegram": {
"command": "/abs/path/.venv/bin/python",
"args": ["/abs/path/server.py"]
}
}
}Restart your client and the telegram tools are available.
Example
You: Search all my Telegram chats for "invoice" and summarize what's outstanding.
The agent calls search_all("invoice"), which returns:
[
{
"id": 84213,
"date": "2026-07-02T09:14:00+00:00",
"chat": "Acme Billing",
"from": "Acme Billing",
"text": "Invoice #204 is due on the 10th."
}
]…and the agent summarizes from there.
How it works
login.py authenticates once via Telethon and saves a StringSession to .env. server.py builds a FastMCP stdio server, connects lazily on the first tool call, verifies the session is authorized, and maps each tool to a Telethon call (iter_dialogs, iter_messages, SearchGlobalRequest, send_message). Results are returned as plain JSON-serializable dicts.
Security
Keep
.envprivate. TheSESSION_STRINGis equivalent to being logged in as you. It is git-ignored — never commit it.Everything runs locally; the server talks only to Telegram's servers.
Automating a user account is a Telegram ToS gray area. Reading your own account is generally fine; keep sending human-paced and avoid bulk/spam activity to stay clear of account limits.
Limitations
No automated test suite yet — verified manually against a live account.
search_messagessearches a single chat; usesearch_allfor a global search.Display-name resolution falls back to scanning your dialog list, so exact usernames/ids are faster and more reliable.
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.
Latest Blog Posts
- 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/Shaan-alpha/telegram-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server