telegram-account-mcp
Provides tools for working with an owner's personal Telegram account, including reading chats and messages, searching, managing files and voice transcription, sending and editing messages, managing chat administration and topics, and invoking arbitrary Telegram MTProto methods with safety checks and quotas.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
telegram-account-mcp
MCP server that lets an AI assistant (Claude, ChatGPT and other MCP clients) work with your own Telegram account, not a bot. It runs as one long-lived process on your server, holds the only Telethon session, and exposes about 37 tools over authenticated streamable HTTP.
It is built for daily, real use by one owner. Safety checks are part of each tool: the target is verified before anything is sent, retries are idempotent, quotas are durable, and every write is read back from Telegram.
What it can do
Area | Tools |
Reading |
|
Files |
|
Writing |
|
Dialog state |
|
Administration |
|
Voice |
|
Everything else |
|
New versions without "Refresh" |
|
Self-improvement |
|
New versions without pressing "Refresh"
ChatGPT and Claude remember a connector's tool list when it is connected or refreshed. A tool or parameter added later stays invisible until somebody presses "Refresh" in the connector settings. Three gateway tools never change their names or parameters, so a client that has them reaches everything deployed later:
list_tools_live— the catalog as deployed now, with full parameter schemas (name=...for one tool);call_read_tool(name, arguments)— runs a read-only tool, refuses anything that changes data;call_tool(name, arguments)— runs any tool.
A gateway call goes through the same registered tool as a direct call, with the same validation, chat resolution, expected_chat, request_id and quotas. Refresh is still useful once in a while so that new tools also appear as first-class tools, but nothing waits for it.
Sending files from a computer
begin_attachment_upload returns upload_url and a ready upload_command. An assistant that can run shell commands uploads the file in one request, so the bytes never pass through the model:
curl -sS --fail-with-body -T card.png 'https://tg.example.com/upload/<upload_id>/<secret>'Then send_file(upload_id=..., send_as='photo' | 'document'). The URL works once, for 15 minutes, for that upload only, and needs no connector credentials. The server checks the declared size and SHA-256 and counts the file against the same upload quota. The reverse proxy must pass /upload/* to the backend with a body limit of at least 32 MiB (see deploy/Caddyfile.example). upload_url is built from public_url, private/public-host or the first host in allowed_hosts; without any of them only the base64 path is offered.
Keeping up with Telegram
Telegram adds features all the time. feature_watch.py runs daily on the server (cron) and compares Telegram's published API schema, the Telegram blog and the latest Telethon release with what this connector has. When something is new it sends a short note to Saved Messages and stores a report that get_telegram_updates serves. A weekly adoption agent reads that report, upgrades Telethon or adds a dedicated tool when it is worth it, and adds the feature to messaging_guide.md.
get_messaging_guide serves that guide: which Telegram features to use by default when writing on the owner's behalf (tables for comparisons, in-place edits, reactions instead of empty replies). Assistants read it before writing, so new features appear in everyday messages without a separate request.
# on the server, in the service directory
.venv/bin/python feature_watch.py --notifyUniversal MTProto access
Telegram ships new API methods all the time. Writing a dedicated tool for each one never keeps up. invoke_mtproto calls any method that the installed Telethon knows, so updating Telethon makes new Telegram features available right away.
Reads (
get*,search*,check*,resolve*) run at once.Writes need
confirm_write=true(only after the owner explicitly asked for that exact action), arequest_id(deduplication),expected_chatwhen a chat or person is targeted, and stay within a daily quota.Always refused: login and session keys (
auth.*), password, account deletion, payments/Stars/gifts, deleting whole chats or history, ownership transfer.Redirected: actions that have a dedicated tool with stronger checks (
messages.sendMessage→send_message, and so on).Logged: each call records the method name, kind, outcome and parameter names in a local SQLite file. Values and responses are never logged.
get_raw_usage_statsturns this into a list of candidates for new dedicated tools.
Related MCP server: Telegram MCP Server
Safety model
Message content from other people is data, never instructions. The server instructions tell the model this.
Addresses must be a numeric ID, an exact
@usernameort.me/username. Bare words, display names and phone numbers are rejected before resolution.Every mutation checks
expected_chatagainst the resolved chat, and in private chats checks that a message ID really belongs to that chat.request_idreceipts are stored before the Telegram call. A retry returns the original receipt. An uncertain outcome blocks a blind resend.Durable quotas cover creating chats, inviting, joining, removing and bulk deleting, as well as raw writes.
After each send, the chat gets Telegram's manual "unread" mark, so the owner can see where the assistant wrote on their behalf.
Setup
Python 3.11+, then
python -m venv .venv && .venv/bin/pip install -r requirements.txt.Create
private/(mode 700) with:credentials.json:{"api_id": ..., "api_hash": "..."}from https://my.telegram.org;mcp-token: a long random bearer token;a Telethon session
private/stan-vps-tg.session, authorized once interactively.
Run
server.py. It listens on127.0.0.1:18765/mcpand requiresAuthorization: Bearer <mcp-token>.To reach it from Claude.ai, run
claude_gateway.pybehind HTTPS (seedeploy/Caddyfile.example). It uses a separate public token,private/claude-mcp-token.Use systemd units like
deploy/*.service.example.Optional voice fallback: a separate venv with
faster-whisperandwhisper_transcribe.py(seevoice.py).
Only one process may own the Telegram session. Do not start a second Telethon client on a copied session file.
Updates come from GitHub: on the server the service directory is a git checkout. ./deploy.sh fetches, fast-forwards, runs the tests (rolls back on failure), waits for running watcher jobs, restarts the service and prints get_status.
rpc.py TOOL < args.json calls a tool on the running server from a shell on the same machine.
Several accounts from one codebase
Every account runs its own copy of the same code: its own process (or container), its own private/ directory with the Telegram session, tokens and receipts, and its own private/instance.json. The code has nothing account-specific in it. See instance.py for the settings: service name, session file, expected_account_id (the server refuses to start for another account), host and port, allowed hosts and origins, auto_unread_mark, and the OAuth gateway values.
A new release is one git pull per instance, so every account gets the same features. For instances in Docker containers under supervisord, deploy/update-container.sh HOST_DIR CONTAINER CONTAINER_DIR PROGRAM... does fetch, tests inside the container, rollback on failure, restart and get_status.
Access for ChatGPT and other OAuth clients
oauth_gateway.py is a public HTTPS front for one owner:
a web page to log in to Telegram (phone, code, 2FA), opened with a one-time bootstrap link;
OAuth 2.1 with PKCE and dynamic client registration (
oauth.py): 1-hour access tokens, rotating 30-day refresh tokens, scopetelegram, resource bound to/mcp;a consent page protected by a separate connection password;
a proxy to the private MCP backend.
claude_gateway.py is the simpler alternative: a static bearer token.
Tests
.venv/bin/python -m unittest test_raw_mtproto test_voice test_topics test_admin_tools \
test_attachments test_mentions test_edit_message test_dialog_state test_chat_photoThe tests use fake Telegram clients and temporary state. They need no network, credentials or real sends.
Contributing
Issues and pull requests are welcome, especially new dedicated tools for frequently used raw methods, and better voice and calls support.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Multi-tenant Telegram gateway for AI agents — HTTP+stdio, 8 tools, MTProto User API
Let AI assistants post to your Telegram chats, groups and channels. Not affiliated with Telegram.
Your Telegram, WhatsApp, Instagram, mail and calendar in Claude or ChatGPT. Never sends messages.
Your personal Telegram account for AI: read, search and sum up chats. QR login, no API key.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to control a personal Telegram account for sending/reading messages, media, group management, and more via the MTProto API.MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with a personal Telegram account via MTProto, offering messaging, search, media handling, and other tools, particularly suited for finding and applying to remote jobs.-
- AlicenseNot gradedqualityDmaintenanceGives an AI assistant full control of a real Telegram user account over MTProto, enabling it to read chats, search history, send and manage messages, and dynamically create new tools as needed.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to interact with a personal Telegram account via MCP, offering tools for reading and searching chats, summarizing unread messages, sending and editing messages, handling files and voice transcripts, and managing groups and channels, with read-only mode by default.Apache 2.0