Skip to main content

MCP server with Telegram search and messaging capabilities

Project description

Hero image

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

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
📊 Enterprise Session Management Zero-downtime deployments with automatic backup/restore and health monitoring
👥 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
🎯 AI-Optimized Literal parameter constraints and LLM-friendly API design
🌍 Web Setup Interface Browser-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 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

🔒 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:

  1. Fork the repository
  2. Read the Contributing Guide
  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 LICENSE 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fast_mcp_telegram-0.8.0.tar.gz (58.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fast_mcp_telegram-0.8.0-py3-none-any.whl (59.0 kB view details)

Uploaded Python 3

File details

Details for the file fast_mcp_telegram-0.8.0.tar.gz.

File metadata

  • Download URL: fast_mcp_telegram-0.8.0.tar.gz
  • Upload date:
  • Size: 58.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fast_mcp_telegram-0.8.0.tar.gz
Algorithm Hash digest
SHA256 8a9b625cdcbec764ca61f035ab0ecb1ec01c2a950d6b16ed637ec99a64293a13
MD5 bbd1356f2ae78d6c1a86607fe1222912
BLAKE2b-256 d8f3bc29e6c61831bfff0662e6b59035340634dcba9c1c4b4f237ff38073d740

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_mcp_telegram-0.8.0.tar.gz:

Publisher: publish.yml on leshchenko1979/fast-mcp-telegram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_mcp_telegram-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fast_mcp_telegram-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db7e4fa465d05e00e0d49d084af7d9ef2955b3a67a9e752cf70327f49b4f722a
MD5 f8cbc0296c857c10cfb0561fef9acd49
BLAKE2b-256 cd0138912364d7a42b02107a75d5097cdbc3f85577395f1a198928ad4bc8844f

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_mcp_telegram-0.8.0-py3-none-any.whl:

Publisher: publish.yml on leshchenko1979/fast-mcp-telegram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page