Repository navigation
Description
Is your feature request related to a problem?
To get a single end-to-end distributed trace across opencode → MCP server, W3C trace context has to be propagated into outbound MCP tools/call requests so the server's spans nest under the opencode tool span. Today this is only achievable for HTTP MCP servers, by intercepting outbound requests and injecting the context into the JSON-RPC _meta + headers. Two gaps:
- stdio MCP servers get no trace context — there is no HTTP request to intercept, so their spans never connect to the parent trace.
- Request-interception is a process-wide workaround that carries transport concerns (URL matching,
content-lengthhandling, body re-serialization) that belong in the MCP SDK, not a telemetry layer.
Describe the solution you'd like
Adopt SEP-414 ("OpenTelemetry Trace Context Propagation Conventions for _meta", merged into the MCP spec) once the MCP TypeScript SDK ships it. Injecting traceparent / tracestate into _meta at the client session layer is transport-agnostic — it covers stdio and HTTP uniformly and removes the need for any request-interception workaround. The SEP-414 wire format (bare traceparent / tracestate keys directly under params._meta) is straightforward to emit and read.
Describe alternatives you've considered
- Patching child-process stdin for stdio — rejected: that stream is shared with other spawned subprocesses (shells, LSP servers, formatters); mutating it is fragile and risks corrupting non-MCP I/O.
- Spawn-time
TRACEPARENTenv var — rejected: stdio MCP servers are long-lived and serve many calls, so a spawn-time value would be static rather than per-call. - Global
fetchinterception — works for HTTP transports only, and is a workaround rather than a protocol-level fix.
Telemetry type
- Traces (Other), Configuration
Additional context
This depends on upstream work (all three required before it can be wired up end-to-end):
- MCP TypeScript SDK implements SEP-414 — tracking: Implement SEP-414: Document OpenTelemetry Trace Context Propagation Conventions modelcontextprotocol/typescript-sdk#2196 (related: OpenTelemetry integration out of the box modelcontextprotocol/typescript-sdk#1264, "OpenTelemetry out of the box").
- opencode upgrades
@modelcontextprotocol/sdkto that version. - opencode enables the (opt-in) propagation middleware on its MCP client.
References:
- SEP-414 (merged): https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/seps/414-request-meta.md
- TS SDK #2196: Implement SEP-414: Document OpenTelemetry Trace Context Propagation Conventions modelcontextprotocol/typescript-sdk#2196
- TS SDK #1264: OpenTelemetry integration out of the box modelcontextprotocol/typescript-sdk#1264
- python-sdk reference implementation (merged): Add basic OpenTelemetry tracing for client and server requests modelcontextprotocol/python-sdk#2381
Checklist
- I have searched existing issues and discussions for similar feature requests
- I have checked the changelog to see if this already exists
Activity
dialupdisaster commentedon Jul 23, 2026
Upstream OpenCode already had an exact implementation proposal: anomalyco/opencode#21539,
feat(mcp): forward plugin-set _meta to downstream MCP tool calls.It added optional
_metaoutput totool.execute.beforeand forwarded that value intoclient.callTool(), which is the transport-independent insertion point needed for SEP-414 over both stdio and HTTP. The PR was closed by automated inactivity cleanup, not because of a technical rejection; it received no maintainer review.The remaining order of work is now:
dev, preservingsessionIDandcallIDin the hook so a telemetry plugin can select the correct live tool span._metaforwarding into OpenCode.traceparentand optionaltracestateunderparams._meta, following final SEP-414.The MCP TypeScript SDK side is ready: modelcontextprotocol/typescript-sdk#2270 merged the reserved keys and confirms
_metapassthrough across transports. It does not inject context automatically. Baggage is also reserved by SEP-414, but should remain separately opt-in rather than being propagated by default.dialupdisaster commentedon Jul 23, 2026
A current OpenCode implementation is now open as anomalyco/opencode#38579.
It updates the earlier proposals for OpenCode's current MCP catalog and SDK 1.29, forwards plugin-set
params._metathrough both normal and code-mode MCP calls, preserves SDK-owned progress metadata, and includes transport-level tests. Once merged, this plugin can inject the active tool span's SEP-414traceparentand optionaltracestatethroughtool.execute.before.