Skip to main content

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 invokes McpServer with minimal MCP protocol overhead.
  • McpMemoryTransport: Single event loop, in-memory transport.
  • McpHttpTransport
  • McpStdioClientTransport / 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiomcp-0.0.5.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

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

aiomcp-0.0.5-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file aiomcp-0.0.5.tar.gz.

File metadata

  • Download URL: aiomcp-0.0.5.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiomcp-0.0.5.tar.gz
Algorithm Hash digest
SHA256 91e7cb67807b6e02da7b747cbd502551f569434fb9b092215771c01f499b4a54
MD5 77d76ba22aaa0b036b116a3324064b3b
BLAKE2b-256 6b6060eacbbab9987b1eb1ee77106a8e02a24d9effb8f5f128b4755709d1082b

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiomcp-0.0.5.tar.gz:

Publisher: publish.yml on yangyuan/aiomcp

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

File details

Details for the file aiomcp-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: aiomcp-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiomcp-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e8ac0a9892a77c20c62f31d330e73bac46bfa9a953c012b4dce2754f6926629f
MD5 5365c2f585e4c39d65842de7a0ff5cb5
BLAKE2b-256 5101c63113272d384ecc8fefbddf736577038fe72da2eaa537b0ec7c7bb03726

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiomcp-0.0.5-py3-none-any.whl:

Publisher: publish.yml on yangyuan/aiomcp

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