telegram-mcp
Allows controlling your Telegram user account to send, read, search, and manage messages, chats, and files, including direct messages and group 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-mcpsend 'Hello' to @john_doe"
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.
This MCP server logs in as your own Telegram account, over Telegram's native MTProto protocol (via GramJS). Acting as your user account, it can read and search your full history, message anyone, join chats, and manage your account — all driven from any MCP client.
It speaks the Model Context Protocol over stdio, so it plugs into Claude Desktop, Claude Code, or any MCP-compatible client, exposing 44 tools across seven domains.
This automates areal user account. Your session string grants full access to that account, and spammy or bulk automation can get it banned. Keep tool actions deliberate and user-initiated.
Features
User-account access — read and search your full history, and message anyone.
44 tools, 7 domains — account, users, messages, files, chats, groups, contacts.
Read/write permission hints — every tool is annotated
readorwrite(MCPreadOnlyHint), so clients can auto-approve reads and gate writes.Login once — an interactive login saves a portable session to a gitignored file; the server reuses it forever. No password or session ever touches your MCP config.
Safe by construction — returned text is sanitized against prompt injection, and results are compact JSON (never raw, circular GramJS objects).
Related MCP server: mcp-telegram
Requirements
Node.js 22.14 or newer
A Telegram account and API credentials (
api_id+api_hash) from my.telegram.org/apps
Getting started
1. Install and build
npm install
npm run build2. Configure credentials
Copy the example env file and fill it in:
cp .env.example .envVariable | Required | Description |
| yes | App |
| yes | App |
| no | Directory for the session file ( |
3. Log in
Run the interactive login once. It prompts for your phone number, the code Telegram sends you, and your two-factor password (if set):
npm run loginIt saves the session to .telegram-session (in SESSION_PATH, or the project root by default) with owner-only 0600 permissions. The server reads it automatically on every start — you never log in again and never paste the session into any config.
npm run login needs an interactive terminal. If your shell isn't a real TTY, run the built script directly: node dist/ops/login.js.
4. Connect an MCP client
Point your client at the built server. Example .mcp.json:
{
"mcpServers": {
"telegram": {
"type": "stdio",
"command": "node",
"args": ["/absolute/path/to/telegram-mcp/dist/server.js"],
"env": {
"TELEGRAM_API_ID": "1234567",
"TELEGRAM_API_HASH": "0123456789abcdef0123456789abcdef"
}
}
}
}That's it — ask your client to list your chats, search a conversation, or send a message.
AddSESSION_PATH to env only if you saved the session outside the project root; otherwise the server finds .telegram-session there by default.
Tools
All 44 tools live in src/tools/, one file per domain. Each is either a read (safe to auto-approve) or a write (mutates your account — gate it).
Domain | Tools |
account — your own account |
|
users — look up others |
|
messages |
|
files — media in/out |
|
chats — your chat list |
|
groups — group/channel management |
|
contacts — address book & blocking |
|
Chat targets accept an@username, a numeric id, a string id, or 'me' (your Saved Messages). Prefer @username — numeric ids resolve reliably only after the entity has been seen this session (e.g. via list_dialogs).
How it works
flowchart LR
client(["MCP client<br/>Claude Desktop / Code"])
client -- "request · stdio / JSON-RPC" --> server["server.ts"]
server --> handler["tool handler"]
handler -- "getClient()" --> gramjs["GramJS · MTProto<br/>→ Telegram"]
gramjs -- "raw result" --> shape["serialize + sanitize"]
shape -- "compact, safe JSON" --> clientserver.tsregisters every tool and connects aStdioServerTransport.lib/client.tslazily creates one shared, authenticated GramJS client on the first tool call and reuses it for the process lifetime (keeping the entity cache warm).Tool prose lives in YAML. Each tool's description and field docs are in
src/prompts/*.yml(loaded via promptoro); the TypeScript holds only types and logic.Every result is mapped through
serialize.ts(compact, BigInt-safe) andsanitize.ts(strips control/zero-width characters as a prompt-injection defense) — raw GramJS objects are never returned.
Security & safety
.envand.telegram-sessionare gitignored. The session string is full access to your account — never commit, log, or share it.The login script writes the session file with
0600(owner read/write only).Tools are annotated
readvswriteso your MCP client can auto-approve harmless reads while prompting for anything that changes your account.
Development
npm run build # tsc -p . → dist/ (also copies prompt YAML)
npm start # run dist/server.js (needs a valid .env)
npm run login # regenerate the session stringAdding a tool: define it in the file for its group under src/tools/, add the matching src/prompts/<name>.yml, register it in src/server.ts, and rebuild. See CLAUDE.md for the full conventions.
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-qualityBmaintenanceEnables AI agents to interact with Telegram accounts through MCP, supporting messaging, contacts, groups, media, and admin functions.Last updated4Apache 2.0
- AlicenseBqualityBmaintenanceA Telegram MCP server that connects agents to a real Telegram user account via MTProto, enabling reading, searching, sending, moderating, and managing Telegram chats through natural language or automated tool calls.Last updated1008828MIT
- Alicense-qualityCmaintenanceConnects AI tools to Telegram via MCP, enabling reading chats, sending messages, managing groups, and more using your own account.Last updated5MIT
- Alicense-qualityCmaintenanceEnables AI assistants to interact with Telegram accounts, chats, messages, media, and more via MCP, using Telethon.Last updatedApache 2.0
Related MCP Connectors
Telegram bridge for your MCP-compatible agent. Bidirectional, no LLM in our stack.
Give AI agents real phone numbers, messages, and voice calls via MCP.
Multi-tenant Telegram gateway for AI agents — HTTP+stdio, 8 tools, MTProto User API
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/naim30/telegram-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server