Telegram MCP Server
Provides tools for accessing the Telegram API, including listing dialogs, chats, and channels; retrieving unread messages and media messages; and requesting/receiving photos, documents, videos, and audio from users.
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 MCP server
About
The server is a bridge between the Telegram API and the AI assistants and is based on the Model Context Protocol.
Ensure that you have read and understood theTelegram API Terms of Service before using this server. Any misuse of the Telegram API may result in the suspension of your account.
Related MCP server: Telegram Account MCP Connector
What is MCP?
The Model Context Protocol (MCP) is a system that lets AI apps, like Claude Desktop, connect to external tools and data sources. It gives a clear and safe way for AI assistants to work with local services and APIs while keeping the user in control.
What does this server do?
The server provides access to the Telegram API, allowing users to:
Get the list of dialogs (chats, channels, groups)
Get the list of (unread) messages in the given dialog
Retrieve messages with media (photos, videos, documents, audio)
Request and receive media from users
Mark chanel as read
Retrieve messages by date and time
Get the list of contacts
Draft a message
...
Practical use cases
Create a summary of the unread messages
Analyze images and media shared in chats
Request photos or documents from users and analyze them in real-time
Find contacts with upcoming birthdays and schedule a greeting
Find discussions on a given topic, summarize them and provide a list of links
Prerequisites
Installation
uv tool install git+https://github.com/sparfenyuk/mcp-telegramIf you have already installed the server, you can update it usinguv tool upgrade --reinstall command.
If you want to delete the server, use theuv tool uninstall mcp-telegram command.
Configuration
Telegram API Configuration
Before you can use the server, you need to connect to the Telegram API.
Get the API ID and hash from Telegram API
Run the following command:
mcp-telegram sign-in --api-id <your-api-id> --api-hash <your-api-hash> --phone-number <your-phone-number>Enter the code you received from Telegram to connect to the API.
The password may be required if you have two-factor authentication enabled.
To log out from the Telegram API, use themcp-telegram logout command.
Claude Desktop Configuration
Configure Claude Desktop to recognize the Exa MCP server.
Open the Claude Desktop configuration file:
in MacOS, the configuration file is located at
~/Library/Application Support/Claude/claude_desktop_config.jsonin Windows, the configuration file is located at
%APPDATA%\Claude\claude_desktop_config.json
Note: You can also find claude_desktop_config.json inside the settings of Claude Desktop app
Add the server configuration
{ "mcpServers": { "mcp-telegram": { "command": "mcp-server", "env": { "TELEGRAM_API_ID": "<your-api-id>", "TELEGRAM_API_HASH": "<your-api-hash>", }, } } } }
Telegram Configuration
Before working with Telegram's API, you need to get your own API ID and hash:
Login to your Telegram account with the phone number of the developer account to use.
Click under API Development tools.
A 'Create new application' window will appear. Fill in your application details. There is no need to enter any URL, and only the first two fields (App title and Short name) can currently be changed later.
Click on 'Create application' at the end. Remember that your API hash is secret and Telegram won't let you revoke it. Don't post it anywhere!
Development
Getting started
Clone the repository
Install the dependencies
uv syncRun the server
uv run mcp-telegram --help
Tools can be added to the src/mcp_telegram/tools.py file.
How to add a new tool:
Create a new class that inherits from ToolArgs
class NewTool(ToolArgs): """Description of the new tool.""" passAttributes of the class will be used as arguments for the tool. The class docstring will be used as the tool description.
Implement the tool_runner function for the new class
@tool_runner.register async def new_tool(args: NewTool) -> t.Sequence[TextContent | ImageContent | EmbeddedResource]: passThe function should return a sequence of TextContent, ImageContent or EmbeddedResource. The function should be async and accept a single argument of the new class.
Done! Restart the client and the new tool should be available.
Validation can accomplished either through Claude Desktop or by running the tool directly.
Debugging the server in terminal
To run the tool directly, use the following command:
# List all available tools
uv run cli.py list-tools
# Run the concrete tool
uv run cli.py call-tool --name ListDialogs --arguments '{"unread": true}'Debugging the server in the Inspector
The MCP inspector is a tool that helps to debug the server using fancy UI. To run it, use the following command:
npx @modelcontextprotocol/inspector uv run mcp-telegramDo not forget to define Environment Variables TELEGRAM_API_ID and TELEGRAM_API_HASH in the inspector.
Available Tools
ListDialogs
Lists available dialogs, chats and channels. Useful for finding conversation IDs to use with other tools.
Parameters:
unread: Boolean flag to show only dialogs with unread messages (default: false)archived: Boolean flag to include archived dialogs (default: false)ignore_pinned: Boolean flag to ignore pinned dialogs (default: false)
Example:
uv run cli.py call-tool --name ListDialogs --arguments '{"unread": true}'ListMessages
Lists messages in a given dialog, chat or channel, from newest to oldest.
Parameters:
dialog_id: ID of the dialog to retrieve messages fromunread: Boolean flag to show only unread messages (default: false)limit: Maximum number of messages to retrieve (default: 100)
Example:
uv run cli.py call-tool --name ListMessages --arguments '{"dialog_id": 123456789, "limit": 10}'GetMessagesWithMedia
Retrieves messages containing media (photos, videos, documents, audio) from a given dialog.
Parameters:
dialog_id: ID of the dialog to retrieve media fromlimit: Maximum number of messages to check for media (default: 20)include_documents: Boolean flag to include document media (default: true)include_videos: Boolean flag to include video media (default: true)include_audio: Boolean flag to include audio media (default: true)
Example:
uv run cli.py call-tool --name GetMessagesWithMedia --arguments '{"dialog_id": 123456789, "limit": 5}'RequestUserMedia
Sends a message to a chat requesting media and waits for the user's response.
Parameters:
dialog_id: ID of the dialog to send the request tomessage: Message text to send to the user requesting mediaaccept_photos: Boolean flag to accept photos (default: true)accept_documents: Boolean flag to accept documents (default: true)accept_videos: Boolean flag to accept videos (default: true)accept_audio: Boolean flag to accept audio (default: true)timeout: Maximum seconds to wait for a response (default: 60)max_media: Maximum number of media items to collect (default: 5)
Example:
uv run cli.py call-tool --name RequestUserMedia --arguments '{"dialog_id": 123456789, "message": "Please send me some photos or documents", "timeout": 120}'RequestUserPhotos
Legacy tool that requests only photos from a user (maintained for backward compatibility).
Parameters:
dialog_id: ID of the dialog to send the request tomessage: Message text to send to the user requesting photostimeout: Maximum seconds to wait for a response (default: 60)max_photos: Maximum number of photos to collect (default: 5)
Example:
uv run cli.py call-tool --name RequestUserPhotos --arguments '{"dialog_id": 123456789, "message": "Please send me some photos", "timeout": 90}'Troubleshooting
Message 'Could not connect to MCP server mcp-telegram'
If you see the message 'Could not connect to MCP server mcp-telegram' in Claude Desktop, it means that the server configuration is incorrect.
Try the following:
Use the full path to the
uvbinary in the configuration fileCheck the path to the cloned repository in the configuration file
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
Let AI assistants post to your Telegram chats, groups and channels. Not affiliated with Telegram.
Telegram automation for AI: read and search channel summaries, get digests, manage auto-publishing.
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
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to read chats, Saved Messages, files and media, search history, and send messages through your personal Telegram account.3MIT
- FlicenseNot gradedqualityBmaintenanceEnables AI assistants to read Telegram conversations, search messages, retrieve chat context, resolve recipients, and send messages with delivery status.1-
- AlicenseAqualityCmaintenanceEnables AI agents to access and search Telegram conversations, including transcribed voice messages and OCR'd images, and to draft messages that require user approval before sending.152MIT