Telegram MCP Server
A bridge allowing Claude Desktop to access Telegram chats and messages via the Model Context Protocol, providing read-only capabilities to retrieve dialogs and messages from Telegram.
sparfenyuk
Tools
ListDialogs
List available dialogs, chats and channels.
ListMessages
List messages in a given dialog, chat or channel. The messages are listed in order from newest to oldest. If `unread` is set to `True`, only unread messages will be listed. Once a message is read, it will not be listed again. If `limit` is set, only the last `limit` messages will be listed. If `unread` is set, the limit will be the minimum between the unread messages and the limit.
README
Telegram MCP server
- 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.
[!IMPORTANT] Ensure that you have read and understood the Telegram API Terms of Service before using this server. Any misuse of the Telegram API may result in the suspension of your account.
<a href="https://glama.ai/mcp/servers/484jega1au"> <img width="380" height="200" src="https://glama.ai/mcp/servers/484jega1au/badge" alt="Telegram Server MCP server" /> </a>
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?
As of not, the server provides read-only access to the Telegram API.
- [x] Get the list of dialogs (chats, channels, groups)
- [x] Get the list of (unread) messages in the given dialog
- [ ] Mark chanel as read
- [ ] Retrieve messages by date and time
- [ ] Download media files
- [ ] Get the list of contacts
- [ ] Draft a message
- ...
Practical use cases
- [x] Create a summary of the unread messages
- [ ] 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-telegram
[!NOTE] If you have already installed the server, you can update it using
uv tool upgrade --reinstallcommand.
[!NOTE] If you want to delete the server, use the
uv tool uninstall mcp-telegramcommand.
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.
[!NOTE] To log out from the Telegram API, use the
mcp-telegram logoutcommand.
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.json - in 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
- in MacOS, the configuration file is located at
-
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 sync -
Run 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-telegram
[!WARNING] Do not forget to define Environment Variables TELEGRAM_API_ID and TELEGRAM_API_HASH in the inspector.
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 file - Check the path to the cloned repository in the configuration file
Recommended Servers
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Apple MCP Server
Enables interaction with Apple apps like Messages, Notes, and Contacts through the MCP protocol to send messages, search, and open app content using natural language.
Tavily MCP Server
Provides AI-powered web search capabilities using Tavily's search API, enabling LLMs to perform sophisticated web searches, get direct answers to questions, and search recent news articles.
mixpanel
Connect to your Mixpanel data. Query events, retention, and funnel data from Mixpanel analytics.
Linear MCP Server
A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.
Sequential Thinking MCP Server
This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.
mcp-shodan
MCP server for querying the Shodan API and Shodan CVEDB. This server provides tools for IP lookups, device searches, DNS lookups, vulnerability queries, CPE lookups, and more.
mcp-pinterest
A Pinterest Model Context Protocol (MCP) server for image search and information retrieval