
aiogram-mcp
io.github.Py2755由 GitHub 帳號 Py2755 發布v0.7.1更新於 Oct 25, 2026
MCP server for aiogram Telegram bots — 30 tools, 7 resources, 3 prompts, event streaming
概覽
把現有的 aiogram Telegram 機器人變成 MCP 伺服器,讓 AI 助理能傳訊息、管理聊天室並回應事件。
- 可以做什麼
- 傳送、轉發、刪除和置頂訊息,以及照片、文件、語音、影片、貼圖、投票、聯絡人和位置,並可建立帶按鈕的內嵌鍵盤、編輯訊息和回應按鈕回呼。查詢機器人、聊天室和成員資訊、成員數量及使用者頭像。管理聊天室:封鎖或解除封鎖使用者,修改聊天室標題和說明。訂閱以 MCP 通知推送的即時 Telegram 事件,並可選擇向多個聊天室廣播。讀取機器人資訊、設定、聊天室清單、訊息歷史、事件佇列、檔案中繼資料和稽核日誌等資源,並使用審核、公告和使用者報告提示詞。
- 適用情境
- 適合已經運行 aiogram 機器人、希望讓 Claude Desktop 等 AI 用戶端操作同一個機器人的情境:收發訊息、執行審核、發布公告,或建立互動式按鈕流程,而不需改寫處理函式。
- 執行需求
- 以本機 stdio 程序與機器人一起啟動(需要 Python 3.10+ 和 aiogram 3.20+,可透過 pip 或 uvx 安裝)。需要 Telegram Bot API 權杖,透過 BOT_TOKEN 環境變數提供,並在機器人程式碼中加入中介層和 MCP 伺服器。需要連線到 Telegram 的網路。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 aiogram-mcp,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
aiogram-mcp
[CI] [Python 3.10+] [License: MIT] [PyPI version] [MCP Registry]
Connect your Telegram bot to AI agents via the Model Context Protocol.
aiogram-mcp turns any aiogram bot into an MCP server. AI clients like Claude Desktop can then send messages, read chat history, build interactive menus, and react to events in real time — all through your existing bot, without rewriting a single handler.
Why aiogram-mcp?
Most Telegram MCP servers are thin wrappers with 3-5 tools. aiogram-mcp goes further:
- 30 tools — messaging, rich media, moderation, interactive keyboards, event subscriptions, broadcasting
- 7 resources — bot info, config, chat lists, message history, event queue, file metadata, audit log
- 3 prompts — ready-made moderation, announcement, and user report workflows
- Structured output — every tool returns typed Pydantic models with
outputSchemafor programmatic parsing - Real-time events — the bot pushes Telegram events to AI clients via MCP notifications (no polling)
- Interactive messages — AI agents create inline keyboard menus, handle button presses, edit messages
- Rate limiting — built-in token bucket prevents Telegram 429 errors
- Permission levels — restrict AI agents to read-only, messaging, moderation, or full admin access
- Audit logging — track every tool invocation with timestamps and arguments
- Zero rewrite — add 5 lines to your existing bot, keep all your handlers
How It Works
The bot runs normally for Telegram users. The MCP server runs alongside it, giving AI agents access to the same bot via tools and resources.
Installation
Requires Python 3.10+ and aiogram 3.20+.
Quickstart
1. Add aiogram-mcp to your bot
2. Connect Claude Desktop
Add to your claude_desktop_config.json:
Now Claude can send messages, read history, create button menus, and react to events in your Telegram bot.
Built-in Tools
Messaging (5 tools)
Interactive Messages (3 tools)
Users (3 tools)
Chats (6 tools)
Rich Media (10 tools)
Events (2 tools)
Broadcast (1 tool, opt-in)
MCP Resources
Read-only data that AI agents can access without calling tools:
MCP Prompts
Pre-built workflows that give AI agents structured context:
Real-time Event Streaming
AI agents don't need to poll. The bot pushes events automatically:
The AI agent calls subscribe_events once, then receives push notifications whenever new events match its filters.
Interactive Messages
AI agents can build full interactive UIs in Telegram — menus, confirmations, multi-step wizards:
The AI agent sends a message with buttons:
User taps a button → event appears in the queue → AI agent reacts:
The bot needs dp.callback_query.middleware(middleware) to capture button presses.
Safety Controls
allowed_chat_ids— AI can only interact with listed chats. Default: all chats.enable_broadcast— broadcast tool is disabled by default as a safety measure.max_broadcast_recipients— caps the number of chats in a single broadcast.
Advanced Configuration
Rate Limiting
Built-in token bucket rate limiter prevents Telegram 429 errors. All outgoing API calls are automatically paced.
Permission Levels
Audit Log
Every tool invocation is logged. Access via telegram://audit/log resource.
Examples
Development
License
MIT. See LICENSE.
來源:README.md,提交 a5ae934
工具
0版本歷史
1- v0.7.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分