Skip to content

PyMCP Kit

Capability-first MCP server tooling for FastAPI. pymcp-kit keeps the built-in transport surface small, exposes app-scoped registries, and ships the MCP features you typically need first: tools, prompts, resources, roots, task-aware execution, optional auth hooks, OAuth protected-resource metadata, and opt-in draft MCP support.

Small transport surface

Use Streamable HTTP at /mcp for networked clients and stdio for subprocess-based MCP hosts.

App-scoped registries

Register tools, prompts, and resources globally for simple setups, then let create_app() snapshot them into an isolated app runtime.

Tasks that stay useful

Opt tools into task execution, emit progress, request user input, support cancellation, and return results without flattening structured payloads.

Security when you need it

Add bearer-token authentication, rule-based authorization, token introspection, and OAuth protected-resource metadata without turning the package into a large framework.

Spec conformant

Passes the official MCP conformance suite in full against the 2025-11-25 spec, verified in CI on every change.

Quick Install

pip install pymcp-kit

How It Fits Together

create_app() snapshots the registries into an isolated runtime, mounts the Streamable HTTP transport at /mcp, and routes every request through the same dispatch pipeline that the stdio transport uses:

flowchart LR
    C1[MCP client] -->|Streamable HTTP /mcp| T[Transport layer]
    C2[MCP host] -->|stdio| T
    T --> SM[Session manager]
    T --> D[Dispatcher]
    D --> G[Middleware gates<br/>error boundary, init,<br/>capability, authorization]
    G --> H[Method handlers<br/>tools, prompts, resources,<br/>roots, tasks]
    H --> R[App-scoped registries]
    H --> E[Task engine]
    SEC[Security hooks<br/>authn, authz,<br/>OAuth metadata] -.-> T
    SEC -.-> D

What Ships Today

  • Streamable HTTP mounted at /mcp
  • Stdio transport through run_stdio_server(app)
  • Stable MCP revisions by default, with opt-in draft 2026-07-28 stateless support
  • Tool, prompt, and resource registries
  • Roots and resource subscriptions
  • Task-aware tool execution with progress, cancellation, and elicitation
  • Optional authentication, authorization, and OAuth protected-resource metadata hooks

Main Protocol Surface

  • Lifecycle: initialize, ping, notifications/initialized, notifications/cancelled
  • Tools: tools/list, tools/call
  • Prompts: prompts/list, prompts/get
  • Resources: resources/list, resources/read, resources/subscribe, resources/unsubscribe
  • Roots: roots/list
  • Tasks: tasks/list, tasks/get, tasks/cancel, tasks/result
  • Draft discovery: server/discover when draft mode is enabled
  • Getting Started: installation, the basic app factory flow, and the built-in transports.
  • Tasks: task-aware tool execution, progress, cancellation, and result polling.
  • Security: bearer tokens, rule-based authorization, and capability filtering.
  • Runtime Surface: protocol revisions, draft stateless flow, endpoints, and capability settings.
  • Docs Deployment: how this site is built and published with GitHub Pages.
  • Release Process: version bump, tag, GitHub Release, and PyPI publishing flow.