fast-mcp-telegram

leshchenko1979/fast-mcp-telegram

3.4

If you are the rightful owner of fast-mcp-telegram and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

MCP Telegram Server is a robust implementation using FastMCP, offering Telegram functionalities through a streamlined API, including search and messaging capabilities.

Tools
5
Resources
0
Prompts
0

Python Version License: MIT Docker Ready

Fast MCP Telegram Server - Production-ready Telegram integration for AI assistants with comprehensive search, messaging, and direct API access capabilities.

๐ŸŒ Demo

  1. Open https://tg-mcp.redevest.ru/setup to begin the authentication flow.
  2. After finishing, you'll receive a ready-to-use mcp.json with your Bearer token.
  3. Use the config with your MCP client to check out this MCP server capabilities.
  4. 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

FeatureDescription
๐Ÿ” Multi-User AuthenticationProduction-ready Bearer token auth with session isolation and LRU cache management
๐ŸŒ HTTP-MTProto BridgeDirect curl access to any Telegram API method with entity resolution and safety guardrails
๐Ÿ” Intelligent SearchGlobal & per-chat message search with multi-query support and intelligent deduplication
๐Ÿ—๏ธ Dual TransportSeamless development (stdio) and production (HTTP) deployment support
๐Ÿ“ Secure File HandlingRich media sharing with SSRF protection, size limits, and album support
๐Ÿ’ฌ Advanced MessagingSend, edit, reply with formatting, file attachments, and phone number messaging
๐Ÿ“Š Enterprise Session ManagementZero-downtime deployments with automatic backup/restore and health monitoring
๐Ÿ‘ฅ Smart Contact DiscoverySearch users, groups, channels with uniform entity schemas and profile enrichment
โšก High PerformanceAsync operations, parallel queries, connection pooling, and memory optimization
๐Ÿ›ก๏ธ Production ReliabilityAuto-reconnect, structured logging, comprehensive error handling
๐ŸŽฏ AI-OptimizedLiteral parameter constraints and LLM-friendly API design
๐ŸŒ Web Setup InterfaceBrowser-based authentication flow with immediate config generation

๐Ÿš€ 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.

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

๐Ÿ—๏ธ Server Modes

ModeTransportAuthenticationUse Case
STDIOstdioDisabledDevelopment with Cursor IDE
HTTP_NO_AUTHHTTPDisabledDevelopment HTTP server
HTTP_AUTHHTTPRequired (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

๐Ÿ“š Documentation

  • - Detailed installation and configuration
  • - Docker deployment and production setup
  • - Complete tools documentation with examples
  • - Search best practices and limitations
  • - Health monitoring and troubleshooting
  • - Code organization and architecture
  • - 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

๐Ÿค Contributing

We welcome contributions! Please see our for:

  • Development setup instructions
  • Testing guidelines
  • Code quality standards
  • Pull request process

Quick Start for Contributors:

  1. Fork the repository
  2. Read the
  3. Create a feature branch
  4. Make your changes and add tests
  5. Submit a pull request

๐Ÿ“„ License

This project is licensed under the MIT License - see the file for details.

๐Ÿ™ Acknowledgments


Made with โค๏ธ for the AI automation community

โญ Star us on GitHub โ€ข ๐Ÿ’ฌ Join our community


mcp-name: io.github.leshchenko1979/fast-mcp-telegram