Skip to content

feat(telemetry): propagate W3C trace-context on outbound MCP HTTP calls (#60177) - #60466

Open
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:feat/60177-otel-mcp
Open

feat(telemetry): propagate W3C trace-context on outbound MCP HTTP calls (#60177)#60466
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:feat/60177-otel-mcp

Conversation

@webtecnica

Copy link
Copy Markdown
Contributor

Propagate W3C trace-context on outbound MCP HTTP calls via traceparent header from active OpenTelemetry span. Closes #60177

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint tool/mcp MCP client and OAuth telemetry Touches outbound telemetry, usage attribution, or analytics — needs opt-in gating before merge labels Jul 7, 2026
(cherry picked from commit 8b4aee5c805343a9dd0fb8b5a92c90cd2e3d05b4)
@webtecnica
webtecnica force-pushed the feat/60177-otel-mcp branch from 8b4aee5 to 68b5024 Compare July 11, 2026 12:49
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for tackling MCP observability. The gap exists on current main, but this implementation does not yet propagate an agent call's active trace context.

Problems

  • tools/mcp_tool.py:4107 sends MCP tool calls through an already-established ClientSession, while this diff injects traceparent only during _run_http() transport setup. A connection-start header cannot carry a fresh span for each tool invocation.
  • MCP lifecycle work runs on the daemon mcp-event-loop thread (tools/mcp_tool.py:3731-3744). The scheduler documents that work on that loop receives its own thread context and only restores HERMES_HOME (tools/mcp_tool.py:3801-3811), so trace.get_current_span() at connection time will not normally observe the agent caller's span.
  • The PR has no tests for active-span propagation, the cross-thread context boundary, or per-call HTTP headers.
  • AGENTS.md:118-121 requires a generic user-facing opt-in before outbound telemetry/identifier tagging; this diff adds none.

Suggested changes

  • Establish the approved opt-in/observability ownership first, then capture caller trace context before the MCP loop boundary and inject it per outbound MCP request/tool call. Add recording-transport coverage for span/no-span and configured-header cases.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data telemetry Touches outbound telemetry, usage attribution, or analytics — needs opt-in gating before merge tool/mcp MCP client and OAuth type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No OTel SDK / W3C trace-context propagation on outbound MCP HTTP calls

3 participants