MCP HubMCP Hub
jujumilk3

ezmcp

by: jujumilk3

Easy-to-use MCP server framework specialized for SSE.

17created 06/03/2025
Visit
SSE
framework

📌Overview

Purpose: To simplify the creation of Minimum Compatible Protocol (MCP) servers with a user-friendly framework that utilizes a FastAPI-like syntax.

Overview: ezmcp is a lightweight server framework designed for developing MCP-compatible applications effortlessly. It leverages a decorator-based API, facilitating the definition of tools that can be easily invoked by MCP clients, making server development straightforward and efficient.

Key Features:

  • FastAPI-style Decorator API: Enables users to define MCP tools conveniently, enhancing productivity and clarity in code.

  • Automatic Parameter Management: Provides automatic validation and type conversion, ensuring that inputs are always correct and reducing boilerplate code.

  • Tool Schema Generation: Automatically generates tool schemas from function signatures to support clear API documentation.

  • SSE Transport Support: Includes built-in support for Server-Sent Events (SSE) to facilitate real-time communication.

  • Middleware Compatibility: Supports FastAPI-style middleware, allowing for the addition of cross-cutting behaviors across the application seamlessly.

  • Interactive Documentation: Offers a self-generating interactive documentation page for users to explore and test the tools dynamically.


ezmcp

Easy-to-use MCP server framework specialized for SSE.

Overview

ezmcp is a lightweight framework that makes it easy to create MCP-compatible servers using a FastAPI-like syntax. It provides a simple decorator-based API for defining tools that can be called by MCP clients.

Features

  • FastAPI-style decorator API for defining MCP tools
  • Automatic parameter validation and type conversion
  • Automatic generation of tool schemas from function signatures
  • Built-in support for SSE transport
  • FastAPI-style middleware support
  • Easy integration with existing Starlette applications
  • Interactive documentation page for exploring and testing tools

Installation

pip install ezmcp

Quick Start

from ezmcp import ezmcp, TextContent

# Create an ezmcp application
app = ezmcp("my-app")

# Define a tool
@app.tool(description="Echo a message back to the user")
async def echo(message: str):
    """Echo a message back to the user."""
    return [TextContent(type="text", text=f"Echo: {message}")]

# Run the application
if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8000)

Once the server is running, you can:

  • Access the interactive documentation at http://localhost:8000/docs
  • Connect to the SSE endpoint at http://localhost:8000/sse

Middleware

ezmcp supports middleware similar to FastAPI, allowing you to add behavior that is applied across your entire application.

from starlette.requests import Request
from ezmcp import TextContent, ezmcp

app = ezmcp("my-app")

@app.middleware
async def process_time_middleware(request: Request, call_next):
    """Add a header with the processing time."""
    import time
    start_time = time.perf_counter()
    response = await call_next(request)
    process_time = time.perf_counter() - start_time
    response.headers["X-Process-Time"] = str(process_time)
    return response

@app.tool(description="Echo a message back to the user")
async def echo(message: str):
    """Echo a message back to the user."""
    return [TextContent(type="text", text=f"Echo: {message}")]

For more information on middleware, see the middleware documentation.

Documentation

For more detailed documentation, see the ezmcp/README.md file.

License

MIT

Commands

  • Install for testing: pdm install -G test
  • Install for development: pdm install -G dev