Skip to main content

A capability-first MCP server toolkit for FastAPI with Streamable HTTP and stdio transport

Project description

PyMCP Kit

Python CI codecov PyPI - Version PyPI Downloads Docs License: MIT Python 3.10+

Documentation | Quick Start | Tasks | Security | Middleware

PyMCP Kit is a capability-first MCP server toolkit for FastAPI. It keeps the built-in transport surface small, supports Streamable HTTP and stdio, and ships app-scoped registries, roots, tasks, and optional auth hooks without pulling in a larger framework.

Quick Start

Install from PyPI:

pip install pymcp-kit

For local development from this repo:

pip install -e .

Register tools, prompts, and resources, then build an app:

from pymcp import (
    CapabilitySettings,
    ServerSettings,
    create_app,
    prompt_registry,
    resource_registry,
    tool_registry,
)


@tool_registry.register
def add(a: float, b: float) -> str:
    return str(a + b)


@prompt_registry.register(description="Create a release summary prompt.")
def summarize_release(topic: str) -> str:
    return f"Summarize the release impact for {topic}."


@resource_registry.register(
    uri="memo://release-plan",
    name="release_plan",
    description="Latest release checklist",
    mime_type="text/markdown",
)
def release_plan() -> str:
    return "# Release Plan\n- freeze API\n- tag build\n"


app = create_app(
    server_settings=ServerSettings(
        name="demo-server",
        version="0.1.0",
        capabilities=CapabilitySettings(
            advertise_empty_prompts=False,
            advertise_empty_resources=False,
        ),
    )
)

The HTTP transport is mounted at /mcp. For local-process integrations, use run_stdio_server(app).

Hosted documentation is built from docs/ with MkDocs Material and published to GitHub Pages.

Features

  • Streamable HTTP transport for networked MCP servers
  • Stdio transport for local-process MCP hosts
  • Tool, prompt, and resource registries
  • Roots, resource subscriptions, and app-scoped session lifecycle
  • Task-aware tool execution with progress, cancellation, and result polling
  • Optional authentication and authorization hooks
  • Capability advertising through CapabilitySettings
  • FastAPI middleware integration through MiddlewareConfig
  • Small surface area focused on practical MCP server builds

Supported MCP Methods

  • initialize, ping, notifications/initialized, and notifications/cancelled
  • tools/list and tools/call
  • prompts/list and prompts/get
  • resources/list, resources/read, resources/subscribe, and resources/unsubscribe
  • roots/list
  • tasks/list, tasks/get, tasks/cancel, and tasks/result

Example Server

Run the bundled example server:

python example/run_server.py

That starts a FastAPI app on http://127.0.0.1:8088 with the MCP endpoint mounted at http://127.0.0.1:8088/mcp.

Stdio Transport

from pymcp import create_app, run_stdio_server


app = create_app()
run_stdio_server(app)

Middleware

Middleware stays separate from capability registration. Use MiddlewareConfig to control CORS, compression, logging, auth hooks, and custom ASGI middleware, then pass it into create_app(). See the hosted Middleware guide for examples.

Scope

  • Prompts and resources are advertised only when registered by default
  • Registries are copied into an app-scoped manager when create_app() runs
  • Streamable HTTP and stdio are the only built-in transports
  • Extra transports such as SSE and HTTP NDJSON are intentionally not shipped in pymcp-kit

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

pymcp_kit-0.1.0.tar.gz (61.8 kB view details)

Uploaded Source

Built Distribution

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

pymcp_kit-0.1.0-py3-none-any.whl (81.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pymcp_kit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1c9774fb724d22b1986adda6bcf00b36f823eaf10389214367b72860b8c9ab7f
MD5 b1cf588ea48c610e8ba12146a6d80433
BLAKE2b-256 4051cd87c8224ba805004dca375309e2b60fa56b9d72e86159dfb3f6508590d1

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pymcp_kit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 719a7ac438bf8ab30e56560d0fe3199cc1e26f0e314a24433ea727c2b40f6080
MD5 70beb69a63e7322e00531c51ab7fdc21
BLAKE2b-256 71ed66fbe6c5aeaec33a27c45f6b8c38e71d9ea538dea108f4ba845ef24c93c6

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