telegram-user-mcp
Connects to a personal Telegram MTProto account via Telethon to provide tools for authentication, chat/folder discovery, message reading and global search, sending/editing/forwarding/deleting/pinning messages, and media upload/download.
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-user-mcp search my Telegram chats for messages about the launch plan"
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-user-mcp
An asynchronous Model Context Protocol (MCP) server and CLI that connects AI coding agents (Claude Code, Claude Desktop, Cursor, Gemini, and custom MCP hosts) directly to a personal Telegram MTProto account via Telethon.
Unlike standard Telegram Bot API wrappers—which can only see chats where a bot was explicitly invited—telegram-user-mcp operates through your authenticated user session with automatic SQLite session-lock recovery, idle auto-disconnect, and a server-enforced TELEGRAM_READ_ONLY safety guard.
Key Capabilities
19 MCP Tools Out of the Box: Full coverage for authentication (OTP + 2FA cloud password), custom chat folders (
DialogFilter), unread dialog filtering, global cross-chat search, message sending/editing/forwarding/pinning, and media uploads/downloads.Read-Only Safety Guard (
TELEGRAM_READ_ONLY=true): Safely grant agents full read/search access across your Telegram workspace while blocking all mutating tools (send,edit,forward,delete,pin) at the server layer.Zero-Lock Session Lifecycle: Automatically disconnects idle Telethon SQLite sessions after 20 seconds of inactivity and retries transient SQLite locks with exponential backoff.
Smart Entity Resolution: Target any chat seamlessly using
"me"(Saved Messages),@username,t.me/links, numeric IDs, or fuzzy dialog titles.Clean
stdioTransport & CLI Parity: Directs all diagnostic logging strictly tostderrand exposes every tool from the terminal viatelegram-mcp-cli.
Related MCP server: telegram-mcp
Installation
git clone https://github.com/tarikra1/telegram-user-mcp.git
cd telegram-user-mcp
python -m venv .venv
# Windows: .venv\Scripts\activate | macOS/Linux: source .venv/bin/activate
pip install -e .Configuration
Create an application at https://my.telegram.org/apps to obtain your
api_idandapi_hash.Copy
.env.exampleto.envand fill in your credentials:
cp .env.example .envTELEGRAM_API_ID=12345678
TELEGRAM_API_HASH=your_32_character_telegram_api_hash
TELEGRAM_PHONE=+15550109999
TELEGRAM_READ_ONLY=falseConnecting to Claude Code / Claude Desktop / Cursor
Add the server to your MCP configuration (claude_desktop_config.json or .mcp.json):
{
"mcpServers": {
"telegram": {
"command": "telegram-user-mcp",
"env": {
"TELEGRAM_API_ID": "12345678",
"TELEGRAM_API_HASH": "your_api_hash",
"TELEGRAM_PHONE": "+15550109999",
"TELEGRAM_READ_ONLY": "false"
}
}
}
}On first use, ask your agent to call auth_send_code followed by auth_verify_code (including Two-Step Verification password support if 2FA is enabled on your Telegram account).
Available MCP Tools (19)
Category | Tool | Description |
Auth & Profile |
| Check session auth state and |
| Request an OTP login code via Telegram / SMS | |
| Complete sign-in with OTP code and optional 2FA password | |
| Retrieve profile details of the authenticated account | |
Discovery & Folders |
| List custom Telegram chat folders ( |
| List all peers pinned/included inside a specific folder | |
| List dialogs filtered by | |
| Search local dialogs + global Telegram directory | |
| Fetch bio, participant count, and metadata for any entity | |
Reading & Search |
| Read recent or filtered messages from a specific chat |
| Full-text search across all chats, groups, and channels | |
Messaging & Media |
| Send Markdown, HTML, or plain-text messages (blocked in read-only mode) |
| Upload documents, images, or videos with captions (blocked in read-only mode) | |
| Download attachments from any message ID to disk | |
| Forward message batches across chats (blocked in read-only mode) | |
| Edit previously sent messages (blocked in read-only mode) | |
| Delete/revoke messages (blocked in read-only mode) | |
| Acknowledge unread messages in a dialog | |
| Pin a message silently or with notification (blocked in read-only mode) |
CLI Usage
# List all registered tools
telegram-mcp-cli list
# List top 10 unread channels
telegram-mcp-cli list_chats --chat-type channel --unread-only --limit 10
# Search across all chats
telegram-mcp-cli search_messages_global --query "deployment" --limit 5Project Links
Running Tests
python -m unittest discover -s tests -vLicense
Released under the MIT License.
Available Tools
19 toolsauth_send_codeC
Send a Telegram login verification code to your phone/Telegram app.
Inputs: phone. Returns: result
auth_statusB
Check whether the Telegram personal account session is authorized.
Inputs: no named parameters. Returns: result
auth_verify_codeA
Complete Telegram login with the verification code (and optional 2FA cloud password).
Inputs: code (required), password. Returns: result
delete_messagesB
Delete one or more messages in a chat.
Inputs: target (required), message_ids (required), revoke. Returns: result
download_mediaC
Download the attached file/photo/video/archive from a specific message_id in target chat.
Inputs: target (required), message_id (required), output_dir. Returns: result
edit_messageC
Edit the text of a message you previously sent.
Inputs: target (required), new_text (required), message_id (required). Returns: result
forward_messagesC
Forward one or more messages from one chat to another (e.g. to 'me' Saved Messages).
Inputs: to_target (required), from_target (required), message_ids (required). Returns: result
get_chat_infoB
Get detailed info about a user, group, or channel by ID, @username, or chat title.
Inputs: target (required). Returns: result
get_folder_chatsA
List all chats/channels/groups inside a custom Telegram folder (by folder title like 'Work' or folder ID).
Inputs: folder (required). Returns: result
get_meA
Get profile information of the currently logged-in Telegram user.
Inputs: no named parameters. Returns: result
get_messagesA
Read messages from a chat/group/channel ('me', @username, numeric ID, or chat title). Optionally filter messages inside that chat using 'search'.
Inputs: target (required), limit, search, offset_id. Returns: result
list_chatsC
List recent Telegram dialogs/chats. chat_type: 'all', 'user', 'bot', 'group', or 'channel'.
Inputs: limit, archived, chat_type, unread_only. Returns: result
list_foldersA
List custom Telegram chat folders (filters) such as work, courses, graphics, etc.
Inputs: no named parameters. Returns: result
mark_as_readC
Mark unread messages in a chat/group/channel as read.
Inputs: target (required). Returns: result
pin_messageC
Pin a message in a chat/group/channel.
Inputs: target (required), message_id (required), notify. Returns: result
search_chatsB
Search your Telegram dialogs and global directory by name or @username.
Inputs: query (required), limit. Returns: result
search_messages_globalC
Search messages across ALL your Telegram chats, groups, and channels.
Inputs: query (required), limit. Returns: result
send_fileC
Upload and send a local file, image, video, or document to a Telegram chat or 'me'.
Inputs: target (required), file_path (required), caption, force_document, +1 more. Returns: result
send_messageC
Send a text message to a user, group, channel, or 'me' (Saved Messages). parse_mode: 'md' (Markdown), 'html', or 'none'.
Inputs: target (required), message (required), parse_mode, reply_to_msg_id. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 19 tools
Most tools target a distinct resource+action pair (send/edit/delete/forward/pin messages), and descriptions clarify the boundaries between list_chats, search_chats, and get_chat_info. Minor overlap remains between search_chats and get_chat_info (both resolve a chat by name/@username) and between get_messages and search_messages_global, but the wording makes the intended selection clear.
All names are snake_case and follow a verb_noun pattern (send_message, edit_message, delete_messages, list_chats, get_chat_info), with an auth_ namespace prefix used consistently for the three login tools. The only deviations are the noun-phrase auth_status and the terse get_me, which are minor and readable.
At 19 tools the set is on the heavy side but each tool maps to a real operation in a personal Telegram client (auth, chats, folders, messages, media). No obviously redundant tools inflate the count, though a few message-management operations could arguably be collapsed.
Core messaging lifecycle is well covered: send text/file, read, search (per-chat and global), edit, delete, forward, pin, mark read, and media download, plus auth and folder browsing. Gaps exist around chat membership operations (join/leave), contact/participant listing, reactions, and folder creation/deletion, but agents can work around most of these.
Maintenance
Related MCP Connectors
Multi-tenant Telegram gateway for AI agents — HTTP+stdio, 8 tools, MTProto User API
Messaging tools for AI agents: send messages, manage chats, groups and channels.
Telegram bridge for your MCP-compatible agent. Bidirectional, no LLM in our stack.
Email inboxes, webhook URLs, mock APIs and 170+ tools for coding agents over one MCP connection.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with a user's Telegram account: list chats, read history, search, and send messages through Telegram's MTProto API.2MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to control a real Telegram user account via MTProto, allowing message sending, chat reading/searching, and message management through MCP tools.-
- 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
- AlicenseNot gradedqualityCmaintenanceEnables MCP-compatible clients such as Claude and Cursor to access and manage Telegram accounts, chats, messages, contacts, media, folders, and admin operations through exposed tools.Apache 2.0