Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(claude): keep MCP credentials out of process arguments #10090

Closedjuliusmarmingewants to merge 1 commit intomain fromfix/claude-mcp-bearer-envopened View on GitHub

juliusmarmingecommented

Closes #10020.

The Claude Agent SDK serializes the built-in MCP configuration into process arguments, exposing its thread-scoped bearer to argv inspection and argv-based diagnostics.

Pass the authorization header in a per-session environment clone and use Claude's ${T3_MCP_AUTHORIZATION} expansion in the existing MCP header. User MCP launch arguments, endpoints, and session/token lifetimes stay unchanged. No credential files are added.

Closes #10020.

Verification

  • Actual production adapter → SDK → inert Node process: three regression cases fail and two controls pass on main; all five pass with the fix. Covers argv, child environment, concurrent-session isolation, immutable parent environment, missing/other-thread sessions, and an existing user MCP flag.
  • 98 focused adapter tests, server typecheck, and targeted lint pass.
  • Actual modified adapter → SDK 0.3.260 → native CLI 2.1.236: MCP connects and every observed request carries the correct synthetic header, while actual process arguments contain the reference and no bearer. Zero prompts, clean child exit. This used disposable config and an isolated network namespace with loopback only, without an account or provider call.
  • Independent verification repeated all 98 tests and the complete modified-adapter native probe, with the same results. The three-file diff and relevant callers were independently reviewed.

Claude documents HTTP-header environment expansion; the native probe also verifies the SDK's inline-config path. Other native versions were not exercised. The credential remains in the child environment and memory; this fixes argv exposure, not OS-level isolation.

Human approval required; do not merge automatically. All executed CI jobs pass on e47b6f09a: 15 successful check runs, four skipped, and one neutral Approvability check. Correctness and Effect checks pass. The repository's approval policy requires human review for the new test-only nodeBuiltinImport diagnostic suppression; the credential-boundary change also needs that review. The suppression matches existing adapter-test conventions but is not exempt from the policy. No screenshots apply to this process-boundary change.

Prepared by GPT 6 Astra via Codex in T3 Code.

Note

Pass MCP credentials via child environment instead of process arguments in makeClaudeAdapter

  • Changes makeClaudeAdapter so that queries with a matching MCP provider session receive a copied environment containing that session's authorization value, instead of serializing it into SDK launch arguments.
  • The generated built-in MCP server configuration now references the environment value indirectly rather than placing the authorization header directly in the config arguments.
  • Queries without a matching MCP session retain the prior environment and omit the built-in MCP configuration.
  • Adds an integration-test harness and inert protocol fixture (claudeMcpArgv.mjs) that exercises the real Claude SDK launch path, verifying credentials stay out of argv, concurrent threads don't leak credentials, and the parent environment is not mutated.
  • Risk: the child process now receives MCP authorization via environment variable (CLAUDE_MCP_AUTH or similar) instead of argv; any out-of-tree code or logging that previously read the credential from generated MCP config arguments will no longer find it there.
Macroscope summarized e47b6f0.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — The production Claude MCP launch path now transports thread-scoped bearer credentials through a child environment instead of process arguments, changing a sensitive process boundary. The PR also adds a file-level static-analysis diagnostic suppression in its new integration test, so the change warrants human review.

      Notes:

      • Diff unchanged. Approvability was decided on eligibility alone.
      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire13.6 KiB13.5 KiB−45 B (−0.3%)15.1 KiB✅
      CodexThread snapshot wire7.0 KiB7.0 KiB+2 B (+0.0%)7.3 KiB✅
      CodexLive turn WebSocket wire6.6 KiB6.5 KiB−47 B (−0.7%)7.8 KiB✅
      CodexLive turn WebSocket decoded57.1 KiB57.0 KiB−88 B (−0.2%)66.4 KiB✅
      CodexLive turn messages108−2 (−20.0%)21✅
      ClaudeTotal thread wire13.6 KiB13.5 KiB−57 B (−0.4%)15.1 KiB✅
      ClaudeThread snapshot wire7.0 KiB7.0 KiB−5 B (−0.1%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.6 KiB6.5 KiB−52 B (−0.8%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded57.9 KiB57.8 KiB−88 B (−0.1%)66.4 KiB✅
      ClaudeLive turn messages108−2 (−20.0%)21✅

      Baseline: 39802c0 · PR result: e47b6f0 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 113.8 KiB
      • Claude decoded thread snapshot: 114.5 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    4. juliusmarminge added labelsmacroscope-review

    5. Thanks for working on this. We merged the orchestrator V2 rewrite in #2829, and we are closing this PR as part of that transition.

      This change touches ClaudeAdapter.ts, which the V2 merge removed. Claude execution now runs through ClaudeAdapterV2.

      Sorry for the extra work this creates. If the change is still needed on V2, please rebuild it on current main, verify it there, and open a new PR linking back here. We're closing the current implementation without assuming the underlying request is resolved.

    6. juliusmarminge closed this

Sign in to join this conversation.