Repository navigation
MCP profiles: follow-ups for Codex and the T3 tool rule (#812, #814, #918) - #961
Conversation
…918) - Codex: a turn Codex starts holds the thread's T3 requests until its set is fixed; sub-agent turns and goal sets are checked but never fix the parent's set; a turn on an unseen thread is adopted by thread/read or stopped after a short wait; T3's own turn is not checked twice and reads the profile the turn check worked out (once per turn). - Codex: MCP Apps calls (tool/call, resource/read) to a server outside the profile are refused, and its elicitations declined. - Codex: only the T3 servers a load carries are exempt, so a user's server named t3-code is switched off like any other. - Codex: a thread not yet in the store is read again (250 ms, 500 ms, 1 s) before the refusal stands. - T3 tool rule: a refused set worked out by a request is reused 5 s and never remembered; tool_search imports only a light filter module. - Claude: the T3 tool set is fixed as the query opens. - Settings help text and docs (4096 cap, Codex edges, not a sandbox). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he rule's span The start-paths guard lists every file that names startTurn, and the boot test lists the fork layers' spans; both now match the rule module. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
lens: state · reviewer: lens agent · read at: 54afc81 🤖 Generated with Claude Code |
|
lens: code · reviewer: lens agent (Claude) · read at: 54afc81 🤖 Generated with Claude Code |
… bounded and never leak - Claude: a turn whose plan matches the one the thread's live process opened with fixes that set again, so a good turn after a refused one gets its set back on the reused process (was: Refused until the process closed). - Codex: the turn/started hold is taken inside the forked check with acquireUseRelease, so a closed scope takes none and every end releases it. - Holds carry a bound: a request waits at most until it, so tools/list waits once, not once per tool; a hold past it is dropped and the thread keeps only the ungrouped T3 tools until a turn fixes its set. - Comments on CurrentTurnMcpProfile's per-turn assumption; README says the hold covers only the profile step; McpHttpServer imports the rule as McpT3ToolRule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
lens: state r2 · reviewer: lens agent · read at: 005eb32 🤖 Generated with Claude Code |
|
lens: code r2 · reviewer: lens agent (Claude) · read at: 005eb32 🤖 Generated with Claude Code |
Follow-ups to the fork's MCP profiles (server, Claude and Codex adapters, settings), from the lens reviews of #804 and #827.
Fixes #812
Fixes #918
Part of #814 (umbrella #875). #814 stays open: its item 8 (plugin servers) is declined below and needs an owner decision.
Security
This touches what tools an agent gets. Every change keeps the narrow default or narrows further, with one mild exception that is called out:
mcpServer/tool/call,mcpServer/resource/read), elicitations from servers outside the profile are declined, a user's own server named like T3's is switched off, and turns on threads T3 has not seen are adopted or stopped while a narrowed profile is in use. A request that comes in while a Codex-started turn is fixing its set now waits for that set instead of using the set from before. The hold lasts 10 s at most from when the turn started; a hold still there then is dropped and the thread keeps only the ungrouped T3 tools until the late check or its next turn fixes the set (never the set from before).mcpServerStatus/listis not refused: it is read-only.Every point
#812 (Fixes)
MCP_NOT_A_SANDBOX_NOTE).optionsgetter fixes the set (fixedWhenOpenedinclaudeMcpProfile.ts). ClaudeAdapterV2 reads them only to open a new process.t3Tools-only change restarts the Claude process: declined, kept as it is. Pushingnotifications/tools/list_changedinstead would (a) still cost the prompt cache, because the tool list is part of the cached prefix, (b) change the tools of background work in the middle of its run, which the restart-on-change rule exists to stop, and (c) rely on Claude Code re-reading the list onlist_changedmid-session, which is not verified. The restart is the safe and known path.McpToolExposure.tsimport chain: done.mcpT3ToolFilter.tsis now a light module (Effect andMcpInvocationContextonly). The rule (mcpT3ToolRule.ts) installs its check into it..github/fork-seams.jsonis updated to match. A test pins the module's imports.docs/fork/README.md(server.mcpProfiles).#814 (stays open)
mcpServer/tool/callandmcpServer/resource/readgo through the thread's profile, and a server it leaves out is refused.t3-code/t3-code-direct: done. Only the T3 servers the load actually carries count as T3's (codexCarriedT3McpServers). A user's server with the same name is switched off like any other.allthreads: done, on Codex only: a thread the store does not have yet is read again after 250 ms, 500 ms and 1 s. After the last attempt, the refusal stands (fail closed).narrowedlatch: done. A thread T3 has not seen (for example a sub-agent from before a restart) is adopted by asking Codex for its parent (thread/read).enabled = falseconfig remains the main guard.docs/fork/README.md("Edges of the Codex turn check"). A stopped turn can run briefly before the interrupt lands, and a turn can end before its check finishes. The comment's follow-up (stop a turn on an unknown thread unless it is adopted within a short wait) is done: the thread is adopted, or after 5 s the turn is stopped.plugins."<id>".mcp_servers.<name>.enabled = falsein the thread's load config. Codex does not check that key's shape before the load, so a wrong or stale plugin id can make Codex refuse the whole thread load instead of just that server. Today every turn is refused while such a server is on (fail closed), which is safe. This needs an owner decision, so MCP profiles part 5 (Codex): follow-ups from the lens reviews #814 stays open.#918 (Fixes)
watchTurn's forked check takes a hold on the thread (holdT3ToolSet) as it starts, before the handler returns, and T3's MCP server makes the thread's requests wait for it. The hold is taken and released withacquireUseReleaseinside the forked fiber, so a closed scope takes none and every end releases it; it also carries a 10 s bound (see the review round below).docs/fork/README.md.CurrentTurnMcpProfile. The Codex wrapper reads that result and no longer works the profile out again: nothread/read, and no second status list.Each fix fails without it
Each fix was undone on its own and its test file run:
watchTurncodexMcpProfile.test.ts› a turn Codex starts holds T3's requests until its set is fixedcodexMcpProfile.test.ts› a sub-agent's turn, or a goal set active, checks but leaves the parent's setcodexMcpProfile.test.ts› a turn on a Codex thread T3 has not seen: adopted when Codex names its parent, else stopped (it hangs to the timeout)codexMcpProfile.test.ts› T3's own turn reads the profile the turn check worked out, once per turnmcpProfileTurnCheck.test.ts› Codex (in MCP_PROFILE_DRIVERS): a narrowed t3Tools gets exactly that set…codexMcpProfile.test.ts› MCP Apps calls and elicitations to a server outside the profile are refusedcodexMcpProfile.test.ts› a server of the user's named like T3's is switched off unless T3 carries itcodexMcpProfile.test.ts› a thread the store does not have yet is read again before it is refusedmcpT3ToolFilter.test.ts› a refused set is not remembered: it is reused briefly, then worked out againmcpT3ToolFilter.test.ts› a hold never released: the request is refused, not given the set beforeclaudeMcpProfile.test.ts› the set is fixed only once the plan opens a process: a turn that keeps the old one keeps its setmcpT3ToolFilter.test.ts› imports no toolkit, profile resolver or storeMcpProfileSettings.browser.test.tsx› says under the T3 tool groups that a profile is not a sandboxclaudeMcpProfile.adapter.test.ts› runs again after a refused turn: the next good turn on the same process gets its set back (sets were Groups, Refused, Refused)forkIncodexMcpProfile.test.ts› stopped half-way: a turn Codex starts as the client closes leaves no holdmcpT3ToolFilter.test.ts› tools/list waits once for the hold, not once per tool; and › a hold past its bound is dropped: later requests do not wait, later turns start fresh (both fail on the old rule and sets, both need no socket)Each run had exactly that one test failing in its file; all others passed. The R1 rows were written first and seen failing on the round-0 head before the fix.
codexMcpProfile.test.ts› stopped half-way: a turn's check interrupted mid-way releases its hold is a guard that already passed (theensuringcovered that path).Review round 1
claudeMcpProfile.tsremembers the plan key each thread's process opened with (set by theoptionsgetter, bounded at 4096 threads). A later plan with the same key fixes its set at once, since the adapter keeps that process without readingoptions. Chosen over closing the process on a refusal, which would kill the background work the refusal exists to protect. Test over three turns: Groups, Refused (settings read fails once), Groups on the same process.forkIn, leaked on a closed scope; tools/list waits once per toolacquireUseRelease(the fiber starts at once, so it is still taken before the handler returns). Each hold records its bound (until); a request waits at most until then, so a list request waits once in all, not once per tool.dropT3ToolSetHold), which fixes a refused set with the "try again" reason, and a laterholdT3ToolSetstarts a fresh hold rather than joining a stale one.CurrentTurnMcpProfilekeyed by threadmcpTurnProfile.tsand where it is provided (mcpProfileTurnCheck.ts): nothing forked inside a turn start may outlive it; fork long-lived work from the session.McpHttpServer.tsnames the ruleMcpT3ToolFilterMcpT3ToolRule.State question
thread/reador stopped. Codex reloads each thread with its per-thread config, as before.acquireUseReleasehowever the check ends, so an interrupted or failed check never leaves requests waiting (tested: scope closed before turn/started, and closed mid-check). A hold that is still not released 10 s after it was taken (a check stuck that long) is dropped: requests waited on it once, are refused, and the thread keeps only the ungrouped T3 tools until the late check or the next turn fixes its set; it never falls back to the set from before. A request whose set read fails is refused, and nothing is remembered.Checks
Run locally:
mcpT3ToolFilter,claudeMcpProfile,claudeMcpProfile.adapter,personOnlySettings,codexMcpProfile,mcpProfileTurnCheckclaudeMcpProfile,claudeMcpProfile.adapter,codexMcpProfile,mcpProfileTurnCheck,personOnlySettings, and the 8mcpT3ToolFiltertests that need no socket, all pass. Not run locally in round 1 (loopback blocked on that machine): thewithServertests inmcpT3ToolFilter.test.tsandholdWork.boot.test.ts; CI runs them.workAdmission.startPaths.test.tsandholdWork.boot.test.ts, which the first CI run caught. The Codex turn wrap is now namedturnStart, so the start-paths guard (every file namingstartTurn) is unchanged. The boot test now expects the rule's spanMcpT3ToolRule.make.McpProfileSettings(10 tests)vp lint,vp fmt --check,knipGeneral vs project
All general: this is the fork's MCP profile feature, for every user of the fork. There are no project facts and no new config. Upstream files: only the fork's own lines in
McpHttpServer.tschange (the import now names the rule's modulefork/mcpT3ToolRule.tsasMcpT3ToolRule, and the fork'slayerline uses that name), and the seam text in.github/fork-seams.jsonchanges to match.McpToolExposure.tsis not touched.🤖 Generated with Claude Code