Skip to content

[FEATURE]: propagate W3C trace context on outbound MCP HTTP/SSE requests #28295

@HrdlickaJakub

Description

@HrdlickaJakub

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem

When opencode connects to an MCP server over HTTP, the outbound requests do not carry the W3C traceparent / tracestate headers.

Expected Behavior

With OTel tracing enabled (OTEL_EXPORTER_OTLP_ENDPOINT set and experimental.openTelemetry: true), every outbound MCP HTTP request should carry the W3C traceparent (and tracestate when present) header derived from the currently-active trace context, so the MCP server's spans attach as children of the originating opencode span in the same trace.

Use Case

Operating a tracing-enabled MCP server (whether self-hosted or shared) and needing a single, complete trace per tool call across all hops.

Concretely, this unblocks:

  • Debugging tool-call latency end-to-end (where time is spent on the opencode side vs. inside the MCP server vs. in whatever the MCP server calls downstream).
  • Correlating errors raised inside the MCP server with the originating opencode session in a single view.
  • Consistent sampling

Related Issues

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions