Skip to main content

The simplest way to build and connect MCP servers and clients.

Project description

MCPeasy

The simplest way to build and connect MCP (Model Context Protocol) servers and clients in Python.

No async. No boilerplate. Just define your tools and go.

Install

pip install mcpeasy

Quickstart

Build a server

from mcpeasy import MCPServer

server = MCPServer("my-server")

@server.tool
def get_weather(city: str) -> str:
    """Get the current weather for a city."""
    return f"Sunny in {city}, 22C"

@server.tool
def calculate(expression: str) -> str:
    """Evaluate a math expression."""
    return str(eval(expression))

server.run()              # stdio (default)
server.run(mode="sse")    # SSE on http://0.0.0.0:8000

Connect a client

from mcpeasy import MCPClient

# SSE — server already running
with MCPClient.from_sse("http://localhost:8000/sse") as client:
    tools  = client.list_tools()
    result = client.call_tool("get_weather", {"city": "Tokyo"})
    print(result)

# stdio — client spawns the server
with MCPClient.from_stdio("python", ["server.py"]) as client:
    tools  = client.list_tools()
    result = client.call_tool("calculate", {"expression": "12 * 7"})
    print(result)

Use with any LLM

list_tools() returns raw MCP format — convert to your LLM's format yourself:

from mcpeasy import MCPClient

with MCPClient.from_sse("http://localhost:8000/sse") as client:
    tools = client.list_tools()
    # tools → [{ "name", "description", "parameters" }]

    # Anthropic
    anthropic_tools = [{"name": t["name"], "description": t["description"], "input_schema": t["parameters"]} for t in tools]

    # OpenAI
    openai_tools = [{"type": "function", "function": {"name": t["name"], "description": t["description"], "parameters": t["parameters"]}} for t in tools]

    # when LLM picks a tool:
    result = client.call_tool(tool_name, params)

API

MCPServer

Method Description
MCPServer(name) Create a server
@server.tool Register a function as a tool
server.run(mode, host, port) Start the server (mode="stdio" or "sse")

MCPClient

Method Description
MCPClient.from_sse(url) Create client for remote SSE server
MCPClient.from_stdio(command, args) Create client for local stdio server
client.connect() Open connection
client.disconnect() Close connection
client.list_tools() Get all tools from server
client.call_tool(name, params) Call a tool, get result as string
client.tool_info(name) Get details of one tool

Transport modes

stdio SSE
Where Same machine Anywhere
Server startup Client spawns it Already running
Connect with from_stdio(cmd, args) from_sse(url)
Best for Local tools Remote / shared servers

License

MIT

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

mcpsdk-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

mcpsdk-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file mcpsdk-0.1.0.tar.gz.

File metadata

  • Download URL: mcpsdk-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for mcpsdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4cdab7296a48ef78ff221100449e24223ed9f93d253fdb479cee0e5ab7257e96
MD5 cb081c41a29d41db6258c6b978a51c0f
BLAKE2b-256 496f370bfa093163a52f2cd7df00719fda401b6d0f373d562565ba106ad3a181

See more details on using hashes here.

File details

Details for the file mcpsdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mcpsdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for mcpsdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 692982c8f557548a68a35550ffcec2a76b2edf07b1f422283ad85e81761d07a7
MD5 15e6e02e633e04b2b4353c2128689a84
BLAKE2b-256 02c8994c1f8ca1b8513cca404372c422c8f560495b0cfb743d9e26a1c023acf5

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