Spanly Docs

Python SDK

Instrument a Python MCP server with the spanly package in one line.

The Python SDK is ASGI middleware: mount SpanlyMiddleware in front of any MCP server that speaks ASGI and it captures every tool call, prompt, resource access, and JSON-RPC packet, with no changes to your server code. Requires Python 3.10+.

pip install spanly
# or: uv add spanly
import osfrom spanly import SpanlyMiddlewareapp.add_middleware(SpanlyMiddleware, api_key=os.environ["SPANLY_API_KEY"])

In this section

  • Installation covers package install and the SPANLY_API_KEY environment variable.
  • Quickstart walks through mounting the middleware in a typical server end to end.
  • API reference documents SpanlyMiddleware and every option it accepts.
  • Examples shows end-user attribution, error reporting via Sentry, and a local test harness.

On this page