tdlib-mcp-server
Provides tools for interacting with Telegram via the official TDLib library, enabling AI agents to manage chats, messages, and user profiles.
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.
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.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
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
Let AI assistants post to your Telegram chats, groups and channels. Not affiliated with Telegram.
WhatsApp and Telegram for AI agents, behind a policy gateway. OAuth or access key.
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.1737 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.2MIT
- AlicenseNot gradedqualityBmaintenanceEnables 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