Skip to main content

A Simple Python MCP Solution

Project description

aiomcp

A Simple Python MCP Solution

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("tool_1", func)
await mcp_server.register_tool("tool_2", impl.method)
await mcp_server.register_tool("tool_3", 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")
# mcp_client = mcp_client.initialize("server.py") for stdio
# mcp_client = mcp_client.initialize(mcp_server) for quick testing without hosting 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_client = McpClient()
await mcp_client.initialize(McpHttpTransport("127.0.0.1", 8000))

Supported McpTransport implementations:

  • McpDirectTransport: Simple client driven transport that invokes McpServer with minimal MCP protocol overhead.
  • McpMemoryTransport: Single event loop, in-memory transport.
  • McpHttpTransport
  • McpStdioTransport
  • McpSocksTransport

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.2.tar.gz (12.2 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.2-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aiomcp-0.0.2.tar.gz
  • Upload date:
  • Size: 12.2 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.2.tar.gz
Algorithm Hash digest
SHA256 2334e34a60be9ca5ae31ae63e577cebef5c57a77a204a71a7abb24a6c377a208
MD5 ed9e07d5d5452ecb3a27f46beef2853c
BLAKE2b-256 e7168b1a97af353cc8b5bff73179a560920eb7456e9526fb34c9c59fd60a26b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiomcp-0.0.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: aiomcp-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7a8e1f28cddfbf4392755df7b592d0645bfe83ecd1b9b05b72d4ff4ef2a4fd3a
MD5 75726bd5102692b50d1e40fc993cf4c9
BLAKE2b-256 6fd46adbbdae0c2120f975d96bdfb886644d5a5d54518929c2f29ecd20a61307

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiomcp-0.0.2-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