telegram-mcp

telegram-mcp

An MCP server that enables interaction with Telegram to send, read, and search messages across chats and dialogs. It supports waiting for incoming messages and retrieving conversation history through natural language commands.

Category
访问服务器

README

telegram-mcp

A Model Context Protocol (MCP) server for interacting with Telegram using mtcute.

Features

  • Send text messages to chats
  • Wait for incoming messages in specific chats
  • Read messages from chats
  • Search messages
  • List and get information about dialogs (chats)
  • Get recent messages across all chats

Setup

Installation

Option 1: Download Pre-built Binary

Download the latest release for your platform from the releases page:

  • macOS (Apple Silicon): telegram-mcp-darwin-arm64.tar.gz
  • macOS (Intel): telegram-mcp-darwin-x64.tar.gz
  • Linux: telegram-mcp-linux-x64.tar.gz
  • Windows: telegram-mcp-win-x64.exe.zip

Extract the archive and make the binary executable (Unix systems):

tar -xzf telegram-mcp-*.tar.gz
chmod +x telegram-mcp

Option 2: Build from Source

  1. Clone the repository and install dependencies:

    git clone git@github.com:zhigang1992/telegram-mcp.git
    cd telegram-mcp
    bun install
    
  2. Build the executable:

    bun run build
    

Initial Setup (First Time Only)

  1. Get your Telegram API credentials from https://my.telegram.org

  2. Run the initial setup to authenticate with Telegram:

    export API_ID=your_api_id
    export API_HASH=your_api_hash
    ./telegram-mcp
    

    The server will:

    • Prompt you to enter your phone number
    • Send you a verification code via Telegram
    • Ask for the verification code
    • Display the absolute storage path (you'll need this for MCP configuration)
  3. Note the storage path displayed in the output. It will look something like:

    Storage path: /Users/username/telegram-mcp/bot-data/session
    

Usage

As an MCP Server

Add to your Claude Desktop config using the storage path from the initial setup:

{
  "mcpServers": {
    "telegram": {
      "command": "/path/to/telegram-mcp",
      "env": {
        "API_ID": "your_api_id",
        "API_HASH": "your_api_hash",
        "TELEGRAM_STORAGE_PATH": "/absolute/path/from/initial/setup"
      }
    }
  }
}

Important: The TELEGRAM_STORAGE_PATH must be the absolute path shown during initial setup. This ensures the MCP server uses the authenticated session.

Available Tools

Message Tools

  • messages_sendText - Send a text message to a chat

    • chatId (required): Chat/User ID or username
    • text (required): Message text to send
    • replyToMessageId: Optional message ID to reply to
  • messages_getHistory - Get message history from a chat

    • chatId (required): Chat/User ID or username
    • limit: Number of messages (default: 100, max: 100)
    • offsetId: Message ID for pagination
  • messages_search - Search for messages

    • query (required): Search query
    • chatId: Specific chat to search in (optional)
    • limit: Number of results (default: 50)
  • messages_getRecent - Get recent messages from all chats

    • limit: Number of chats (default: 10)
    • messagesPerChat: Messages per chat (default: 10)

Interactive Tools

  • wait_for_reply - Wait for the next message in a chat
    • chatId (required): Chat/User ID or username to wait for a message from
    • timeoutSeconds: Timeout in seconds (default: 60, max: 300)

Dialog Tools

  • dialogs_list - List all dialogs

    • limit: Maximum dialogs (default: 50)
    • filter: Filter options (onlyUsers, onlyGroups, onlyChannels)
  • dialogs_getInfo - Get detailed dialog information

    • chatId (required): Chat/User ID or username

Development

Run in development mode:

bun run dev

The server stores session data in bot-data/ directory.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选