Cover image
Try Now
2025-04-03

3 years

Works with Finder

1

Github Watches

0

Github Forks

0

Github Stars

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 (for npx installation)
  • Telegram API credentials (api_id and api_hash)
  • A Telegram account

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/telegram-MCP-server.git
cd telegram-MCP-server
  1. Install required dependencies:
uv venv .venv  # Create a virtual environment
source .venv/bin/activate  # Activate it (Linux/macOS)
.\venv\Scripts\activate  # Activate it (Windows)
uv pip install

  1. Create a .env file in the project root with your Telegram credentials:
TG_API_ID=your_api_id
TG_API_HASH=your_api_hash
phone=your_phone_number  # Format: +1234567890

Integration with Cursor/Claude Desktop

Copy the below json with the appropriate {{PATH}} values:

{
  "mcpServers": {
    "whatsapp": {
      "command": "{{PATH_TO_UV}}", // Run `which uv` and place the output here
      "args": [
        "--directory",
        "{{PATH_TO_SRC}}/whatsapp-mcp/whatsapp-mcp-server", // cd into the repo, run `pwd` and enter the output here + "/whatsapp-mcp-server"
        "run",
        "main.py"
      ]
    }
  }
}

For Claude, save this as claude_desktop_config.json in your Claude Desktop configuration directory at:

~/Library/Application Support/Claude/claude_desktop_config.json

For Cursor, save this as mcp.json in your Cursor configuration directory at:

~/.cursor/mcp.json

Tool Documentation

get_contacts()

Returns a list of all your Telegram contacts with their names, phone numbers, and usernames.

send_message_by_identifier(identifier: str, message: str)

Sends a message to a contact identified by either their name or phone number.

  • identifier: Contact's name or phone number
  • message: Text message to send

get_last_interaction(identifier: str)

Returns the most recent message exchanged with a specific contact.

  • identifier: Contact's name or phone number

get_chat_history(identifier: str, start_date: str = None, end_date: str = None, limit: int = 20)

Retrieves chat history with a contact within a specified timeframe.

  • identifier: Contact's name or phone number
  • start_date: Optional start date (YYYY-MM-DD)
  • end_date: Optional end date (YYYY-MM-DD)
  • limit: Maximum number of messages to return

get_channel_posts(channel_name: str, start_date: str = None, end_date: str = None, limit: int = 20)

Gets posts from a Telegram channel.

  • channel_name: Channel username or name
  • start_date: Optional start date (YYYY-MM-DD)
  • end_date: Optional end date (YYYY-MM-DD)
  • limit: Maximum number of posts to return

Error Handling

The server includes comprehensive error handling for:

  • Invalid credentials
  • Network issues
  • Rate limiting
  • Invalid parameters
  • Permission errors

Security Considerations

  • Store API credentials securely
  • Never share your .env file
  • Use environment variables in production
  • Implement rate limiting for production use
  • Monitor usage and implement logging

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

  • Telethon library for Telegram API integration
  • FastMCP for the server framework

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://reddgr.com
  • Delivers concise Python code and interprets non-English comments

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

  • ravitemer
  • 一个功能强大的Neovim插件,用于管理MCP(模型上下文协议)服务器

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • patruff
  • Ollama和MCP服务器之间的桥梁,使本地LLMS可以使用模型上下文协议工具

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

    Reviews

    1 (1)
    Avatar
    user_zT0SWXwc
    2025-04-17

    telegram-mcp-server by wolderufael is a fantastic tool for seamless integration with Telegram. It simplifies the process of managing multiple bot interactions, making it incredibly efficient and user-friendly. The clear documentation and active support community enhance the overall experience. Highly recommended for any developer looking to leverage Telegram bots effectively! Check it out at https://github.com/wolderufael/telegram-mcp-server.