Skip to main content

Add your description here

Project description

EasyMCP

EasyMCP is a complete rewrite of the model context protocol (MCP) in Python.

Installation

uv add easymcp

Usage

The high level API exposes a ClientManager class that can be used to manage multiple MCP servers.

import asyncio
from easymcp.client.ClientManager import ClientManager
from easymcp.client.transports.stdio import StdioServerParameters

mgr = ClientManager()

searxng = StdioServerParameters(
    command="uvx",
    args=["mcp-searxng"],
)

timeserver = StdioServerParameters(
    command="uvx",
    args=["mcp-timeserver"],
)

servers = {
    "searxng": searxng,
    "timeserver": timeserver,
}

async def main():
    # initialize the client manager
    await mgr.init(servers=servers)

    # list servers
    print(mgr.list_servers())

    # remove a server
    await mgr.remove_server("searxng")

    # add a server
    await mgr.add_server("searxng", searxng)

    # list tools - these are namespaced by server name automatically
    # {server name}.{tool name}
    print(await mgr.list_tools())

    # call tool
    print(await mgr.call_tool("timeserver.get-current-time", {}))

    # list resources - these are namespaced by server name automatically
    # mcp-{server name}+{resource uri}
    print(await mgr.list_resources())

    # read resource
    print(await mgr.read_resource("mcp-timeserver+datetime://Africa/Algiers/now"))

    await asyncio.Future()

asyncio.run(main())

Core Features

  • list tools/resources/prompts caching out of the box
  • automatic cache invalidation on tool/resource/prompt change notifications
  • out of the box support for parallel requests to servers
  • full lifecycle management of servers
  • dynamic server addition/removal
  • namespaced tools/resources/prompts
  • lightweight asyncio native implementation

Why namespace tools?

Namespaced tools remove need to perform a lookup to find the correct tool. This means:

  • faster tool calls
  • tool calls can be routed across many MCP hosts at scale
  • mcp servers do not need globally unique tool names

Why namespace resources?

Resources are namespaced in a way that makes it easy to make a resource URI to a specific server. You can:

  • check if a URL needs to be resolved via mcp by checking if it starts with mcp
  • check what server to resolve the URI with
  • ingest resources into a search system like elastic search without having to store metadata about the server
  • completely eliminate the need to map URIs to servers via a database or lookup table

Comparison of classes to other MCP libraries

easyMCP modelcontextprotocol/python-sdk
ClientManager manages multiple MCP servers
ClientSession ClientSession manages a single MCP server
StdioTransport stdio_client raw subprocess transport

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

easymcp-0.3.0.tar.gz (32.8 kB view details)

Uploaded Source

Built Distribution

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

easymcp-0.3.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file easymcp-0.3.0.tar.gz.

File metadata

  • Download URL: easymcp-0.3.0.tar.gz
  • Upload date:
  • Size: 32.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.18

File hashes

Hashes for easymcp-0.3.0.tar.gz
Algorithm Hash digest
SHA256 11cc4ebe021971b3c4cee65082312558977b4b9728a34967520b3cc74649e512
MD5 4249cbd660f1ae8f1c68b29fe3a32719
BLAKE2b-256 83a51516d78463328068f5071418227ac63a7e28062d4ea21e51de464d42e34b

See more details on using hashes here.

File details

Details for the file easymcp-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: easymcp-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.18

File hashes

Hashes for easymcp-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6e0600b22471e7cb1a98429f447b5cbfd00b4faaf20ba7a8111d9a9ba83f9a31
MD5 ec9f1c0061d321279d463f4af8f85a40
BLAKE2b-256 ec77f72ed88555a34612e9d081550bc47a3e942f9cc23d3ce9da3704ff4c16aa

See more details on using hashes here.

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