claude-code - 💡(How to fix) Fix [FEATURE] Propagate MCP session/trace context in tool calls (`_meta`, SEP-414) [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#54629Fetched 2026-04-30 06:40:23
View on GitHub
Comments
2
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
commented ×2labeled ×2

Code Example

{
    "method": "tools/call",
    "params": {
      "name": "some_tool",
      "arguments": {},
      "_meta": {
        "traceparent": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01",
        "tracestate": "...",
        "baggage": "..."
      }
    }
  }

---

{
    "method": "tools/call",
    "params": {
      "name": "some_tool",
      "arguments": {},
      "_meta": {
        "anthropic/session": "anon-stable-session-id"
      }
    }
  }
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • This is a single feature request (not multiple features)

Problem Statement

Claude Code currently does not provide a stable way for MCP servers/gateways to correlate tool calls that belong to the same Claude Code conversation/session.

This matters for MCP servers that need per-session policy, audit, security review, observability, or live dashboards. Today, an MCP server can see individual tool calls and transport sessions, but it cannot reliably answer:

  • are these tool calls part of the same Claude Code chat/session?
  • did this request come from the same Claude Code instance after reconnect?
  • should this tool call inherit prior per-session policy state?
  • how do I correlate Claude Code tool calls into one trace across my gateway, backend, and downstream services?

This becomes especially painful with Streamable HTTP/SSE behavior. The transport can disconnect or refresh, and clients may reconnect or create new MCP sessions. Without a stable client session id or propagated trace context, MCP servers have to infer identity from transport lifecycle, which is fragile.

ChatGPT recently added similar metadata for Apps SDK tool calls: _meta["openai/session"], described as an anonymized conversation id that can be used to correlate requests within a ChatGPT session.

Proposed Solution

Please add support for propagating session/trace context on MCP tool calls from Claude Code.

Ideally Claude Code would the standard OpenTelemetry/W3C trace context in params._meta, following SEP-414:

  {
    "method": "tools/call",
    "params": {
      "name": "some_tool",
      "arguments": {},
      "_meta": {
        "traceparent": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01",
        "tracestate": "...",
        "baggage": "..."
      }
    }
  }

The stable session id should be:

  • consistent for tool calls in the same Claude Code conversation/session
  • anonymized and not directly user-identifying
  • stable across MCP transport reconnects where the user is continuing the same conversation
  • different for unrelated Claude Code sessions/conversations
  • available to all MCP transports, not only stdio or HTTP

This would let MCP servers implement reliable per-session policy state, audit logs, dashboards, and trace correlation without coupling correctness to SSE/transport lifetimes.

Alternative Solutions

Do the same as ChatGPT/OpenAI and implement an anonymized Claude Code session id in params._meta, for example:

  {
    "method": "tools/call",
    "params": {
      "name": "some_tool",
      "arguments": {},
      "_meta": {
        "anthropic/session": "anon-stable-session-id"
      }
    }
  }

Priority

Critical - Blocking my work

Feature Category

MCP server integration

Use Case Example

I run an MCP gateway that applies organization policy to tool calls and shows a live dashboard of connected MCP sessions.

Example workflow:

  1. I open Claude Code and connect it to an MCP server.
  2. Claude Code calls a safe/read-only tool.
  3. Later in the same conversation, Claude Code calls a state-changing or private-data tool.
  4. The MCP gateway needs to know this is the same Claude Code session so it can apply policy using prior session context.
  5. If the MCP transport reconnects, the gateway should not lose the ability to correlate future tool calls with the same user workflow.
  6. In production, I also want logs/traces from Claude Code → MCP gateway → downstream services to be correlated in OpenTelemetry.

Without client-provided session/trace metadata, the gateway has to treat transport lifecycle as session lifecycle, which is not reliable.

Additional Context

extent analysis

TL;DR

Add support for propagating session/trace context on MCP tool calls from Claude Code using OpenTelemetry/W3C trace context in params._meta.

Guidance

  • Implement a stable, anonymized session id in params._meta for correlating tool calls within the same Claude Code conversation/session.
  • Follow OpenTelemetry/W3C trace context conventions using traceparent, tracestate, and baggage keys in params._meta.
  • Ensure the session id is consistent across MCP transport reconnects and different for unrelated Claude Code sessions/conversations.
  • Consider implementing an anonymized Claude Code session id in params._meta, similar to ChatGPT's _meta["openai/session"].

Example

{
  "method": "tools/call",
  "params": {
    "name": "some_tool",
    "arguments": {},
    "_meta": {
      "traceparent": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01",
      "tracestate": "...",
      "baggage": "..."
    }
  }
}

Notes

The proposed solution requires changes to the Claude Code implementation to propagate session/trace context. The example provided follows the OpenTelemetry/W3C trace context conventions, but the actual implementation may vary depending on the specific requirements and constraints of the Claude Code system.

Recommendation

Apply the proposed solution by implementing OpenTelemetry/W3C trace context in params._meta to enable reliable per-session policy state, audit logs, dashboards, and trace correlation for MCP servers.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [FEATURE] Propagate MCP session/trace context in tool calls (`_meta`, SEP-414) [2 comments, 2 participants]