telegram-mcp-server
The Telegram MCP Server is a robust integration server for managing Telegram contacts, messages, and channels using the Multi-Client Protocol (MCP). It supports contact management, messaging, and channel operations with features such as chat history retrieval and message sending. Secure handling of credentials and error management are integral to the server's operations.
Telegram MCP Server
A powerful Telegram integration server that provides various tools for managing contacts, sending messages, and retrieving channel information through MCP (Multi-Client Protocol).
Features
- Contact Management
- Get list of contacts
- Search contacts
- Get last interactions
- Messaging
- Send messages to contacts by name or phone number
- Get chat history with date range filtering
- View last interactions
- Channel Features
- Get posts from channels
- Search channels
- View channel information
- Filter posts by date range
Prerequisites
- Python 3.8 or higher
- Node.js 14 or higher
- Telegram API credentials
- A Telegram account
Installation
- Clone the repository
- Install required dependencies
- Get Telegram API ID and API Hash
- Create a
.env
file with Telegram credentials - Authenticate Telegram
Tool Documentation
- get_contacts()
- send_message_by_identifier(identifier, message)
- get_last_interaction(identifier)
- get_chat_history(identifier, start_date=None, end_date=None, limit=20)
- get_channel_posts(channel_name, start_date=None, end_date=None, limit=20)
Error Handling
Comprehensive error handling for invalid credentials, network issues, rate limiting, invalid parameters, and permission errors.
Security Considerations
Store API credentials securely, use environment variables, implement rate limiting, monitor usage, and logging.
Contributing
- Fork the repository
- Create a feature branch
- Commit changes
- Push to the branch
- Create a Pull Request
License
Licensed under MIT.