Skip to main content
FastMCP includes native OpenTelemetry instrumentation for observability. Traces are automatically generated for tool, prompt, resource, and resource template operations, providing visibility into server behavior, request handling, and provider delegation chains.

How It Works

FastMCP uses the OpenTelemetry API for instrumentation. This means:
  • Zero configuration required - Instrumentation is always active
  • No overhead when unused - Without an SDK, all operations are no-ops
  • Bring your own SDK - You control collection, export, and sampling
  • Works with any OTEL backend - Jaeger, Zipkin, Datadog, New Relic, etc.

Enabling Telemetry

The easiest way to export traces is using opentelemetry-instrument, which configures the SDK automatically:
Then run your server with tracing enabled:
Or configure via environment variables:
This works with any OTLP-compatible backend (Jaeger, Zipkin, Grafana Tempo, Datadog, etc.) and requires no changes to your FastMCP code.

OpenTelemetry Python Documentation

Learn more about the OpenTelemetry Python SDK, auto-instrumentation, and available exporters.

Tracing

FastMCP creates spans for all MCP operations, providing end-to-end visibility into request handling.

Server Spans

The server creates spans for each operation using MCP semantic conventions: For mounted servers, an additional delegate {name} span shows the delegation to the child server.

Client Spans

The FastMCP client creates spans for outgoing requests with the same naming pattern (tools/call {name}, resources/read {uri}, prompts/get {name}).

Span Hierarchy

Spans form a hierarchy showing the request flow. For mounted servers:
For proxy providers connecting to remote servers:

Programmatic Configuration

For more control, configure the SDK in your Python code before importing FastMCP:
The SDK must be configured before importing FastMCP to ensure the tracer provider is set when FastMCP initializes.

Local Development

For quick local trace visualization, otel-desktop-viewer is a lightweight single-binary tool:
Run it alongside your server:
For more features, use Jaeger:
Then view traces at http://localhost:16686

Custom Spans

You can add your own spans using the FastMCP tracer:

Error Handling

When errors occur, spans are automatically marked with error status and the exception is recorded:

Attributes Reference

RPC Semantic Conventions

Standard RPC semantic conventions:

MCP Semantic Conventions

FastMCP implements the OpenTelemetry MCP semantic conventions:

Auth Attributes

Standard identity attributes:

FastMCP Custom Attributes

All custom attributes use the fastmcp. prefix for features unique to FastMCP: Provider-specific attributes for delegation context:

Testing with Telemetry

For testing, use the in-memory exporter: