Skip to main content
When you call instrumentServer(server, config), the package patches server.registerTool so every subsequent tool you register runs inside an OpenTelemetry span.

Span shape

Each tool invocation produces a single span:

Attributes

Optional attributes

These show up only under specific configurations:
enableArgumentCollection is off by default. Tool arguments often contain user input, secrets, or PII — turn it on knowingly.

Resource attributes

The OTel resource attached to every span carries: These are added once per process and merged into every export.

Errors

If your handler throws, the package:
  1. Sets the span status to ERROR with the error message.
  2. Sets error.type, error.message, mcp.operation.success: false.
  3. Records the duration histogram with mcp.operation.success: false.
  4. Re-throws the original error so the MCP runtime sees it.

Sampling

By default, all spans are recorded (samplingRate: 1.0). To trim volume in production, set a ratio:
The sampler is TraceIdRatioBasedSampler — head-based and deterministic per trace id. See Sampling for tradeoffs.

What’s next

Automatic attributes reference

Full table of every attribute the package writes.

Custom spans

Record domain-specific operations alongside auto-spans.