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 spanlyimport 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_KEYenvironment variable. - Quickstart walks through mounting the middleware in a typical server end to end.
- API reference documents
SpanlyMiddlewareand every option it accepts. - Examples shows end-user attribution, error reporting via Sentry, and a local test harness.