aiohttp-mcp-client
MCP (Model Context Protocol) client built on top of aiohttp. Supports the Streamable HTTP transport.
Features
- Async context manager with automatic initialize/terminate lifecycle
- Supports both JSON and SSE response modes
- Accepts an external
aiohttp.ClientSessionfor integration into existing apps - Typed result objects (frozen dataclasses)
- Only 1 runtime dependency:
aiohttp
Installation
pip install aiohttp-mcp-client
Or with uv:
uv add aiohttp-mcp-client
Quick Start
import asyncio
from aiohttp_mcp_client import MCPClient
async def main():
async with MCPClient("http://localhost:8080/mcp") as client:
# List available tools
tools = await client.list_tools()
for tool in tools:
print(f" {tool.name}: {tool.description}")
# Call a tool
result = await client.call_tool("my_tool", {"arg": "value"})
for block in result.content:
print(block.text)
asyncio.run(main())
Notification callbacks
The server can send log messages and progress updates during tool calls. You can handle these with async callbacks — set defaults at client level, or override per call:
from aiohttp_mcp_client import MCPClient, LogMessage, Progress
async def on_log(msg: LogMessage) -> None:
print(f"[{msg.level}] {msg.data}")
async def on_progress(msg: Progress) -> None:
pct = f"{msg.progress}/{msg.total}" if msg.total else f"{msg.progress}"
print(f"Progress: {pct}")
async def main():
# Client-level defaults
async with MCPClient(url, on_log=on_log, on_progress=on_progress) as client:
result = await client.call_tool("slow_task", {"steps": 10})
# Per-call override
result = await client.call_tool("other_task", on_log=my_other_handler)
Using an existing aiohttp session
import aiohttp
from aiohttp_mcp_client import MCPClient
async def main():
async with aiohttp.ClientSession() as session:
async with MCPClient("http://localhost:8080/mcp", session=session) as client:
tools = await client.list_tools()
API
MCPClient(url, *, session=None, client_info=None, on_log=None, on_progress=None)
url— MCP server endpoint URLsession— Optionalaiohttp.ClientSession(one is created if not provided)client_info— Optional{"name": "...", "version": "..."}dicton_log— Default async callback forLogMessagenotificationson_progress— Default async callback forProgressnotifications
Methods
| Method | Description |
|---|---|
list_tools() |
List available tools |
call_tool(name, arguments) |
Call a tool |
list_resources() |
List available resources |
read_resource(uri) |
Read a resource by URI |
list_resource_templates() |
List resource templates |
list_prompts() |
List available prompts |
get_prompt(name, arguments) |
Get a prompt by name |
ping() |
Send a ping |
All methods except ping() accept optional on_log and on_progress keyword arguments to override the client-level defaults for that call.
Future Plans
- Automatic pagination helpers (fetch all pages)
Requirements
- Python 3.11+
- aiohttp >= 3.9.0
Development
uv venv && source .venv/bin/activate
uv sync --all-extras
make test
make lint
License
Metadata
Release files for aiohttp-mcp-client 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| aiohttp_mcp_client-0.0.3.tar.gz | 12.4 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiohttp_mcp_client-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.3 kB
Release files / aiohttp_mcp_client-0.0.3.tar.gz
| Download URL | aiohttp_mcp_client-0.0.3.tar.gz |
|---|---|
| Size | 12.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aebd706a624d8326ecba2909e69c4b11e5eb94b6d508ad3d8202bb101f6dddb5
|
|
BLAKE2b-256 checksum How to use checksums |
ac04f983a0e7587fd55851330f7386a2f725a3c7d84061a6cd5dbbc00b7dd1a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Apr 14, 2026.
Transparency logRelease files / aiohttp_mcp_client-0.0.3-py3-none-any.whl
| Download URL | aiohttp_mcp_client-0.0.3-py3-none-any.whl |
|---|---|
| Size | 13.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d706bbd9335aa8d74fbc02e71c61867328f9c44dae8be6bfddab46332800e12c
|
|
BLAKE2b-256 checksum How to use checksums |
3ae5978870f9f6a6fffa9c924ac328df013711fb3514bf54960ab2b781309487
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Apr 14, 2026.
Transparency logSecurity for aiohttp-mcp-client 0.0.3
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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for aiohttp_mcp_client-0.0.3.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 Apr 14, 2026.
Transparency logA 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.