Skip to main content

aiohttp-mcp-server

A framework to easily make production-grade MCP servers for AI agents.

Installation

pip install aiohttp-mcp-server

Usage

import aiohttp_mcp_server as mcp
from aiohttp import web

async def get_weather(location: str) -> str:
    """Get current weather information for a location."""
    return f"Sunny in {location}."

app = web.Application()
mcp.setup(app, tools=mcp.ToolRegistry(get_weather))
web.run_app(app, handler_cancellation=True)

This serves the MCP endpoint at /mcp. This can be added to any existing aiohttp web application, or used as a standalone one as above.

Note that it is especially recommended to enable handler cancellation for MCP servers, but you should read the documentation first to understand the impact it has on your handlers: https://docs.aiohttp.org/en/stable/web_advanced.html#web-handler-cancellation

Remote servers and auth

A server exposed on the internet needs two additions: the domain added to allowed_origins, and an authorization configuration. MCP uses OAuth 2.1, and aiohttp-mcp-server ships everything needed for it out of the box (including an authorization server) so a complete, working deployment is:

import os
import secrets

import aiohttp_mcp_server as mcp
from aiohttp import web

async def check_credentials(username: str, password: str, request: web.Request) -> bool:
    return username == "admin" and secrets.compare_digest(
        password, os.environ["MCP_PASSWORD"]
    )

app = web.Application()
mcp.setup(
    app,
    allowed_origins=("mcp.server.example",),
    authorization=mcp.LocalAuthorization(
        check_credentials,
        resource="https://mcp.server.example",
        secret=bytes.fromhex(os.environ["MCP_TOKEN_KEY"]),
    ),
)
web.run_app(app, handler_cancellation=True)

LocalAuthorization makes the application its own OAuth 2.1 authorization server, with the credential check as the only deployment-specific part. Larger deployments with multiple users should use Authorization to connect to an established OAuth server instead.

Metadata

Release files for aiohttp-mcp-server 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiohttp-mcp-server 0.1.0
File Size Uploaded Provenance Actions
aiohttp_mcp_server-0.1.0.tar.gz 132.5 kB With provenance Details for aiohttp_mcp_server-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aiohttp-mcp-server 0.1.0
File Interpreter ABI Platform Actions
aiohttp_mcp_server-0.1.0-py3-none-any.whl Python 3 none any Details for aiohttp_mcp_server-0.1.0-py3-none-any.whl

Total release size: 206.9 kB

Release files / aiohttp_mcp_server-0.1.0.tar.gz

Download URL aiohttp_mcp_server-0.1.0.tar.gz
Size 132.5 kB
Tags Source
SHA-256 checksum
How to use checksums
41ea5affbbcedb6d37bd3493995cb539fdd4c7a63cb1c57024c8af5ea548e760
BLAKE2b-256 checksum
How to use checksums
3dd0bbb934f3c5e4ba12788ed82892bf9420bb162f05a7cf69f080a4e2555dfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Release files / aiohttp_mcp_server-0.1.0-py3-none-any.whl

Download URL aiohttp_mcp_server-0.1.0-py3-none-any.whl
Size 74.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3bc5bc1c29892fe0279f79c3ede28814b72c94f7ec6be81d6cc8bea7ad8806ad
BLAKE2b-256 checksum
How to use checksums
fbc73d13fa12864c5b32926e06ea3e93a7d8739b61f8e8a918b1badbe7daeecb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Security for aiohttp-mcp-server 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aiohttp_mcp_server-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page