Skip to content

fix(server): preserve Claude read-only MCP hints with native permission checks - #40694

Open
Sidreyas wants to merge 4 commits into
pingdotgg:mainfrom
Sidreyas:sidreyas/fix-32185-claude-mcp-permission-checks-v2
Open

Sidreyas wants to merge 4 commits into
pingdotgg:mainfrom
Sidreyas:sidreyas/fix-32185-claude-mcp-permission-checks-v2

Conversation

@Sidreyas

Copy link
Copy Markdown
Contributor

Problem

In a Full Access Claude thread, one unrelated MCP deny rule (for example mcp__buildkite__create_build) makes T3 drop the read-only hint from every MCP App tool on every server. A read-only background helper such as Datadog's _dd_gff then opens "Allow … to run …?". Confirming does not help: the adapter's broad deny guard refuses the call with "A Claude deny rule may cover …, so it was not called."

The guard is broad on purpose. Claude also matches rules against server aliases T3 can't list (#31131), and mcp_call used to skip Claude's own permission check.

Change

Claude Code advertises mcp_call_check_permissions_v1, which lets mcp_call run Claude's own permission evaluator on the real tool. That evaluator also handles aliases and wildcards. Use it in ClaudeAdapterV2 when all of these hold:

  • the CLI advertises the capability
  • the thread is in Full Access (bypassPermissions)
  • the permission rules are readable
  • no ask rule could cover MCP tools
  • the tool is annotated read-only

On that path, listTools keeps readOnlyHint and callTool sends mcp_call with check_permissions: true. If a deny rule really covers the tool, Claude refuses the call itself.

Everything else keeps today's conservative behavior: older CLIs, unreadable rules, ask rules, other permission modes, and tools without a read-only annotation. The checked path stays limited to Full Access with no possible ask rule because an idle card can't answer a CLI approval request. The server-prefix overlap and normalized tool-name collision guards are unchanged. Clients and wire schemas are unchanged.

This is the same change as #32230, ported onto current main and re-verified, and it supersedes that PR. #32230 was closed only to stay within the open-PR limit and had no outstanding review findings. It conflicted after about 2,950 commits on main.

Scope

Bug fix for #32185 (open). It is limited to the Claude adapter (ClaudeAdapterV2.ts and its test).

Refs #32185. This fixes the reported case: an unrelated deny rule in Full Access. Two cases from the issue comments still prompt, because they keep the conservative path:

  • any ask rule that may cover MCP tools, including an unrelated one such as mcp__atlassian__createJiraIssue
  • threads that are not in Full Access

Handling those would need a way to route Claude's "ask" result to an idle card, which is a design decision for maintainers. #38962 (open) separately stops dialogs for calls an app makes without a click.

Verification

Windows 11, Node 26, Claude Code CLI 2.1.328 (installed), base origin/main f9b19a7, head 2d8a3be.

End to end, real server and real Claude CLI. Script: run.ts <label> <case>. Each run did the following:

  • started the real t3 serve on a fresh isolated T3 home, with an isolated CLAUDE_CONFIG_DIR
  • added a real git project with t3 project add
  • ran a Full Access Claude thread with t3 thread start --provider claudeAgent --wait

The project's .mcp.json registers a stdio MCP fixture shaped like Datadog's graph app:

  • show_graph renders an MCP App
  • get_graph_data is an app-only helper annotated read-only, and it logs each execution

A loopback Anthropic Messages fixture stood in for the model. It only emitted the show_graph tool_use and then some text. Claude Code made every permission decision itself. After the turn, the persisted MCP App item was read from the run's own database. The script then called mcpApps.toolInfo and mcpApps.callTool for get_graph_data over the server's authenticated WebSocket RPC, which is the path McpAppFrame uses. No paid model turn or live user data was used.

Before (origin/main):

case unrelated-deny: project rules {"deny":["mcp__buildkite__create_build"]}
mcpApps.toolInfo get_graph_data -> callable=true readOnly=false
  client: McpAppFrame shows "Allow graph to run get_graph_data?" before calling
mcpApps.callTool get_graph_data -> FAILED: ... "claudeAgent provider protocol error: A Claude deny rule may cover mcp__graph__get_graph_data, so it was not called.."
get_graph_data executions on the MCP server: 0
case exact-deny: project rules {"deny":["mcp__graph__get_graph_data"]}
mcpApps.toolInfo get_graph_data -> callable=true readOnly=false
mcpApps.callTool get_graph_data -> FAILED: ... "A Claude deny rule may cover mcp__graph__get_graph_data, so it was not called.."
get_graph_data executions on the MCP server: 0
case tool-wildcard-deny: project rules {"deny":["mcp__graph__get_*"]}
mcpApps.toolInfo get_graph_data -> callable=true readOnly=false
mcpApps.callTool get_graph_data -> FAILED: ... "A Claude deny rule may cover mcp__graph__get_graph_data, so it was not called.."
get_graph_data executions on the MCP server: 0
case unrelated-ask: project rules {"ask":["mcp__atlassian__createJiraIssue"]}
mcpApps.toolInfo get_graph_data -> callable=true readOnly=false
mcpApps.callTool get_graph_data -> success [{"type":"text","text":"get_graph_data ok"}]
get_graph_data executions on the MCP server: 1

After (this branch):

case unrelated-deny: project rules {"deny":["mcp__buildkite__create_build"]}
mcpApps.toolInfo get_graph_data -> callable=true readOnly=true
  client: McpAppFrame calls without a confirmation dialog
mcpApps.callTool get_graph_data -> success [{"type":"text","text":"get_graph_data ok"}]
get_graph_data executions on the MCP server: 1
case exact-deny: project rules {"deny":["mcp__graph__get_graph_data"]}
mcpApps.toolInfo get_graph_data -> callable=true readOnly=true
mcpApps.callTool get_graph_data -> FAILED: Permission to use mcp__graph__get_graph_data has been denied.
get_graph_data executions on the MCP server: 0
case tool-wildcard-deny: project rules {"deny":["mcp__graph__get_*"]}
mcpApps.toolInfo get_graph_data -> callable=true readOnly=true
mcpApps.callTool get_graph_data -> FAILED: Permission to use mcp__graph__get_graph_data has been denied.
get_graph_data executions on the MCP server: 0
case unrelated-ask: project rules {"ask":["mcp__atlassian__createJiraIssue"]}
mcpApps.toolInfo get_graph_data -> callable=true readOnly=false
mcpApps.callTool get_graph_data -> success [{"type":"text","text":"get_graph_data ok"}]
get_graph_data executions on the MCP server: 1

With an unrelated deny rule, the read-only helper now runs without a prompt. A deny rule that names the tool, exactly or by wildcard, is still enforced, now by Claude's own evaluator. The helper never runs. The unrelated-ask case is unchanged, as described under Scope.

Focused tests. From apps/server, the existing permission-rules table in ClaudeAdapterV2.test.ts gains five rows:

  • native checks with an unrelated deny rule
  • an ask rule for a hidden alias containing __
  • unreadable rules
  • a thread outside Full Access
  • a tool without a read-only annotation

Results:

  • vp test run src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts -t "permission rules to MCP app" --maxWorkers 1 on unmodified main source: 1 failed, 26 passed. The failure was expected { destructiveHint: false } to deeply equal { readOnlyHint: true, …(1) } (unrelated-deny row).
  • vp test run src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts src/provider/AgentContextBudget.test.ts --maxWorkers 1 on this branch: 479 passed, 1 skipped. One test failed, and it is unrelated: native fork > forks a session from its original directory… expects C:\workspace and gets /workspace, a Windows path difference in code this PR does not touch. It fails the same way on unmodified main on this machine (1 failed, 472 passed).
  • Server vp run typecheck: passed. vp staged (fmt, lint, knip): passed. apps/server/src/provider/agentContextBudget.json is unchanged.

Not checked:

  • A live Datadog account, the macOS desktop app, or a browser capture. The RPC results above are what McpAppFrame acts on.
  • A real hidden-alias deny spelling. Those stay on the conservative path when an ask rule exists, and are otherwise delegated to Claude's evaluator.
  • A thread outside Full Access, end to end, because the CLI has no runtime-mode flag. A unit test covers it.

Written by Claude Opus 5.5 in Claude Code via T3 Code.

🤖 Generated with Claude Code

…on checks

An unrelated Claude MCP deny rule, such as mcp__buildkite__create_build, stripped the read-only hint from every MCP App tool, so read-only background calls asked for approval and were then refused by the adapter's broad deny guard.

When Claude advertises mcp_call_check_permissions_v1 and the thread runs in Full Access with readable rules and no ask rule that may cover MCP tools, keep read-only hints and send mcp_call with check_permissions, so Claude's own evaluator applies exact, wildcard and alias rules to the actual tool. Older CLIs, unreadable rules, ask rules, other permission modes and tools without a read-only annotation keep the conservative path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 22, 2026 05:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 22, 2026
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Claude adapter now enables native permission checks for eligible read-only MCP app calls when session capability, permission mode, and readable rules allow. Tests cover permission-rule cases and verify the check flag passed to Claude.

Changes: Claude MCP permission checks

Layer / File(s) Summary
Determine permission-check eligibility
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
The adapter evaluates Claude’s capability, permission mode, and readable rules. It uses the result when setting MCP app tool metadata.
Apply checks to MCP calls
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
Eligible read-only calls pass check_permissions to Claude. The adapter applies its local deny-rule refusal when Claude-side checks are not enabled. Tests cover permission-rule cases and verify the call arguments and check flag.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • pingdotgg/t3code#32185 — The issue reports that an unrelated deny rule removes read-only hints from other MCP App tools. This PR changes the handling of that case.

Possibly related PRs

  • pingdotgg/t3code#32230 — This PR targets the same issue and changes the Claude MCP permission-check behavior.

Suggested reviewers: juliusmarminge, macroscopeapp, yash-singh1

Merge Risk: Minimal · up to db3f7

This change stops an unrelated MCP deny rule from forcing confirmation prompts on read-only MCP App tools in Full Access threads. Claude's native permission check still enforces applicable deny rules. Older CLIs, unreadable rules, possible ask rules and other permission modes keep their conservative behavior. No concrete merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix and the main mechanism: Claude read-only MCP hints are kept while native permission checks run. It matches the changeset, which keeps readOnlyHint and sends check_permissions f…
Description check Passed The description follows the template sections: Problem, Change, Scope, and Verification. The Problem section explains the bug and reproduction. The Change section explains the capability gate and the …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the fix and the main mechanism: Claude read-only MCP hints are kept while native permission checks run. It matches the changeset, which keeps readOnlyHint and sends check_permissions for read-only MCP app tools under Full Access. The title follows the conventional commit form from the template. At 78 characters it is slightly long but still clear.

Full details: Description check

Explanation

The description follows the template sections: Problem, Change, Scope, and Verification. The Problem section explains the bug and reproduction. The Change section explains the capability gate and the affected behavior. The Scope section links the issue (#32185), limits the change to the Claude adapter, and explains what still prompts. The Verification section gives specific end-to-end runs, focused test results, typecheck and lint results, and unchecked items. The model attribution line is present. The description is detailed and complete. Minor note: the template asks for the reason a small fix needs no issue, but the PR links an open issue, so this does not apply.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between dace83f and db3f761.

Files selected for processing: 2

  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 22, 2026
juliusmarminge and others added 3 commits November 22, 2026 06:06
T3's broad ask matcher treated any mcp__ ask rule as covering every MCP
App tool, so an unrelated ask rule still withheld read-only hints and
sent calls back through the broad deny guard. With check_permissions,
Claude evaluates ask rules itself and routes a matching ask to
canUseTool, which prompts during a turn and refuses when idle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…calls"

This reverts commit dace83f.

With native checks, an ask rule that really covers a read-only app tool
reaches canUseTool, which refuses it when no turn is active. Cards load
between turns, so the frame lost its confirmation and the call failed,
where main asks and then runs it. Any MCP ask rule again keeps the
frame's confirmation and the unchecked call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge juliusmarminge added takeover:blocked Takeover blocked; reason in the PR body takeover:in-progress A takeover lead is working on this PR and removed takeover:in-progress A takeover lead is working on this PR takeover:blocked Takeover blocked; reason in the PR body labels Nov 22, 2026
@juliusmarminge juliusmarminge added takeover:needs-julius Takeover done; route gate says Julius decides and removed takeover:in-progress A takeover lead is working on this PR labels Nov 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). takeover:needs-julius Takeover done; route gate says Julius decides vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants