Telegram MCP Server
The Telegram MCP Server enables AI agents to interact with Telegram accounts programmatically via the MTProto protocol, with integrated safety features throughout.
Get Account Info: Retrieve details about the currently logged-in Telegram account (
get_account_info).List Chats: Browse and search Telegram chats/dialogs with filtering options (
list_chats).Download Media: Safely download media attachments from Telegram messages (
download_telegram_media), with path traversal prevention, dangerous file type blocking, filename sanitization, and a 100MB size limit.Send Messages: Send text messages or media files to any Telegram chat (
telegram_send_message), with support for replies, parse modes, silent sending, and link preview control. Includes safety features like dangerous file extension blocking and upload size limits.Authentication: Authenticate with Telegram using your API credentials before using the server.
Provides tools for interacting with Telegram via MTProto, enabling AI agents to send messages, manage chats, and perform other Telegram actions programmatically.
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., "@Telegram MCP Serverget my recent messages from the group 'Tech Talk'"
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 Model Context Protocol (MCP) server for Telegram, built with Telethon and FastMCP.
Features
MTProto Support: High-performance communication via Telethon.
FastMCP: Seamless integration with AI agents.
Async & Performance: Optimized for speed and concurrency.
Professional Core: Built-in logging, caching, and configuration.
Related MCP server: tdlib-mcp-server
Setup
Install
uvif you haven't already.Clone the repository.
Create a
.envfile based on.env.example:cp .env.example .envFill in your
API_IDandAPI_HASHfrom my.telegram.org.Install dependencies:
uv sync
Usage
Authentication
Before running the server, you need to authenticate with Telegram:
uv run telegram-mcp authRun Server
uv run telegram-mcp serverOr run directly via the module:
uv run python -m telegram_mcp.serverCodex Integration
This server is fully compatible with Codex.
Local Plugin Discovery
The repository includes a .codex-plugin/ directory for native discovery. You can add this directory as a local plugin in your Codex settings.
Manual Configuration
Add the following to your ~/.codex/config.toml (replace with your absolute paths):
[mcp_servers.telegrammcp]
command = "/absolute/path/to/TelegramMCP/.venv/bin/python"
args = ["-m", "telegram_mcp.server"]
cwd = "/absolute/path/to/TelegramMCP"
startup_timeout_sec = 30
tool_timeout_sec = 120
env_vars = ["API_ID", "API_HASH", "SESSION_NAME", "TELEGRAM_PHONE_NUMBER"]
[mcp_servers.telegrammcp.env]
SERVER_NAME = "telegrammcp"
LOG_LEVEL = "INFO"
TELEGRAM_DOWNLOAD_DIR = "/absolute/path/to/TelegramMCP/storage/downloads/telegram"
TELEGRAM_UPLOAD_DIR = "/absolute/path/to/TelegramMCP/storage/uploads/telegram"Tools
Account Info
get_account_info: Returns information about the currently logged-in Telegram account.
Chat Management
list_chats: List Telegram chats/dialogs with search and filtering.
Media Download
download_telegram_media: Safely download media attachments from a Telegram message.Inputs:
chat_id,message_id,download_directory(optional),preferred_file_name(optional),allow_suspicious_files(default: false).Safety Features:
Prevents path traversal.
Blocks suspicious file types (executables, archives) by default.
Sanitizes filenames.
Limits file size (default 100MB).
Ensures downloads stay within a designated storage directory.
Sending Messages
telegram_send_message: Safely send a message or media file to a Telegram chat, or reply to an existing message.Inputs:
chat(required),message(optional),reply_to_message_id(optional),media(optional),parse_mode(optional),silent(optional),disable_link_preview(optional).Safety Features:
Strictly blocks dangerous file extensions (
.exe,.sh,.bat, etc.) for uploads.Prevents path traversal for local media files.
Enforces max upload file size (default 100MB).
Forbids URL-based media fetching for security.
Examples:
Send text:
{"chat": "@username", "message": "Hello"}Reply with text:
{"chat": "123456", "message": "Got it!", "reply_to_message_id": 987}Send photo:
{"chat": "@username", "media": {"path": "C:/safe/dir/photo.jpg", "type": "photo"}}
Structure
src/telegram_mcp/core/: Essential utilities (logger, cache, config).src/telegram_mcp/service/: Business logic and external API clients.src/telegram_mcp/models/: Pydantic data models.src/telegram_mcp/server.py: MCP server definition and tool registration.
Available Tools
1 toolget_account_infoA
Returns information about the currently logged-in Telegram account.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, and the description does not disclose behavioral traits beyond the fact that it returns information. For a simple read-only tool, this is adequate but not rich.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, front-loaded sentence with no wasted words. It is appropriately concise for a trivial tool.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no output schema, the description could be more specific about what 'information' is returned. However, for a tool with no parameters and no siblings, it is minimally complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
There are no parameters, and the schema coverage is 100%. Per guidelines, a baseline of 4 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('Returns information') and the resource ('the currently logged-in Telegram account'). It is specific enough, though the term 'information' is vague. No siblings exist, so no differentiation needed.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description does not provide explicit guidance on when to use the tool versus alternatives, but there are no siblings. The context is simple, so the lack of detailed usage instructions is acceptable but not exemplary.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
Only one tool exists, so there is no possibility of confusion between tools.
With a single tool, naming is trivially consistent and follows a clear verb_noun pattern.
A single tool for a Telegram server is far too few; typical Telegram integrations have many more tools for messaging, media, and contact management.
The tool set covers only account information, missing essential operations like sending messages, fetching chats, and managing contacts, making it severely incomplete.
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 Connectors
Multi-tenant Telegram gateway for AI agents — HTTP+stdio, 8 tools, MTProto User API
Telegram bridge for your MCP-compatible agent. Bidirectional, no LLM in our stack.
Phone, SMS & email for AI agents — one remote MCP endpoint, OAuth login, zero install.
AI agent infrastructure for discovery, authorization, execution, identity, and signed receipts.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI agents to send and receive messages, media, and files on Telegram, and manage chats via a bot token.17MIT
- FlicenseNot gradedqualityDmaintenanceConnects AI agents to Telegram via the official TDLib library, enabling tools like getting user info, listing dialogs, and searching messages.
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to interact with a user's Telegram account: list chats, read history, search, and send messages through Telegram's MTProto API.1MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to control a personal Telegram account for sending/reading messages, media, group management, and more via the MTProto API.MIT
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/shaxzodrashid/TelegramMCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server