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: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:- Sets the span status to
ERRORwith the error message. - Sets
error.type,error.message,mcp.operation.success: false. - Records the duration histogram with
mcp.operation.success: false. - 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:
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.