A Simple Python MCP Solution
Project description
aiomcp
A Simple Python MCP Solution
Mission of aiomcp
A smooth start experience.
Tutorial
Expected Behavior for Version 0.1.0
A simple McpServer
def func(a: int, b: int):
return a + b
impl = ToolImpl()
mcp_server = McpServer("mcp-server-name")
await mcp_server.register_tool(func)
await mcp_server.register_tool(impl.method, alias="tool_alias")
await mcp_server.register_tool(ToolImpl.class_method)
await mcp_server.host("http://127.0.0.1:8000/mcp")
A simple McpClient
mcp_client = McpClient("mcp-client-name")
await mcp_client.initialize("http://127.0.0.1:8000/mcp")
# await mcp_client.initialize(McpHttpTransport("127.0.0.1", 8000, "/mcp"))
# await mcp_client.initialize(McpStdioClientTransport([sys.executable, "server.py"]))
# await mcp_client.initialize(mcp_server) for quick testing without hosting a server
sum_value = await mcp_client.invoke("name", {"a": 1, "b": 2})
# standard MCP functions
# await mcp_client.mcp_tools_list() -> list[McpTool]
# await mcp_client.mcp_tools_call(tool: McpTool, request: McpRequest) -> McpResponse | McpError
Using McpTransports
While McpClient and McpServer handle client/server behavior, they are implemented in a platform-agnostic way by using McpClientTransport/McpServerTransport to handle message streams. Client and server transports usually come in pairs as McpTransport implementations.
mcp_server = McpServer()
await mcp_server.host(McpHttpTransport("127.0.0.1", 8000, "/mcp"))
# await mcp_server.host("http://127.0.0.1:8000/mcp")
mcp_client = McpClient()
await mcp_client.initialize(McpHttpTransport("127.0.0.1", 8000, "/mcp"))
# await mcp_client.initialize("http://127.0.0.1:8000/mcp")
Supported McpTransport implementations:
McpDirectTransport: Simple client driven transport that invokesMcpServerwith minimal MCP protocol overhead.McpMemoryTransport: Single event loop, in-memory transport.McpHttpTransportMcpStdioClientTransport/McpStdioServerTransport: stdio based transport
Sample: Using McpMemoryTransport for local debugging.
transport = McpMemoryTransport()
mcp_server = McpServer()
asyncio.create_task(mcp_server.host(transport))
mcp_client = McpClient()
await mcp_client.initialize(transport)
Project details
Release history Release notifications | RSS feed
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 aiomcp-0.0.6.tar.gz.
File metadata
- Download URL: aiomcp-0.0.6.tar.gz
- Upload date:
- Size: 22.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90067ef95cce58a84e600e24066378d98812ee7c1601890b6bfac7a221aa89bb
|
|
| MD5 |
b1118b8413933d0b535cb60d22607252
|
|
| BLAKE2b-256 |
7b5c30ed48460dd3c34219de00ee2b263d9002c948cc85ba8895785352dd808c
|
Provenance
The following attestation bundles were made for aiomcp-0.0.6.tar.gz:
Publisher:
publish.yml on yangyuan/aiomcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiomcp-0.0.6.tar.gz -
Subject digest:
90067ef95cce58a84e600e24066378d98812ee7c1601890b6bfac7a221aa89bb - Sigstore transparency entry: 724303448
- Sigstore integration time:
-
Permalink:
yangyuan/aiomcp@31ca0484501bafce566c1b1049d07af50df84c41 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/yangyuan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@31ca0484501bafce566c1b1049d07af50df84c41 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file aiomcp-0.0.6-py3-none-any.whl.
File metadata
- Download URL: aiomcp-0.0.6-py3-none-any.whl
- Upload date:
- Size: 22.1 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 |
49da33bf6fa54c72191bb13f286a25387e1ff169fa101c1aaccad492106acf01
|
|
| MD5 |
50c3f344a3c71cbad7b6b354378454e6
|
|
| BLAKE2b-256 |
ede7de33d2de04a7689892b935cafc91995c2e1281619ba07acaf2d057f11fdd
|
Provenance
The following attestation bundles were made for aiomcp-0.0.6-py3-none-any.whl:
Publisher:
publish.yml on yangyuan/aiomcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiomcp-0.0.6-py3-none-any.whl -
Subject digest:
49da33bf6fa54c72191bb13f286a25387e1ff169fa101c1aaccad492106acf01 - Sigstore transparency entry: 724303457
- Sigstore integration time:
-
Permalink:
yangyuan/aiomcp@31ca0484501bafce566c1b1049d07af50df84c41 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/yangyuan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@31ca0484501bafce566c1b1049d07af50df84c41 -
Trigger Event:
workflow_dispatch
-
Statement type: