OpenTelemetry

The proxy emits OTLP traces, Prometheus metrics, and structured logs. W3C Trace Context is propagated to upstream APIs so distributed traces span your entire stack.

Configuration

telemetry:
  enabled: true
  service_name: mcp-anything
  service_version: 1.0.0

  traces:
    exporter: otlp
    endpoint: https://otel-collector.internal:4318  # OTLP HTTP
    insecure: false
    headers:
      Authorization: Bearer ${OTEL_TOKEN}

  metrics:
    exporter: prometheus
    path: /metrics    # Prometheus scrape endpoint
    port: 9090

Traces

Each MCP tool call produces a trace with spans covering the full request lifecycle:

  • MCP protocol handling (request parsing, tool lookup)
  • Auth validation (inbound and outbound)
  • Request transform (jq expression)
  • Upstream HTTP call
  • Response transform (jq expression)

MCP-specific span attributes

AttributeDescription
mcp.tool.nameFull tool name (e.g. kraken__get_ticker)
mcp.tool.upstreamUpstream name
mcp.transportstreamable-http or sse
http.upstream.urlURL of the upstream request
http.upstream.status_codeHTTP status from upstream

W3C Trace Context propagation

The proxy injects traceparent and tracestate headers into upstream HTTP requests. If the upstream is also instrumented with OTel, traces from the MCP client through to the upstream API appear as a single distributed trace.

Metrics

When the Prometheus exporter is enabled, metrics are available at the configured path:

MetricTypeDescription
mcp_tool_calls_totalCounterTotal tool calls by tool name and status
mcp_tool_call_duration_secondsHistogramTool call latency distribution
mcp_upstream_requests_totalCounterHTTP requests to upstreams
mcp_upstream_request_duration_secondsHistogramUpstream HTTP latency
mcp_active_connectionsGaugeActive MCP client connections

Trace exporters

ExporterDescription
otlpOTLP over HTTP (default port 4318)
stdoutPrint traces to stdout (development)
noopDiscard all traces

Metric exporters

ExporterDescription
prometheusPrometheus scrape endpoint
otlpPush metrics via OTLP
stdoutPrint metrics to stdout (development)

Structured logging

The proxy logs via Go's slog package in JSON format. Log level is configurable:

telemetry:
  log_level: info    # debug, info, warn, error

Secret values (tokens, credentials) are never logged. Config fields that reference ${ENV_VAR} secrets show the variable reference, not the expanded value.

See also

  • Kubernetes — configuring OTel collector sidecars