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
| Attribute | Description |
|---|---|
mcp.tool.name | Full tool name (e.g. kraken__get_ticker) |
mcp.tool.upstream | Upstream name |
mcp.transport | streamable-http or sse |
http.upstream.url | URL of the upstream request |
http.upstream.status_code | HTTP 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:
| Metric | Type | Description |
|---|---|---|
mcp_tool_calls_total | Counter | Total tool calls by tool name and status |
mcp_tool_call_duration_seconds | Histogram | Tool call latency distribution |
mcp_upstream_requests_total | Counter | HTTP requests to upstreams |
mcp_upstream_request_duration_seconds | Histogram | Upstream HTTP latency |
mcp_active_connections | Gauge | Active MCP client connections |
Trace exporters
| Exporter | Description |
|---|---|
otlp | OTLP over HTTP (default port 4318) |
stdout | Print traces to stdout (development) |
noop | Discard all traces |
Metric exporters
| Exporter | Description |
|---|---|
prometheus | Prometheus scrape endpoint |
otlp | Push metrics via OTLP |
stdout | Print 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