Skip to main content

MCP server middleware for aiogram Telegram bots — expose your bot to AI agents via the Model Context Protocol

Project description

aiogram-mcp

CI Python 3.10+ License: MIT PyPI version

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:

  • stdio for Claude Desktop and local MCP clients
  • sse for remote HTTP-based MCP connections

Built-in Tools

Messaging:

  • send_message
  • send_photo
  • forward_message
  • delete_message
  • pin_message

Users:

  • get_bot_info
  • get_chat_member_info
  • get_user_profile_photos

Chats:

  • get_chat_info
  • get_chat_members_count
  • ban_user
  • unban_user
  • set_chat_title
  • set_chat_description

Broadcast:

  • broadcast when enable_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 source
  • tests/ unit tests
  • examples/ runnable usage examples
  • .github/workflows/ci.yml GitHub 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

aiogram_mcp-0.1.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiogram_mcp-0.1.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

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

Hashes for aiogram_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d6d0899b9ec5e5587ecc104174a5436787fc60d9d20dcb72fc0525a3e0366891
MD5 8aeabe185d8e4b9a4be8f54d49827560
BLAKE2b-256 7981732dc7c24ce5784bd74e32b38242a6013ede8e4cac8011f11bf5786960cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiogram_mcp-0.1.0.tar.gz:

Publisher: publish.yml on Py2755/aiogram-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for aiogram_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bbfbc9c229b422beda191265725c7e85d5e8a582179429dfc19e822b28a0eed5
MD5 48d508977e28708d621280c48e2b2b35
BLAKE2b-256 7271efa499657d9161a8daedc3268f5f8483ef209c92f91475c5689994d3599c

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiogram_mcp-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Py2755/aiogram-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page