fix(server): MCP session grants apply only to forms that offer one #39360
Openshivamhwp(GitHub profile, opens in a new tab)wants to merge 3 commits into
main fromrefs/pull/39360/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
juliusmarminge added labelstakeover:in-progress
- apps/server/src/provider/CodexMcpElicitation.ts lines 201 to 203Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -179,0 +182,21 @@182+ "block",183+ "blocked",184+ "deny",185+ "denied",186+ "disallow",187+ "decline",188+ "never",189+ "no",190+ "not",191+ "refuse",192+ "reject",193+]);194+195+// Whole words only, so an approving word such as "unblock" is not read as a denial.196+function isApprovingSessionChoice(value: string): boolean {197+ return (198+ mcpElicitationPersistenceDecision(value) === "acceptForSession" &&199+ !value200+ .toLowerCase()201+ .split(/[^a-z]+/)202+ .some((word) => NEGATED_CHOICE_WORDS.has(word))
juliusmarminge added labelstakeover:needs-julius
juliusmarminge removed labelstakeover:in-progress
- @@ -178,2 +178,21 @@178178 }179179180+// The Claude SDK drops the server's `_meta.persist`, so the schema is the only session signal it passes on.181+const NEGATED_CHOICE_WORDS = new Set([182+ "block",183+ "blocked",184+ "deny",185+ "denied",186+ "disallow",187+ "decline",188+ "never",189+ "no",190+ "not",191+ "refuse",192+ "reject",193+]);194+195+// Whole words only, camelCase split first, so "unblock" is not read as a denial.196+function isApprovingSessionChoice(value: string): boolean {197+ return (198+ mcpElicitationPersistenceDecision(value) === "acceptForSession" &&
tanstack-source added labelsbug
Sign in to join this conversation.
Walkthrough
MCP elicitation now offers and records a session grant only when a form includes an approving session choice. Plain confirmations omit the session option. The elicitation turn-item event now precedes the runtime-request event.
Changes: MCP elicitation session approval
apps/server/src/provider/CodexMcpElicitation.ts,apps/server/src/provider/CodexMcpElicitation.test.tsapps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts,apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.tsEstimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
Possibly related PRs
Suggested labels:
bugfixSuggested reviewers:
juliusmarminge,yash-singh1Merge Risk:
Moderate · up to
c7b5eSession grants now apply only to forms that offer an approving session choice, which fixes the original silent approval of plain confirmations. However, a denial value such as "dont_allow_for_session" is still treated as an approving session choice. After a grant exists, such a form can be auto-accepted without a card. Tighten the matching before merging.
Pre-merge checks:
4
Full details: Title check
Explanation
The title names the main change: MCP session grants now apply only to forms that offer a session choice. It matches the raw summary and the PR objectives, and it follows the conventional commit format from the repository template. It is short and specific.
Full details: Description check
Explanation
The description follows the template. It has Problem, Change, Evidence, and a note on what was not verified. It covers the bug, the fix, and the tests run. Scope is weak: it gives no bug-issue link or maintainer request, only a 'Refs
#38734' reference. It does not state why the fix needs no issue. Verification is detailed and states what was not checked. Model and harness are named.Finishing Touches
Generate unit tests (beta)