BM

braindao/mcp-telegram

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

8 stars 6 forks 质量 65 趋势 20

Model Context Protocol Server for interacting with Telegram Channels

概览

An MCP (Model Context Protocol) server for interacting with Telegram bots and channels using the Telegraf library. This server enables AI agents to send messages, manage channels, forward content, and respond intelligently to Telegram conversations. By implementing the Model Context Protocol (MCP), this server allows Large Language Models (LLMs) to interact with Telegram directly through their context window, bridging the gap between AI and messaging platforms. * : Send messages to channels or chats with optional topic support * : Get information about channels/chats * : Forward messages between chats * : Pin messages in channels * : Get list of channel administrators * : AI-powered responses using FastMCP sampling * : Smart filtering - responds when mentioned in groups * : Supports text, photos, documents, voice, video, stickers, locations, contacts, polls * : Configurable user/chat allow/block lists * : Per-user and per-chat rate limiting * : Highly customizable behavior and...

README

以下为原文 README 节选,完整内容请查看原文。

Telegram MCP Server

Overview

An MCP (Model Context Protocol) server for interacting with Telegram bots and channels using the Telegraf library. This server enables AI agents to send messages, manage channels, forward content, and respond intelligently to Telegram conversations.

By implementing the Model Context Protocol (MCP), this server allows Large Language Models (LLMs) to interact with Telegram directly through their context window, bridging the gap between AI and messaging platforms.

Features

Core Tools

  • SEND_MESSAGE: Send messages to channels or chats with optional topic support
  • GET_CHANNEL_INFO: Get information about channels/chats
  • FORWARD_MESSAGE: Forward messages between chats
  • PIN_MESSAGE: Pin messages in channels
  • GET_CHANNEL_MEMBERS: Get list of channel administrators

AI Sampling (Enhanced)

  • Intelligent Responses: AI-powered responses using FastMCP sampling
  • Mention-Only Mode: Smart filtering - responds when mentioned in groups
  • Multi-Message Types: Supports text, photos, documents, voice, video, stickers, locations, contacts, polls
  • Access Control: Configurable user/chat allow/block lists
  • Rate Limiting: Per-user and per-chat rate limiting
  • Advanced Configuration: Highly customizable behavior and templates

Installation

To use this server without installing it globally:

npx @iqai/mcp-telegram

Build from Source

git clone https://github.com/IQAIcom/mcp-telegram.git
cd mcp-telegram
pnpm install
pnpm run build

Running with an MCP Client

Add the following configuration to your MCP client settings (e.g., claude_desktop_config.json).

Minimal Configuration

{
  "mcpServers": {
    "telegram": {
      "command": "npx",
      "args": ["-y", "@iqai/mcp-telegram"],
      "env": {
        "TELEGRAM_BOT_TOKEN": "your_bot_token_here"
      }
    }
  }
}

Advanced Configuration (Local Build)

{
  "mcpServers": {
    "telegram": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-telegram/dist/index.js"],
      "env": {
        "TELEGRAM_BOT_TOKEN": "your_bot_token_here",
        "SAMPLING_ENABLED": "true",
        "SAMPLING_MENTION_ONLY": "true"
      }
    }
  }
}

Configuration (Environment Variables)

Required

Variable Required Description
TELEGRAM_BOT_TOKEN Yes Your Telegram bot token from @BotFather

Sampling Configuration

Variable Default Description
SAMPLING_ENABLED true Enable/disable AI sampling entirely
SAMPLING_MENTION_ONLY true Only respond when mentioned in groups
在 GitHub 查看完整 README

安装

npx -y @iqai/mcp-telegram
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "telegram": { "command": "npx", "args": ["-y", "@iqai/mcp-telegram"], "env": { "TELEGRAM_BOT_TOKEN": "your_bot_token_here" } } } }