Enable LLMs to control your Telegram
Connect Large Language Models to Telegram via the Model Context Protocol (MCP).
Built with Telethon, this server allows AI agents to interact with Telegram, enabling features like sending/editing/deleting messages, searching chats, managing drafts, downloading media, and more using the MTProto.
🚀 Getting Started
Prerequisites
- Python 3.10 or higher
uvInstall via the official uv guide.
Installation
Install the mcp-telegram CLI tool:
uv tool install mcp-telegram
⚙️ Usage
The mcp-telegram command-line tool is your entry point.
mcp-telegram --help # See all commands
Login
First, authenticate with your Telegram account:
mcp-telegram login
This interactive command will prompt you for:
- API ID & API Hash: Obtain these from my.telegram.org/apps.
- Phone Number: Your Telegram-registered phone number (international format, e.g.,
+1234567890). - Verification Code: Sent to your Telegram account upon first login.
- 2FA Password: If you have Two-Factor Authentication enabled.
Your credentials are securely stored in the session file for future use.
Connect to the MCP server
To use MCP Telegram with MCP clients like Claude Desktop or Cursor, you'll need to configure the MCP server. The configuration process varies by client and operating system.
For detailed setup instructions, please refer to:
The configuration file should contain:
{
"mcpServers": {
"mcp-telegram": {
"command": "mcp-telegram" /* Use full path if client can't find the command (e.g. "/usr/local/bin/mcp-telegram"). See IMPORTANT section below for full path instructions. */,
"args": ["start"],
"env": {
"API_ID": "<your_api_id>",
"API_HASH": "<your_api_hash>"
}
}
}
}
After saving the configuration file, restart your application.
🧰 Available Tools
Here's a comprehensive list of tools you can use to interact with Telegram through MCP:
📨 Messaging Tools
| Tool | Description |
|---|---|
send_message |
✉️ Send text messages or files to any user, group, or channel |
edit_message |
✏️ Modify content of previously sent messages |
delete_message |
🗑️ Remove one or multiple messages |
get_messages |
📜 Retrieve message history with advanced filtering options |
🔍 Search & Navigation
| Tool | Description |
|---|---|
search_dialogs |
🔎 Find users, groups, and channels by name or username |
message_from_link |
🔗 Access specific messages using Telegram links |
📝 Draft Management
| Tool | Description |
|---|---|
get_draft |
📋 View current message draft for any chat |
set_draft |
✍️ Create or clear message drafts |
📂 Media Handling
| Tool | Description |
|---|---|
media_download |
📸 Download photos, videos, and documents from messages |
🛠️ Troubleshooting
Database Locked Errors
Running multiple mcp-telegram instances using the same session file can cause database is locked errors due to Telethon's SQLite session storage. Ensure only one instance uses a session file at a time.
Force-Stopping Existing Processes
If you need to stop potentially stuck processes:
- macOS / Linux:
pkill -f "mcp-telegram" - Windows:
taskkill /F /IM mcp-telegram.exe /T(Check Task Manager for the exact process name)
🤝 Contributing
We welcome contributions! If you'd like to help improve MCP Telegram, please feel free to submit issues, feature requests, or pull requests. Your feedback and contributions help make this project better for everyone.
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by Yeabsira Driba
Metadata
Release files for mcp-telegram 0.1.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mcp_telegram-0.1.11.tar.gz | 1.5 MB | Without provenance | Details for mcp_telegram-0.1.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcp_telegram-0.1.11-py3-none-any.whl | Python 3 | none | any | Details for mcp_telegram-0.1.11-py3-none-any.whl |
Total release size: 1.5 MB
Release files / mcp_telegram-0.1.11.tar.gz
| Download URL | mcp_telegram-0.1.11.tar.gz |
|---|---|
| Size | 1.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e4955b194d147989d3534cd53c72a79660ab27c5a053143af8ad04441da8824
|
|
BLAKE2b-256 checksum How to use checksums |
014d3b29110cd928594eee6e75a69098c01a48e9d24ba19c9637bf8612b94fb9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.16
|
Release files / mcp_telegram-0.1.11-py3-none-any.whl
| Download URL | mcp_telegram-0.1.11-py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
09197d925e065eb16958baa937384c6051fc98bcaf27f9c24bd32eaf9d79944d
|
|
BLAKE2b-256 checksum How to use checksums |
3ba1147491b1ffe7c6bc368e43400de99b020cee845273cc5d609c4beab54bc9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.16
|
Security for mcp-telegram 0.1.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.