telegram-mcp-server
Provides read-only, folder-scoped access to personal Telegram chats, allowing AI agents to list folders and chats, read recent messages, and search across allowed chats.
Click on "Deploy 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-mcp-serverlist the chats in my allowed folders"
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, read-only, folder-scoped MCP server that lets an AI agent (Claude Code, etc.) read your personal Telegram chats — but only the chats inside an allowlist of Telegram folders. No send/edit/delete capability exists.
Built for a common use case: let an agent read your client/lead conversations and pull out tasks, without giving it the keys to your whole Telegram.
⚠️ This logs in as your personal Telegram account via the official MTProto API (GramJS). Automating a user account is a grey area under Telegram's ToS; the risk is low for read-only use but not zero. Use on your own account.
How it stays safe
Read-only. The server registers four tools, all read-only. There is no tool that can send, edit, or delete anything.
Folder-scoped. Only chats inside the folders listed in
config.json(allowedFolders) are reachable. Every tool resolves the requested chat against that allowlist and refuses anything outside it. Chats in your other folders (family, personal, etc.) are physically unreachable.Secrets stay local.
api_id/api_hashlive inconfig.json(gitignored). The session string — which grants full account access — is stored in the macOS Keychain, never on disk, never in git.
Related MCP server: Telegram MCP Chigwell
Requirements
Bun (runs the TypeScript directly)
macOS (uses the Keychain via the
securityCLI for session storage)A Telegram account, and an
api_id/api_hashfrom https://my.telegram.org
Setup
# 1. install
bun install
# 2. configure
cp config.example.json config.json
# edit config.json: apiId, apiHash, allowedFolders (exact Telegram folder names)
# 3. log in (QR — the reliable method; see note below)
bun run qr
# On your phone: Telegram -> Settings -> Devices -> Link Desktop Device -> scan the QR
# 4. verify which folders/chats resolved
bun run folders
# 5. register with your MCP client (Claude Code example, user scope):
claude mcp add telegram -s user -- bun run "$(pwd)/src/server.ts"Why QR login, not the SMS/app code
bun run login (phone + code) often fails: Telegram frequently accepts the
SendCode request and reports "code sent to app", but never actually delivers
the code (and offers no SMS fallback) for third-party API logins — especially
with a freshly created api_id. bun run qr sidesteps this entirely: the
login is approved from your already-authorized phone, so no code delivery is
needed. Use QR first.
Tools
Tool | What it does |
| List allowed folders + resolved chat counts |
| List chats in allowed folders (optionally one folder) |
| Recent messages from one allowed chat |
| Search messages across allowed chats / one folder / one chat |
Troubleshooting
A folder shows 0 chats → its name in
config.jsondoesn't match Telegram exactly. Runbun run folders; if needed, temporarily inspect all folder titles (the diagnose output lists matched ones). Names are case-insensitive but must otherwise match (watch for typos / emoji / extra words).FLOOD_WAIT_N→ too many login attempts; wait N seconds. Don't spam retries — each one extends the window.CHANNEL_PRIVATEskipped → a private channel you've left/been removed from can't be resolved; it's skipped, harmless.Login code never arrives → use
bun run qr(see above).
Files
src/
server.ts MCP server (4 read-only tools)
client.ts GramJS client + folder allowlist (the privacy boundary)
qr-login.ts QR-code login (recommended)
login.ts phone+code login (fallback, with 'sms' resend)
config.ts loads config.json
keychain.ts session string <-> macOS Keychain
diagnose.ts 'bun run folders' — show allowed folders + counts
probe.ts 'bun run probe +NUMBER' — dump raw SendCode responseLicense
MIT
This server cannot be deployed
Maintenance
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
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
An MCP server that provides read access to your cloud storage providers, bank accounts and more.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceAn 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.MIT
- AlicenseNot gradedqualityAmaintenanceRead-only MCP server for Telegram that enables reading messages and transcribing voice, audio, and video notes via the Telegram API for use with Codex and Claude Code.Apache 2.0
- AlicenseNot gradedqualityAmaintenanceA safe-by-default MCP server for real Telegram accounts powered by TDLib, enabling AI agents to read and act on your account with read-only mode and human approval for destructive actions.7Apache 2.0
- AlicenseNot gradedqualityCmaintenanceA read-only Telegram MCP server that only exposes a user-defined allowlist of chats, providing tools to list chats, fetch messages, search, and get context while stripping untrusted text and with no write capabilities.MIT