Skip to main content

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

Project description

MCPSDK

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.1.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.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcpsdk-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 7d3df960be14c7e436732e9467780d959e390dc9faf0a59de2cecadd82c0f7dd
MD5 4d8dc075eb993fa89f7026a5fff0fa03
BLAKE2b-256 93ec087622aa03fecfedf73f1c2271757654b2e7e961390da4b3c9b0fa5580f3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mcpsdk-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 09bff801628514845ab5ee77ce411b0019228b1b3c517e63508411caee3d532c
MD5 871294f882ccf550a7b68daaac9ade31
BLAKE2b-256 87c5390c66ac76b845052bbdaf87e8713caa8c60711e5408f7df2cb2d689dae7

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