MCP Telegram Server
An MCP server for interacting with Telegram. It allows searching, sending messages, and managing chats using the Telegram API.
Fast MCP Telegram Server - Production-ready Telegram integration for AI assistants with comprehensive search, messaging, and direct API access capabilities.
π Demo
- Open https://tg-mcp.redevest.ru/setup to begin the authentication flow.
- After finishing, you'll receive a ready-to-use
mcp.jsonwith your Bearer token. - Use the config with your MCP client to check out this MCP server capabilities.
- Or try the HTTPβMTProto Bridge right away with curl (replace TOKEN):
curl -X POST "https://tg-mcp.redevest.ru/mtproto-api/messages.SendMessage" \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-d '{"params": {"peer": "me", "message": "Hello from Demo!"}}'
π Table of Contents
- β¨ Features
- π Quick Start
- ποΈ Server Modes
- π HTTP-MTProto Bridge
- π Documentation
- π Security
- π€ Contributing
- π License
β¨ Features
| Feature | Description |
|---|---|
| π Multi-User Authentication | Production-ready Bearer token auth with session isolation and LRU cache management |
| π HTTP-MTProto Bridge | Direct curl access to any Telegram API method with entity resolution and safety guardrails |
| π Intelligent Search | Global & per-chat message search with multi-query support and intelligent deduplication |
| ποΈ Dual Transport | Seamless development (stdio) and production (HTTP) deployment support |
| π Secure File Handling | Rich media sharing with SSRF protection, size limits, and album support |
| π¬ Advanced Messaging | Send, edit, reply with formatting, file attachments, and phone number messaging |
| π€ Voice Transcription | Automatic speech-to-text for Premium accounts with parallel processing and polling |
| π Unified Session Management | Single configuration system for setup and server, with multi-account support |
| π₯ Smart Contact Discovery | Search users, groups, channels with uniform entity schemas and profile enrichment |
| β‘ High Performance | Async operations, parallel queries, connection pooling, and memory optimization |
| π‘οΈ Production Reliability | Auto-reconnect, structured logging, comprehensive error handling with clear actionable messages |
| π― AI-Optimized | Literal parameter constraints, LLM-friendly API design, and MCP ToolAnnotations |
| π Web Setup Interface | Browser-based authentication flow with immediate config generation |
π οΈ Available Tools
| Tool | Purpose | Key Features |
|---|---|---|
search_messages_globally | Search across all chats | Multi-term queries, date filtering, chat type filtering |
search_messages_in_chat | Search within specific chat | Supports "me" for Saved Messages, optional query for latest messages |
send_message | Send new message | File attachments (URLs/local), formatting (markdown/html), replies |
edit_message | Edit existing message | Text formatting, preserves message structure |
read_messages | Read specific messages by ID | Batch reading, full message content, voice transcription for Premium accounts |
find_chats | Find users/groups/channels | Multi-term search, contact discovery, username/phone lookup |
get_chat_info | Get detailed profile info | Member counts, bio/about, online status, enriched data |
send_message_to_phone | Message phone numbers | Auto-contact management, optional cleanup, file support |
invoke_mtproto | Direct Telegram API access | Raw MTProto methods, entity resolution, safety guardrails |
π For detailed tool documentation with examples, see Tools Reference
π Quick Start
1. Install from PyPI
pip install fast-mcp-telegram
2. Authenticate with Telegram
fast-mcp-telegram-setup --api-id="your_api_id" --api-hash="your_api_hash" --phone-number="+123456789"
π Prefer a browser? Run the server and open /setup to authenticate and download a readyβtoβuse mcp.json. You can also reauthorize existing sessions through the same interface.
3. Configure Your MCP Client
STDIO Mode (Development with Cursor IDE):
{
"mcpServers": {
"telegram": {
"command": "fast-mcp-telegram",
"env": {
"API_ID": "your_api_id",
"API_HASH": "your_api_hash",
"PHONE_NUMBER": "+123456789"
}
}
}
}
HTTP_AUTH Mode (Production with Bearer Token):
{
"mcpServers": {
"telegram": {
"url": "https://your-server.com",
"headers": {
"Authorization": "Bearer AbCdEfGh123456789KLmnOpQr..."
}
}
}
}
4. Start Using!
{"tool": "search_messages_globally", "params": {"query": "hello", "limit": 5}}
{"tool": "send_message", "params": {"chat_id": "me", "message": "Hello from AI!"}}
π For detailed installation instructions, see Installation Guide
ποΈ Server Modes
| Mode | Transport | Authentication | Use Case |
|---|---|---|---|
| STDIO | stdio | Disabled | Development with Cursor IDE |
| HTTP_NO_AUTH | HTTP | Disabled | Development HTTP server |
| HTTP_AUTH | HTTP | Required (Bearer token) | Production deployment |
π HTTP-MTProto Bridge
Direct curl access to any Telegram API method - Execute any Telegram MTProto method via HTTP requests with automatic entity resolution and safety guardrails.
Quick Examples
# Send message with automatic entity resolution
curl -X POST "https://your-domain.com/mtproto-api/messages.SendMessage" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"params": {"peer": "@username", "message": "Hello from curl!"},
"resolve": true
}'
# Send message using params_json (works with n8n and other tools)
curl -X POST "https://your-domain.com/mtproto-api/messages.SendMessage" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"params_json": "{\"peer\": \"@username\", \"message\": \"Hello from curl!\"}",
"resolve": true
}'
# Get message history with peer resolution
curl -X POST "https://your-domain.com/mtproto-api/messages.getHistory" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"params": {"peer": "me", "limit": 10},
"resolve": true
}'
π For complete MTProto Bridge documentation, see MTProto Bridge Guide
π Documentation
- Installation Guide - Detailed installation and configuration
- Deployment Guide - Docker deployment and production setup
- Tools Reference - Complete tools documentation with examples
- Search Guidelines - Search best practices and limitations
- Operations Guide - Health monitoring and troubleshooting
- Project Structure - Code organization and architecture
- Contributing Guide - Development setup and contribution guidelines
π Security
Key Security Features:
- Bearer token authentication with session isolation
- SSRF protection for file downloads
- Dangerous method blocking with opt-in override
- Session file security and automatic cleanup
π For complete security information, see SECURITY.md
π€ Contributing
We welcome contributions! Please see our Contributing Guide for:
- Development setup instructions
- Testing guidelines
- Code quality standards
- Pull request process
Quick Start for Contributors:
- Fork the repository
- Read the Contributing Guide
- Create a feature branch
- Make your changes and add tests
- Submit a pull request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- FastMCP - MCP server framework
- Telethon - Telegram API library
- Model Context Protocol - Protocol specification
Made with β€οΈ for the AI automation community
β Star us on GitHub β’ π¬ Join our community
mcp-name: io.github.leshchenko1979/fast-mcp-telegram
Related Servers
Slack MCP Server
An MCP server for interacting with Slack workspaces using user tokens, without requiring bots or special permissions.
EMQX MCP Server
Interact with an EMQX MQTT broker via a Model Context Protocol (MCP) server.
ELEMENT.FM
Create and publish unlimited podcast shows and episodes with ELEMENT.FM
RocketMQ
A server for interacting with Apache RocketMQ, a distributed messaging and streaming platform, requiring environment variables for configuration.
Didlogic MCP Server
Interact with the Didlogic API for telecommunication services, including virtual phone numbers and SMS.
MCP Server Whisper
Advanced audio transcription and processing using OpenAI's Whisper and GPT-4o models.
Kokoro TTS
A server that provides text-to-speech capabilities using the Kokoro TTS engine.
Reddit
Interact with Reddit by posting comments and searching for posts.
MailerLite MCP server
Turn AI tools into your email marketing assistant.
WhatsApp MCP server by Kapso
WhatsApp Cloud API MCP server by Kapso