Skip to main content
The Python SDK instruments servers built with FastMCP — both the standalone package and the FastMCP class from the official MCP Python SDK. Python 3.10+.

Install

The base package has no runtime dependencies; the extras pull in the framework you use (fastmcp>=2,<4 or mcp>=1.27,<2).

Set your API key

Create a key in the dashboard, then add it to your deployment secrets. If the key is missing, the SDK quietly no-ops — your server keeps working, and no data is sent.

Instrument your server

Call instrument_fastmcp once, before registering tools:
server.py
Works identically with the official SDK’s FastMCP:
Instrumentation is idempotent — calling instrument_fastmcp twice does not double-count. Sync and async tool handlers are both supported.

Custom dispatcher

If you handle tools/list and tools/call yourself, use the recorder directly:
Running on serverless or stateless HTTP? Wrap your ASGI app in StatelessHttpSessionMiddleware and set "delivery": "await". See Stateless & serverless servers.

Configuration

Pass options as a dict under the armature key. Both snake_case and camelCase keys are accepted:

Flush on shutdown

With background delivery, drain pending events before the process exits:

Verify locally

Capture batches in memory instead of sending them:

Troubleshooting

FastMCP builds the advertised schema from your function’s type hints, so the SDK adds a keyword-only telemetry parameter to instrumented functions. If you post-process signatures or schemas yourself, make sure that parameter survives.
The SDK reads the Mcp-Session-Id header, including on FastMCP versions that exclude it from get_http_headers() by default. If you run a custom ASGI stack, make sure the header reaches the app.
Check that ANALYTICS_INGEST_API_KEY is set in the server’s environment (missing keys no-op silently by design) and pass an on_error hook to surface delivery failures.