MCP server middleware for aiogram Telegram bots — expose your bot to AI agents via the Model Context Protocol
Project description
aiogram-mcp
MCP server middleware for aiogram Telegram bots.
aiogram-mcp lets you expose an existing aiogram bot to MCP clients such as Claude Desktop without rewriting handlers, routers, or business logic.
Status
Beta — the core API is stable but may change before 1.0.
Installation
pip install aiogram-mcp
Requirements:
- Python 3.10+
- aiogram 3.20+
Quickstart
from aiogram import Bot, Dispatcher
from aiogram_mcp import AiogramMCP
bot = Bot(token="YOUR_BOT_TOKEN")
dp = Dispatcher()
# Register your normal handlers here.
mcp = AiogramMCP(bot=bot, dp=dp)
await mcp.run_alongside_bot(transport="stdio")
Available transports:
stdiofor Claude Desktop and local MCP clientsssefor remote HTTP-based MCP connections
Built-in Tools
Messaging:
send_messagesend_photoforward_messagedelete_messagepin_message
Users:
get_bot_infoget_chat_member_infoget_user_profile_photos
Chats:
get_chat_infoget_chat_members_countban_userunban_userset_chat_titleset_chat_description
Broadcast:
broadcastwhenenable_broadcast=True
Safety Controls
mcp = AiogramMCP(
bot=bot,
dp=dp,
name="my-bot",
allowed_chat_ids=[123456789, -1001234567890],
enable_broadcast=True,
max_broadcast_recipients=500,
)
Use MCPMiddleware to track recent chats and build recipient lists:
from aiogram_mcp import AiogramMCP, MCPMiddleware
tracker = MCPMiddleware()
dp.message.middleware(tracker)
mcp = AiogramMCP(bot=bot, dp=dp, enable_broadcast=True)
Development
pip install -e ".[dev]"
ruff check aiogram_mcp tests examples
mypy aiogram_mcp
pytest -v
Project layout:
aiogram_mcp/package sourcetests/unit testsexamples/runnable usage examples.github/workflows/ci.ymlGitHub Actions pipeline
Examples
License
MIT. See LICENSE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiogram_mcp-0.1.0.tar.gz.
File metadata
- Download URL: aiogram_mcp-0.1.0.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6d0899b9ec5e5587ecc104174a5436787fc60d9d20dcb72fc0525a3e0366891
|
|
| MD5 |
8aeabe185d8e4b9a4be8f54d49827560
|
|
| BLAKE2b-256 |
7981732dc7c24ce5784bd74e32b38242a6013ede8e4cac8011f11bf5786960cc
|
Provenance
The following attestation bundles were made for aiogram_mcp-0.1.0.tar.gz:
Publisher:
publish.yml on Py2755/aiogram-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiogram_mcp-0.1.0.tar.gz -
Subject digest:
d6d0899b9ec5e5587ecc104174a5436787fc60d9d20dcb72fc0525a3e0366891 - Sigstore transparency entry: 1057191886
- Sigstore integration time:
-
Permalink:
Py2755/aiogram-mcp@2ee033396fc101c6f5ea411886853baec072a245 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Py2755
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2ee033396fc101c6f5ea411886853baec072a245 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aiogram_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aiogram_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbfbc9c229b422beda191265725c7e85d5e8a582179429dfc19e822b28a0eed5
|
|
| MD5 |
48d508977e28708d621280c48e2b2b35
|
|
| BLAKE2b-256 |
7271efa499657d9161a8daedc3268f5f8483ef209c92f91475c5689994d3599c
|
Provenance
The following attestation bundles were made for aiogram_mcp-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Py2755/aiogram-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiogram_mcp-0.1.0-py3-none-any.whl -
Subject digest:
bbfbc9c229b422beda191265725c7e85d5e8a582179429dfc19e822b28a0eed5 - Sigstore transparency entry: 1057191941
- Sigstore integration time:
-
Permalink:
Py2755/aiogram-mcp@2ee033396fc101c6f5ea411886853baec072a245 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Py2755
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2ee033396fc101c6f5ea411886853baec072a245 -
Trigger Event:
push
-
Statement type: