Are you the author? Sign in to claim
Local MCP server that connects Claude to your personal Telegram account via MTProto. Web panel, QR & phone login, 11 too
A local MCP (Model Context Protocol) server that connects Claude to your personal Telegram account using MTProto — the same encrypted protocol used by Telegram's own apps.
Claude gets 11 tools and 4 resources to read messages, search chats, send replies, forward files, and more — all through your real Telegram account, not a bot.
npx mcp-telegram-local
Most Telegram integrations use the Bot API, which requires a separate bot account and can't access your personal chats. This server uses MTProto (via gramjs) to log in as you — the same way the official Telegram desktop app works. Claude sees exactly what you see: all your chats, groups, channels, contacts, and message history.
api_id, api_hash, and session file live only on your computer at ~/.mcp-telegram/ with 600 permissions (owner read/write only). Nothing is sent to Anthropic, npm, or any third party — only to Telegram's own servers.npx mcp-telegram-local serve as a local process on your machine. The MCP communication happens over stdio — no network port is opened, no data leaves your computer.~/.mcp-telegram/session.json private. To revoke it, run npx mcp-telegram-local logout — this signs the session out on Telegram's side and deletes the local file.api_id and api_hash from my.telegram.org — free, takes 2 minutes (see below)npx mcp-telegram-local ui
This opens a local web page at http://127.0.0.1:8765 (only accessible from your computer). From there you can:
api_id and api_hashAfter adding to Claude Code, restart Claude Code and type /mcp — you should see telegram listed as a connected server.
npx mcp-telegram-local auth
Walks you through login interactively in the terminal (phone number or QR code printed as ASCII art), then automatically registers the server in Claude Code.
You need these once. They identify your app to Telegram and are stored locally.
MyApp / myapp) — the values don't matterapi_id (a number) and api_hash (a long hex string)Paste them into the web panel or terminal when prompted. They're saved to ~/.mcp-telegram/config.json and never needed again.
npx mcp-telegram-local # Show this command list
npx mcp-telegram-local ui # ⭐ Open the web control panel
npx mcp-telegram-local auth # Log in via terminal + auto-add to Claude Code
npx mcp-telegram-local status # Check if your session is valid
npx mcp-telegram-local add_mcp # Register server in Claude Code (no re-login)
npx mcp-telegram-local logout # Sign out of Telegram + delete local session
npx mcp-telegram-local delete_key # Delete api_id/api_hash + sign out (full reset)
npx mcp-telegram-local config # Print the Claude Code config JSON snippet
npx mcp-telegram-local serve # Force MCP server mode on stdio (used by Claude)
npx mcp-telegram-local help # Show help
Once registered, Claude Code automatically starts npx mcp-telegram-local serve as a background process whenever it needs Telegram access. The server communicates over stdio (standard input/output) using the MCP protocol — no web server, no open ports, no background daemon to manage. It starts on demand and exits when Claude is done.
The config Claude Code stores looks like this:
{
"mcpServers": {
"telegram": {
"command": "npx",
"args": ["mcp-telegram-local", "serve"]
}
}
}
You can also add it manually by running:
claude mcp add --scope user telegram -- npx mcp-telegram-local serve
| Tool | Parameters | What it does |
|---|---|---|
get_dialogs | limit, offset | List your chats and channels |
get_messages | chat_id, limit | Fetch message history from a chat |
search_messages | query, chat_id?, limit | Search messages globally or in a specific chat |
get_unread | max_chats, max_messages_per_chat | Fetch all unread messages across chats |
send_message | chat_id, text | Send a text message |
reply_to_message | chat_id, message_id, text | Reply to a specific message |
forward_message | from_chat, to_chat, message_id | Forward a message between chats |
download_file | chat_id, message_id, include_base64? | Download a file or photo from a message |
send_file | chat_id, file_path, caption? | Send a file from your computer |
get_contacts | — | List your Telegram contacts |
get_chat_members | chat_id, limit | List members of a group or channel |
chat_idaccepts a numeric ID,@username, or at.me/...link.
| URI | Description |
|---|---|
telegram://dialogs | All your dialogs/chats |
telegram://chat/{id} | A specific chat with recent messages |
telegram://unread | All unread messages |
telegram://me | Your Telegram profile |
Once connected, just describe what you want in plain English:
All data is stored locally with restrictive file permissions:
~/.mcp-telegram/
├── config.json # api_id and api_hash
├── session.json # gramjs session string (equivalent to a Telegram login)
└── downloads/ # files downloaded via the download_file tool
To fully reset everything:
npx mcp-telegram-local delete_key
This revokes the session on Telegram's servers, deletes session.json, and deletes config.json. You'll start fresh next time.
To only sign out (keep api credentials):
npx mcp-telegram-local logout
After logout, go to Telegram → Settings → Devices if you want to confirm the session was removed there too.
npx mcp-telegram-local auth again.git clone https://github.com/pokkop/mcp-telegram-local
cd mcp-telegram-local
npm install
npm run build # compile TypeScript → dist/
npm run dev # watch mode
node dist/index.js status
Source layout:
src/
├── index.ts # entry point: CLI commands + MCP server on stdio
├── auth.ts # terminal login (phone + QR), MTProto/privacy banner
├── web.ts # local web panel HTTP server + gramjs login bridge
├── web-page.ts # full SPA (HTML/CSS/JS) served by web.ts
├── client.ts # TelegramClient wrapper, JSON serializers, logout
├── tools.ts # all 11 MCP tools
├── resources.ts # all 4 MCP resources
├── storage.ts # ~/.mcp-telegram/ read/write helpers
├── claude.ts # auto-registration with Claude Code
├── notice.ts # English MTProto/privacy notices for terminal output
└── suppress-warnings.ts # suppresses gramjs's Node.js localStorage warning
TypeScript compiles to ESM ("type": "module") targeting Node 18+. gramjs logging is fully silenced (LogLevel.NONE) to prevent any stray output from corrupting the MCP stdio stream.
MIT
Run Claude Code as an MCP server so any agent can delegate coding tasks to it
Browser automation using accessibility snapshots instead of screenshots
Google's universal MCP server supporting PostgreSQL, MySQL, MongoDB, Redis, and 10+ databases
Official GitHub integration for repos, issues, PRs, and CI/CD workflows