Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(orchestrator): scope Claude MCP tool pre-approval #3862

MergedPixPMusic(GitHub profile, opens in a new tab)merged 2 commits intot3code/codex-turn-mapping fromrefs/pull/3862/headmerged by juliusmarminge View on GitHub

Summary

  • always pre-approve the thread-scoped T3 MCP server's tools when it is attached: the Claude Agent SDK's allowedTools only pre-approves tool calls (availability is the separate tools option), so without this entry headless modes like dontAsk deny the orchestrator's own mcp__t3-code__* calls
  • in read-only sandboxes, pre-approve only the orchestrator tools annotated Tool.Readonly instead of the wildcard, so a read-only session cannot silently spawn child threads or scheduled tasks
  • cover MCP and allowlist combinations with focused adapter tests, including a cross-check that the read-only allowlist stays in sync with the toolkit annotations

Notes

An earlier revision of this PR instead dropped the wildcard when no explicit allowlist was set, on the premise that it blocked Claude's built-in tools. Per the SDK typings, allowedTools cannot block built-in tools ("To restrict which tools are available, use the tools option instead"), and dropping it would have auto-denied or prompt-gated the t3-code MCP tools in every mode that does not bypass permissions.

Validation

  • vp check
  • vp run typecheck
  • vp test apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts

Addresses review feedback on #2829.

Note

Scope Claude MCP tool pre-approval to read-only tools in read-only sandboxes

  • In read-only sandboxes, claudeMcpQueryOverrides now pre-approves only the fixed set of tools in CLAUDE_READ_ONLY_T3_MCP_ALLOWED_TOOLS instead of the mcp__t3-code__* wildcard.
  • Adds claudeEffectiveQueryPolicyKey to incorporate MCP-derived allowedTools into live-query reuse keys, so read-only and non-read-only queries are not incorrectly shared.
  • claudeMcpQueryOverrides now requires a readOnlySandbox boolean; callers in openQuery derive it from sandboxPolicyKindForClaudeRuntimePolicy.
  • Behavioral Change: read-only sandbox sessions no longer have access to all t3-code MCP tools; access is limited to the tools annotated with Tool.Readonly in OrchestratorToolkit.
Macroscope summarized 4eafde4.

Note

Medium Risk Changes permission pre-approval for orchestrator MCP tools in read-only sandboxes; behavior is narrow and covered by focused adapter tests, but it affects what agents can do without prompts in constrained runtimes.

Overview When a thread-scoped t3-code MCP server is attached, Claude query setup still pre-approves orchestrator MCP tools via allowedTools, but read-only sandboxes now get only CLAUDE_READ_ONLY_T3_MCP_ALLOWED_TOOLS instead of the mcp__t3-code__* wildcard, so headless modes cannot auto-approve thread spawn or scheduled-task mutations.

claudeMcpQueryOverrides takes a readOnlySandbox flag (derived from the runtime sandbox policy at query open). Live-query reuse uses claudeEffectiveQueryPolicyKey so differing MCP pre-approvals do not share a cached query. Tests cover MCP/no-MCP and allowlist combinations, plus a check that the read-only list stays aligned with Tool.Readonly on OrchestratorToolkit.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4eafde49d6d23b36fc33e406cb46aa05f5807a05. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: e1d89a73-d790-436a-b7bf-96ce7d333995

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

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

      Approvability

      Verdict: Needs human review

      This PR modifies security-relevant tool authorization logic, gating which MCP tools are pre-approved based on sandbox read-only status. Changes that affect authorization behavior and restrict capabilities in security contexts warrant human review despite good test coverage.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. PixPMusic(GitHub profile, opens in a new tab) changed the title

    5. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 744c7b724a2ea364d3ba78d7a66eb48028024869. Configure [here](https://www.cursor.com/dashboard/bugbot).
    6. juliusmarminge merged thisd26dac9

    7. juliusmarminge closed this

Sign in to join this conversation.