tgmcp
Automates one Telegram user account through the Telegram user API, providing tools for listing chats, reading, sending, and searching messages, plus an action catalog for account administration.
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., "@tgmcpList my recent chats and show unread messages"
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.
tgmcp
MCP server that automates one Telegram user account through the Telegram user API (mtcute). It is not a bot.
The public tool list is an inbox: list chats, read, send, and search. Everything else lives in an action catalog behind telegram search / describe / invoke. Empty catalog search shows inbox and lookup actions only. Join, leave, and profile edits stay hidden until you search for them.
tgmcp runs on Node.js 20 or newer. npx and bunx both work.
Install
One-shot (no global install):
npx @watzon/tgmcp loginbunx @watzon/tgmcp loginGlobal install:
npm install -g @watzon/tgmcp
# or
bun add -g @watzon/tgmcpThat puts tgmcp on your PATH.
From a clone:
git clone https://github.com/watzon/tgmcp.git
cd tgmcp
bun install
bun run loginRelated MCP server: telegram-mcp
Sign in
Create an application at my.telegram.org and copy
api_id/api_hash.Run
tgmcp login(orbun run loginin a clone).Finish the page that opens on
127.0.0.1. The hash, login code, and 2FA stay in the browser. They never enter the model.
Both login paths write storage/credentials.json (api id, hash, owner id) and the mtcute session under the data home.
Local browser login is the one you want. On a remote host, start the MCP server unsigned and use theauth tool: set_credentials, then send_code / sign_in, or start_qr. You can also call auth with browser and open that URL on the machine that runs tgmcp (SSH port-forward if you are not on that host).
Optional: put TELEGRAM_API_ID and TELEGRAM_API_HASH in .env in the data home. Env values override the credentials file.
Check the session with tgmcp status.
Run the MCP server
tgmcp
# same thing:
tgmcp serveThe process speaks MCP on stdio. Point your host at that command. Host snippets for Claude Code, Cursor, OpenClaw, and Hermes are in agent instructions.
Agent instructions
You are installing tgmcp. It is an MCP server that automates one Telegram user account through the Telegram user API. It is not a bot. Do not ask for a bot token.
Requirements
Node.js 20 or newer on the machine that will run the server. Prefer
npx -y @watzon/tgmcp.bunx @watzon/tgmcpalso works.An
api_idandapi_hashfrom my.telegram.org. The user already has these, or they get them there.
Do not clone the repo unless the user asked for a development checkout.
Wire the host
Generic stdio, Claude Code, Cursor, and OpenClaw:
{
"mcpServers": {
"telegram": {
"command": "npx",
"args": ["-y", "@watzon/tgmcp"]
}
}
}bunx @watzon/tgmcp is the same command if you prefer Bun.
Hermes:
mcp_servers:
telegram:
command: "npx"
args: ["-y", "@watzon/tgmcp"]Default data home is ~/.tgmcp. Set TGMCP_HOME in the host env only if the user wants a different directory. From a clone, bun src/index.ts with cwd set to the repo still works.
Sign in
On the same machine as the server, run
npx @watzon/tgmcp login(ortgmcp loginif it is installed). A page binds to127.0.0.1. The user finishes it in a browser. Do not ask them to pasteapiHash, the login code, or a 2FA password into chat.On a remote host, start the server unsigned. Call
authwithcommand: "status"first. Thenset_credentials, thensend_code/sign_in, orstart_qr. Preferauthcommand: "browser"if they can open or port-forward that URL.Never echo
apiHash, login codes, or 2FA passwords in tool results, logs, or later messages.
After it is connected
Call
authwithcommand: "status"once per session before other tools. The tool list does not change with auth state.Use
list_chatsto get a numericchatId. Pass thatchatIdon every chat-scoped call. Groups and channels are negative.Inbox tools:
list_chats,read_messages,send_message,search_messages.Longer tail goes through
telegramwithcommandsearch,describe, orinvoke. Empty search lists inbox and lookup actions only. Searchjoin,leave,folder, orprofilefor account-admin actions.
Example:
telegram { command: "search", query: "pin topic" }
telegram { command: "describe", name: "pin" }
telegram { command: "invoke", name: "pin", params: { chatId: "-100123", messageId: 42 } }Tools
Tool | Role |
| Resolve a title to a numeric |
| Recent history. Does not mark read |
| Send or reply in a chat |
| Find messages inside one chat |
| Catalog knife: |
| Sign-in. Prefer |
Chat-scoped work needs an explicit numeric chatId. Use list_chats first.
Example catalog flow:
telegram { command: "search", query: "pin topic" }
telegram { command: "describe", name: "pin" }
telegram { command: "invoke", name: "pin", params: { chatId: "-100123", messageId: 42 } }Empty telegram search lists inbox and lookup actions (react, edit, pin, media, user info, topics). Search for join, leave, folder, or profile when you need those.
Data home
Published runs store state in ~/.tgmcp unless you say otherwise:
Path | What |
| Denylist, rate limits, relative paths |
| api id, hash, owner id (mode 0600) |
| mtcute SQLite session |
| Append-only action ledger |
| Saved media |
Resolution order:
TGMCP_HOMEif setThe current directory, if it already has
tgmcp.config.json(this is how a clone works)~/.tgmcp, created on first run
Copy .env.example to .env in that directory if you want env overrides.
Config
tgmcp.config.json looks like this:
{
"ownerId": "",
"telegram": {
"sessionPath": "storage/session",
"credentialsPath": "storage/credentials.json"
},
"ledgerPath": "data/tgmcp.db",
"downloadsDir": "data/downloads",
"denylist": [],
"rateLimits": {
"perChatMs": 2000,
"globalPerHour": 120
}
}ownerId is filled in after the first login. If you set it yourself, tgmcp refuses to start as a different account.
Safety
Mutations go through a denylist, per-chat spacing, a global hourly cap, one flood-wait retry, and an append-only ledger.
Secrets stay on disk or in
.env. The MCP transport is stdio, so logs go to stderr only.This process does not run an agent loop and does not ingest incoming chats on its own.
Treat
storage/sessionlike a logged-in browser profile. Do not commit it.
Development
bun install
bun test
bun run typecheck
bun run build
node dist/cli.js help
bun run login
bun src/index.tsCONTEXT.md has the project vocabulary and boundaries.
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
- FlicenseBqualityDmaintenanceAn MCP server that enables interaction with Telegram messaging platform, allowing users to retrieve unread messages, fetch entity information, and send messages through natural language interfaces.610
- Alicense-qualityCmaintenanceAn MCP server that enables interaction with Telegram to send, read, and search messages across chats and dialogs. It supports waiting for incoming messages and retrieving conversation history through natural language commands.194MIT
- AlicenseAqualityCmaintenanceMCP server that exposes a Telegram bot, enabling sending messages and retrieving updates through natural language.31MIT
- Alicense-qualityBmaintenanceAn MCP server that connects to Telegram as your real user account and exposes read-only tools to read and search messages, list chats and folders, inspect group info, and download media.22MIT
Related MCP Connectors
Telegram bridge for your MCP-compatible agent. Bidirectional, no LLM in our stack.
MCP server for Gainium — manage trading bots, deals, and balances via AI assistants
Personal assistant MCP server with search, execute, packages, jobs, secrets, and integrations.
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/watzon/tgmcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server