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.
telegram-mcp
Drive Telegram as your own account from any MCP client — not a bot.
An MCP server that connects an AI agent to Telegram through your real user account over MTProto (via GramJS), authenticated with a saved session string. Because it acts as you and not a bot, it can read and search chat history and message anyone — things the Bot API cannot do.
It exposes 11 focused tools over stdio for sending, reading, searching, and managing messages, chats, and files.
Features
You, not a bot — message people who never contacted you and post to any chat you belong to.
Read & search history — pull recent messages or full-text search a conversation.
Send anything — text with Markdown/HTML, replies, files by local path or URL.
Manage messages — edit, delete (for everyone or just you), and forward across chats.
Discover chats — list your dialogs with unread counts and resolve
@username→ id.Safe by default — returned content is sanitized against prompt injection; the client stays silent on stdout so it never corrupts the protocol stream.
Related MCP server: mcp-telegram
Prerequisites
Node.js ≥ 22.14
A Telegram account
An
api_idandapi_hashfrom my.telegram.org/apps (these identify the app, not your account)
Installation
git clone https://github.com/naim30/telegram-mcp.git
cd telegram-mcp
npm install
npm run buildConfiguration
Copy the example environment file and add your app credentials:
cp .env.example .envVariable | Required | Description |
| yes | App |
| yes | App |
| yes* | Session string for your account (generated below) |
| no | Fallback chat ( |
*Set TELEGRAM_SESSION after running the login step below.
Login
Generate a session string once. The script prompts for your phone number, the login code Telegram sends you, and your two-factor password if you have one:
npm run loginCopy the printed string into .env as TELEGRAM_SESSION=.... That's it — the session is reused on every start, so you never log in again.
The session string grantsfull access to your account. Never commit it or share it. .env is already gitignored.
Connect to 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",
"TELEGRAM_SESSION": "1BQANOTEuMTA...",
"TELEGRAM_DEFAULT_CHAT": "me"
}
}
}
}Values in env override .env. The server connects to Telegram lazily on the first tool call and reuses one authorized client for its lifetime.
Tools
Tool | Description |
| Your account profile — doubles as a connectivity/auth check |
| List your chats (DMs, groups, channels) with unread counts and last message |
| Look up a user/group/channel by |
| Read a chat's recent history, newest first, with pagination |
| Full-text search a single chat's history |
| Send a text message (Markdown/HTML, replies, silent) |
| Edit a message you previously sent |
| Delete messages for everyone or just your local copy |
| Forward messages from one chat to another |
| Clear a chat's unread counter |
| Send a photo or document by local path or URL |
Thechat argument accepts a @username, a numeric id, a string id, or me (your Saved Messages). Numeric ids resolve reliably only after the entity has been seen this session — run list_dialogs first to warm the cache, or prefer @username.
How it works
MCP client ──stdio──▶ server.ts ──▶ tool handler ──▶ GramJS client ──▶ Telegram (MTProto)
│
└─▶ serialize + sanitize ──▶ JSON resultsrc/
server.ts Registers all tools, connects the stdio transport
login.ts `npm run login` — interactive session-string generator
config/config.ts Typed environment config (envalid + dotenv)
lib/
client.ts Lazy, authorized GramJS client
register-tool.ts Wraps each tool: JSON output, errors → isError
sanitize.ts Strips control/zero-width characters from returned text
serialize.ts Compact, BigInt-safe summaries of GramJS objects
fields.ts Shared zod input fields
tools/ account · messages · files (one object per tool)Scripts
npm run build # Compile TypeScript to dist/
npm run login # Generate a session string
npm start # Run the server (needs a valid .env)This automates auser account. Bulk or spammy behavior can get your account limited or banned by Telegram. Keep actions deliberate and user-initiated.
Acknowledgements
Built on GramJS and the Model Context Protocol SDK. The content-sanitization approach is adapted from the Telethon-based chigwell/telegram-mcp.
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/naim30/telegram-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server