Skip to main content
@sedata-ai/mcp runs an OpenTelemetry NodeSDK inside your process and exports data over OTLP. This page covers the moving parts.

Exporters

The exporter type is controlled by config.exporterType: Endpoint composition:
A trailing slash is normalized — both https://host/v1 and https://host/v1/ work.

Authentication headers

exporterAuth is converted to HTTP headers and applied to both the trace and metric exporters:
basic auth is permitted by ConfigValidator but the actual header is commented out in the OTLP setup. Use bearer or apiKey until that ships.

Sampling

The sampler is TraceIdRatioBasedSampler — deterministic by trace id, head-based. Out-of-range values throw on validation. Metrics are not sampled — enableMetrics is the only switch for metrics.

Batching

Trace exporter batching is delegated to OTel’s standard BatchSpanProcessor defaults. The metric reader is a PeriodicExportingMetricReader with two knobs:

Resource detection

The SDK runs these resource detectors at startup:
  • envDetector — picks up OTEL_RESOURCE_ATTRIBUTES.
  • hostDetector — host name + arch.
  • osDetector — OS name + version.
  • serviceInstanceIdDetectorSync — generates a stable service.instance.id.
Plus the package adds:
  • service.name from config.serverName
  • service.version from config.serverVersion
  • mcp.session.id (per-process UUID)

Toggles

Every part of the pipeline is opt-out:

Custom data processors

You can mutate every attribute set right before export:
Processors run in order and receive the merged attribute object (always includes mcp.session.id). See Data processors.

Shutdown

Always call shutdown on graceful exit so in-flight metrics flush:
shutdown() records mcp.server.session.duration and then calls NodeSDK.shutdown(), which flushes both the trace exporter and metric reader.

Next

Authentication

All three auth shapes with examples.

Sampling

Choosing a rate that survives production.