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 "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., "@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: 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 installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- 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/Crocodile-beep/tdlib_mcp_server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server