
A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

A Python library that implements the MCP protocol natively to help you build Model Context Protocol servers on top of aiohttp applications.
aiohttp-mcp: MCP server tools for aiohttp is cataloged as an MCP server attributed to kulapard. A Python library that implements the MCP protocol natively to help you build Model Context Protocol servers on top of aiohttp applications. It is categorized under developer tools. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.
Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.
Catalog license label: MIT License. Check the source repository's current license and terms before using, modifying or distributing this software.
能力定义尚未审核。未核验的采集内容不会作为可信接口展示。
暂无可展示的已审核记录。这不表示上游不支持此能力。
暂无可展示的已审核记录。这不表示上游不支持此能力。
暂无可展示的已审核记录。这不表示上游不支持此能力。
Email delivery is not connected. This page does not collect email addresses or create subscriptions.
Browse the registry for current listings instead.
Reviews for aiohttp-mcp: MCP server tools for aiohttp are not available yet
Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.
Yes, tools can read registered resources by URI via ctx.read_resource, which avoids duplicating logic.
Tools can return Pydantic BaseModel or dataclass instances, which are serialized to JSON and generate outputSchema in tools/list responses.
README.md · dc2ede008ea3 · 采集于 2026-11-13 10:22:10 UTC
保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。
当前显示最后一次成功采集的文档快照,请以来源页面为准。
Tools for building Model Context Protocol (MCP) servers on top of aiohttp.
Implements the MCP protocol natively — no heavy SDK dependencies. Only 3 runtime dependencies: aiohttp, aiohttp-sse, pydantic.
ctx.app and per-request data via ctx.requestWith uv package manager:
uv add aiohttp-mcp
Or with pip:
pip install aiohttp-mcp
Create a simple MCP server with a custom tool:
import datetime
from zoneinfo import ZoneInfo
from aiohttp import web
from aiohttp_mcp import AiohttpMCP, build_mcp_app
# Initialize MCP
mcp = AiohttpMCP()
# Define a tool
@mcp.tool()
def get_time(timezone: str) -> str:
"""Get the current time in the specified timezone."""
tz = ZoneInfo(timezone)
return datetime.datetime.now(tz).isoformat()
# Create and run the application
app = build_mcp_app(mcp, path="/mcp")
web.run_app(app)
You can also use aiohttp-mcp as a sub-application in your existing aiohttp server:
import datetime
from zoneinfo import ZoneInfo
from aiohttp import web
from aiohttp_mcp import AiohttpMCP, setup_mcp_subapp
mcp = AiohttpMCP()
# Define a tool
@mcp.tool()
def get_time(timezone: str) -> str:
"""Get the current time in the specified timezone."""
tz = ZoneInfo(timezone)
return datetime.datetime.now(tz).isoformat()
# Create your main application
app = web.Application()
# Add MCP as a sub-application
setup_mcp_subapp(app, mcp, prefix="/mcp")
web.run_app(app)
By default, the server runs in stateless mode — each request creates a fresh transport, making it safe for load-balanced and multi-instance deployments. Tool notifications (ctx.info()) work inline via SSE POST responses.
For single-instance deployments that need server-initiated push (via GET SSE stream) or SSE resumability, enable stateful mode. Session state and events are stored in-process memory — this is not suitable for multi-instance deployments without sticky sessions.
from aiohttp_mcp import AiohttpMCP, InMemoryEventStore, build_mcp_app
# Stateful with resumability (single instance only)
# If client disconnects, it can reconnect with Last-Event-ID to replay missed events
mcp = AiohttpMCP(event_store=InMemoryEventStore())
app = build_mcp_app(mcp, path="/mcp", stateless=False)
Note:
InMemoryEventStoreis in-process only. For multi-instance stateful deployments, implement a customEventStorebacked by shared storage (e.g., Redis) and use sticky sessions.
There are 3 ways to access the MCP context inside tools. All return the same Context object:
1. get_current_context() — module function
from aiohttp_mcp import get_current_context
@mcp.tool()
async def my_tool(query: str) -> str:
ctx = get_current_context()
user_id = ctx.request.headers.get("X-User-ID", "anonymous")
await ctx.info(f"Query by {user_id}")
return f"Result for {user_id}"
2. mcp.get_context() — instance method
@mcp.tool()
async def my_tool(query: str) -> str:
ctx = mcp.get_context()
user_id = ctx.request.headers.get("X-User-ID", "anonymous")
return f"Result for {user_id}"
3. ctx: Context — parameter injection
Declare ctx: Context as a parameter — it's auto-injected and excluded from the tool's input schema:
from aiohttp_mcp import Context
@mcp.tool()
async def my_tool(query: str, ctx: Context) -> str:
user_id = ctx.request.headers.get("X-User-ID", "anonymous")
return f"Result for {user_id}"
Context capabilities:
ctx.request — aiohttp Request (headers, cookies, client IP)ctx.app — aiohttp Application for shared state (ctx.app["db_pool"])ctx.request_id — JSON-RPC request IDawait ctx.info(msg) / debug() / warning() / error() — send log to clientawait ctx.report_progress(progress, total) — report progressawait ctx.read_resource(uri) — read a registered resourceShared state via ctx.app:
from collections.abc import AsyncIterator
from aiohttp import web
from aiohttp_mcp import AiohttpMCP, build_mcp_app, get_current_context
mcp = AiohttpMCP()
@mcp.tool()
async def secure_query(sql: str) -> str:
"""Run a database query with auth validation."""
ctx = get_current_context()
db_pool = ctx.app["db_pool"]
return await db_pool.query(sql)
async def startup(app: web.Application) -> AsyncIterator[None]:
app["db_pool"] = await create_db_pool()
yield
await app["db_pool"].close()
app = build_mcp_app(mcp, path="/mcp")
app.cleanup_ctx.append(startup)
Tools can read registered resources during execution via ctx.read_resource(uri), avoiding logic duplication:
from aiohttp_mcp import AiohttpMCP, get_current_context
mcp = AiohttpMCP()
@mcp.resource("config://{service}")
async def get_config(service: str) -> str:
"""Service configuration exposed as a resource."""
return load_config(service)
@mcp.tool()
async def deploy(service: str) -> str:
"""Deploy a service using its registered config."""
ctx = get_current_context()
config = await ctx.read_resource(f"config://{service}")
return f"Deployed {service} with {config}"
This calls back into the resource registry using the same URI that MCP clients use — tools only need the URI, not a direct reference to the resource function.
Tools can return Pydantic BaseModel or dataclass instances — they are automatically serialized to JSON and generate outputSchema in tools/list responses:
import dataclasses
from pydantic import BaseModel
from aiohttp_mcp import AiohttpMCP
mcp = AiohttpMCP()
@dataclasses.dataclass
class UserData:
name: str
email: str
age: int = 25
class UserResult(BaseModel):
id: str
name: str
email: str
@mcp.tool()
async def create_user(data: UserData) -> UserResult:
"""Create a new user."""
# Input: dataclass validated from dict/JSON automatically
# Output: BaseModel serialized to JSON, outputSchema auto-generated
return UserResult(id="123", name=data.name, email=data.email)
Plain types (str, dict, list) continue to serialize as before. outputSchema is generated for any return type annotation — BaseModel and dataclass return values additionally get proper JSON serialization via Pydantic's TypeAdapter instead of str().
Here's how to create a client that interacts with the MCP server using the mcp client library:
import asyncio
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
async def main():
# Connect to the MCP server
async with streamablehttp_client("http://localhost:8080/mcp") as (
read_stream,
write_stream,
_,
):
async with ClientSession(read_stream, write_stream) as session:
# Initialize the session
await session.initialize()
# List available tools
tools = await session.list_tools()
print("Available tools:", [tool.name for tool in tools.tools])
# Call a tool
result = await session.call_tool("get_time", {"timezone": "UTC"})
print("Current time in UTC:", result.content)
if __name__ == "__main__":
asyncio.run(main())
For more examples, check the examples directory.
git clone https://github.com/kulapard/aiohttp-mcp.git
cd aiohttp-mcp
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv sync --all-extras
uv run pytest
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
Claim this server with your GitHub account to request manual ownership verification.
Link to the catalog listing for aiohttp-mcp: MCP server tools for aiohttp from your README. This badge does not certify ownership, compatibility or security.
[](https://awesome-mcp.com/servers/aiohttp-mcp)Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.
来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。
尚无已审核的包 / 镜像标识,暂不展示下载统计。
Alternative and complementary servers in the same category

A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

A hosted MCP service for browsing and searching through Singapore mobile-network proxies.

A directory listing describing a Markdown-to-PDF service. The configured public GitHub repository returned 404 during source verification.