Skip to main content
This guide assumes you already have a working MCP server. You’ll add instrumentServer and verify traces in under a minute.

Add the call

instrumentServer must run before you register tools — it patches server.registerTool and only the calls made afterward are instrumented.
instrumentServer returns an ObservabilityInstance — keep the reference around to record custom spans and to call shutdown().

Pick the right serverName / serverVersion

These map to service.name and service.version in OpenTelemetry. Use stable values that match how you operate the service:

Wire shutdown

The OTel SDK is a long-running thing. Always shut it down on exit so the last batch of metrics flushes (including session duration):

Confirm it works

Three quick checks:
Set exporterType: 'console' and watch spans print on stdout when you call a tool:
See Console debugging.
With the live exporter pointed at https://otel.sedata-ai.tech/v1, run a tool from any MCP client. Open app.sedata-ai.techTraces. Latest trace should appear within a few seconds.
Point exporterEndpoint at your collector and tail its logs:

Common pitfalls

Calling instrumentServer after registerTool — tools registered before instrumentation are not patched. Always call instrumentServer immediately after new McpServer(...).
Two versions of @opentelemetry/api — if your project pins a different version, your tracer will silently no-op. Run npm ls @opentelemetry/api and dedupe.
Sampling 0 in dev — if samplingRate: 0 is in a shared config you’ll see zero spans. Default is 1.0.

Next

Authentication

Bearer, API key, basic.

Custom spans & metrics

Record domain-specific telemetry.