You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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-length handling, 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 TRACEPARENT env 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 fetch interception — 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):
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 _meta output to tool.execute.before and forwarded that value into client.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:
Revive or replace OpenCode #21539 against current dev, preserving sessionID and callID in the hook so a telemetry plugin can select the correct live tool span.
Merge the hook and _meta forwarding into OpenCode.
Add plugin-side injection of that tool span's W3C traceparent and optional tracestate under params._meta, following final SEP-414.
The MCP TypeScript SDK side is ready: modelcontextprotocol/typescript-sdk#2270 merged the reserved keys and confirms _meta passthrough 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.
It updates the earlier proposals for OpenCode's current MCP catalog and SDK 1.29, forwards plugin-set params._meta through 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-414 traceparent and optional tracestate through tool.execute.before.
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.