tdlib-mcp-server
Provides tools for interacting with Telegram via the official TDLib library, enabling AI agents to manage chats, messages, and user profiles.
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., "@tdlib-mcp-serverlist my recent dialogs"
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.
tdlib-mcp-server
Open-source MCP server that connects AI agents to Telegram via the official TDLib (Telegram Database Library).
Unlike other Telegram MCP servers (GramJS, Telethon), this uses the official C++ library via Python ctypes. Your account is treated as an official client (like Telegram Desktop) — no unofficial client flags.
Features
Tool | Description |
| Get current authorized user profile |
| List chats with basic info |
| Convert @username to chat info |
| Get detailed chat/channel/group info |
| Get messages from a chat (newest first) |
| Get a single message by ID |
| Search messages in a specific chat |
| Search messages across all chats |
Related MCP server: agent-telegram-mcp
Quick Start
# 1. Clone
git clone https://github.com/Crocodile-beep/tdlib_mcp_server.git
cd tdlib_mcp_server
# 2. Create venv
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# 3. Configure API credentials
cp .env.example .env
# Edit .env with your api_id, api_hash from https://my.telegram.org/apps
# 4. First-time auth
python test_auth.py
# Enter the code sent to Telegram
# 5. Run MCP server
python main.pyMCP Client Configuration
Add to your opencode.jsonc:
{
"mcp": {
"tdlib": {
"type": "local",
"command": ["./venv/bin/python", "-u", "./main.py"],
"enabled": true
}
}
}For other MCP clients (Claude Desktop, etc.), point them to python /path/to/tdlib-mcp-server/main.py.
Architecture
┌──────────────┐ queue.Queue ┌──────────────────┐
│ asyncio │ ──────────────────>│ TDLib Thread │
│ MCP Server │ │ libtdjson.so │
│ (main.py) │ <──────────────────│ (tdlib_client) │
│ │ asyncio.Future │ │
└──────────────┘ └──────────────────┘Python 3.14 — MCP stdio transport via
mcpSDKTDLib 1.8.57 — compiled
libtdjson.soinlib/ctypes — direct C function calls, no bindings
SQLite — session data stored in
data/tdlib/(managed by TDLib)
Roadmap
list_messages_date_range— filter messages by dateError handling — FLOOD_WAIT retry, reconnection
More tools as needed
License
MIT — fully open source, use it freely.
This server cannot be deployed
Maintenance
Related MCP Connectors
Telegram bridge for your MCP-compatible agent. Bidirectional, no LLM in our stack.
Multi-tenant Telegram gateway for AI agents — HTTP+stdio, 8 tools, MTProto User API
Run a Telegram channel from your AI agent. Posts go out through your own bot, not your account.
Connect AI agents to 1000+ apps with managed authentication and tool-calling.
Related MCP Servers
- FlicenseAqualityDmaintenanceEnables AI agents to interact with Telegram via MTProto, supporting high-performance communication and seamless integration.1-
- AlicenseAqualityDmaintenanceEnables AI agents to send and receive messages, media, and files on Telegram, and manage chats via a bot token.1720 PyPIMIT
- 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 agents to operate a Telegram account through the same commands as the terminal client: messaging, chat management, voice transcription, calls, stickers, and privacy settings.1MIT