Sponsored by Deepsite.site

Mcp Telegram

Created By
dryeab8 months ago
MCP Server for Telegram
Content
MCP Telegram Logo

Enable LLMs to control your Telegram

GitHub stars PyPI version PyPI Downloads Twitter Follow

Connect Large Language Models to Telegram via the Model Context Protocol (MCP).

Built with Telethon, this server allows AI agents to interact with Telegram, enabling features like sending/editing/deleting messages, searching chats, managing drafts, downloading media, and more using the MTProto.


Table of Contents

🚀 Getting Started

Prerequisites

Installation

Install the mcp-telegram CLI tool:

uv tool install mcp-telegram

⚙️ Usage

IMPORTANT

Please ensure you have read and understood Telegram's ToS before using this tool. Misuse of this tool may result in account restrictions.

The mcp-telegram command-line tool is your entry point.

mcp-telegram --help # See all commands

Login

First, authenticate with your Telegram account:

mcp-telegram login

This interactive command will prompt you for:

  • API ID & API Hash: Obtain these from my.telegram.org/apps.
  • Phone Number: Your Telegram-registered phone number (international format, e.g., +1234567890).
  • Verification Code: Sent to your Telegram account upon first login.
  • 2FA Password: If you have Two-Factor Authentication enabled.

Your credentials are securely stored in the session file for future use.

WARNING

Keep your API credentials private and never share them publicly

NOTE

Use mcp-telegram logout to logout from current session or mcp-telegram clear-session to remove all stored session data.

Connect to the MCP server

To use MCP Telegram with MCP clients like Claude Desktop or Cursor, you'll need to configure the MCP server. The configuration process varies by client and operating system.

For detailed setup instructions, please refer to:

The configuration file should contain:

{
  "mcpServers": {
    "mcp-telegram": {
      "command": "mcp-telegram" /* Use full path if client can't find the command (e.g. "/usr/local/bin/mcp-telegram"). See IMPORTANT section below for full path instructions. */,
      "args": ["start"],
      "env": {
        "API_ID": "<your_api_id>",
        "API_HASH": "<your_api_hash>"
      }
    }
  }
}

NOTE

Configuration paths vary by OS and client. For example:

  • macOS: ~/Library/Application Support/Claude/ or ~/.cursor/
  • Windows: %APPDATA%\Claude\ or %APPDATA%\Cursor\

IMPORTANT

If your client cannot execute mcp-telegram despite it being accessible in the terminal, try using the full path to the executable. You can find this by running which mcp-telegram (macOS/Linux) or where mcp-telegram (Windows) in your terminal. Replace the command value in the configuration with the full path.

After saving the configuration file, restart your application.

🧰 Available Tools

Here's a comprehensive list of tools you can use to interact with Telegram through MCP:

📨 Messaging Tools

ToolDescription
send_message✉️ Send text messages or files to any user, group, or channel
edit_message✏️ Modify content of previously sent messages
delete_message🗑️ Remove one or multiple messages
get_messages📜 Retrieve message history with advanced filtering options

🔍 Search & Navigation

ToolDescription
search_dialogs🔎 Find users, groups, and channels by name or username
message_from_link🔗 Access specific messages using Telegram links

📝 Draft Management

ToolDescription
get_draft📋 View current message draft for any chat
set_draft✍️ Create or clear message drafts

📂 Media Handling

ToolDescription
media_download📸 Download photos, videos, and documents from messages

NOTE

For detailed parameter information and example use cases, run mcp-telegram tools in your terminal.

🛠️ Troubleshooting

Database Locked Errors

Running multiple mcp-telegram instances using the same session file can cause database is locked errors due to Telethon's SQLite session storage. Ensure only one instance uses a session file at a time.

Force-Stopping Existing Processes

If you need to stop potentially stuck processes:

  • macOS / Linux: pkill -f "mcp-telegram"
  • Windows: taskkill /F /IM mcp-telegram.exe /T (Check Task Manager for the exact process name)

🤝 Contributing

We welcome contributions! If you'd like to help improve MCP Telegram, please feel free to submit issues, feature requests, or pull requests. Your feedback and contributions help make this project better for everyone.

📝 License

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


Made with ❤️ by Yeabsira Driba

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Playwright McpPlaywright MCP server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
WindsurfThe new purpose-built IDE to harness magic
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Tavily Mcp
Serper MCP ServerA Serper MCP Server
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Amap Maps高德地图官方 MCP Server
DeepChatYour AI Partner on Desktop
ChatWiseThe second fastest AI chatbot™
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
CursorThe AI Code Editor
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.