Repository navigation
feat: run admitted MCP tools on the worker node that hosts them - #191387
Conversation
|
|
Codex review: needs maintainer review before merge. What this changesThis PR lets compatible workers execute admitted MCP tools through their node’s existing MCP client and project results inside the model process. Example: A worker calls documents.search and receives structuredContent containing document: 7.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this maintainer-authored PR open: it provides useful same-node MCP execution, preserves Gateway fallback, and has no identified code defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Gateway admits the tool surface and issues turn-scoped handles; the node supervisor resolves those handles through its MCP client and returns raw results for worker-side projection. flowchart LR
A[Gateway tool admission] --> B[Worker turn grant]
B --> C[Model worker]
C --> D[Node supervisor]
D --> E[Existing MCP client]
E --> F[MCP server]
F --> C
C --> G[Code Mode result]
Technical reviewBest possible solution: Use the existing node MCP client for eligible same-node tools, project results in the worker, and preserve Gateway execution wherever its policies or transport are required. Do we have a high-confidence way to reproduce the issue? Current-main Gateway proxies reconstruct serialized results, while Code Mode MCP metadata lives in a process-local WeakMap; source inspection establishes the boundary without executing target code. Is this the best way to solve the issue? The implementation addresses that boundary through existing admission, supervisor, MCP-client, and projection owners; the extracted tool-surface module and reused retained-worker fixture support a coherent same-node stage after the separately merged question flow. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a12e3ae8d85d. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +795, Tests +1019, Docs +11, Other +5. Total +1830 across 52 files. Added test files: 3. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (8 earlier review cycles)
Reviewed November 3, 2026, 5:40 PM ET / 22:40 UTC (Revision 9). |
|
Codex follow-up for The worker now preserves recognized MCP error codes and bounded, redacted diagnostics, including the sign-in action for a 401. The Gateway error path keeps its existing behavior. I also reproduced a pending launch inheriting permission after withdrawal and restoration. The node now binds the grant when it receives the launch, before any wait for the workspace or journal. The model turn keeps its own cancellation signal. The updated PR description includes the live Console trace and the server-observed request counts from the controlled HTTP MCP test. The server saw all three admitted controls and zero requests for the ungranted, revoked, replaced-connection and previous-turn cases. The test counts incoming frames before the MCP server dispatches a tool. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex CI attribution for the remaining item on
Both tests install their own mock Gateway. Their settings implementation and fixtures are unchanged in this PR. I classified these as inherited failures and added the comparison to the PR description. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
This comment has been minimized.
This comment has been minimized.
|
Codex follow-up for @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex follow-up for @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…elease-test-budget-20261104 * commit 'd27139b2b220327d6f65b659c6fba0b0110fad97': fix(ci): reconcile remaining unallocated test lines feat: run admitted MCP tools on the worker node that hosts them (#191387) fix(agents): use canonical MCP catalog metadata type fix(ci): preserve injected CLI fetch mock identity fix(models): avoid revalidating trusted remote catalog snapshots (#192363)
…claw#191387) * feat: run admitted MCP tools on the worker node that hosts them * fix: preserve MCP result compatibility for local worker calls * fix: type the node MCP client method for unbound use * fix: bind local MCP permission at launch receipt and preserve tool diagnostics * test: count local MCP calls at the HTTP request boundary * docs: distinguish node-owned MCP clients from remote OAuth servers * feat: let node-hosted MCP tools ask questions through the gateway * fix: return an explicit empty result for unbound MCP calls * fix: forward worker MCP questions only for a granted tool handle * fix: advertise local MCP only on nodes that receive policy updates * test: check pending MCP answers at the server after revocation * test: refuse stale MCP answers on a dedicated worker * refactor: reuse the worker MCP wire feature for node negotiation * fix: await MCP questions across the private app bridge * test: account for same-node MCP security and compatibility coverage * fix: preserve the MCP work budget while the native host waits for an answer * fix: advertise MCP elicitation without growing the Control UI bundle --------- Co-authored-by: Codex <[email protected]>
* commit 'b4ebd3673fea4932296b92bbc07b7abc4bdc792d': fix(ci): allow serial SDK API reports to finish (#192196) fix(ci): run PostgreSQL checks when its shard planner changes (#191963) fix(ci): model native Linux updater asset entry improve(test): speed up config and device binding browser tests (#192404) improve(ui): show arrivals top right with a contextual session status (#192016) improve(ui): mark error toasts and split two-sentence copy (#192015) fix(sandbox): give dependency builders a writable home (#192390) fix(worktrees): keep archive manifest checks off the main thread (#192358) fix(cron): preserve admitted runs and pacing across unrelated MCP reloads (#192399) improve(ui): stack toasts in a center lane and an arrivals lane (#192014) fix: reclaim abandoned read-only database snapshots (#192368) improve(ui): rebuild the toast on one component with variants and a hover dismiss (#192013) docs: consolidate team server and team setup into one Multiplayer page fix(ci): reconcile remaining unallocated test lines feat: run admitted MCP tools on the worker node that hosts them (#191387)
Builds on the Gateway question flow merged in #191589. This PR targets
mainand adds same-node execution.What Problem This Solves
A dedicated worker can run the model turn on the same node that owns an MCP client. Sending that call through the Gateway serializes the projected result and loses the metadata Code Mode needs to expose it to the model.
User Impact
A compatible worker calls its node's existing MCP client through its supervisor and projects the result in the model process. The MCP server can run on the node or at a remote HTTPS endpoint. In the Slack test, OCE handled OAuth and the worker used a bearer placeholder for Slack’s hosted MCP server. Known timeouts, authentication failures, and incompatible responses reach the model with a bounded, redacted diagnostic. Unexpected exceptions get a generic message.
Why This Change Was Made
The Gateway applies the turn's tool policy and grants a handle only for eligible tools on the selected node. Older workers, tools on other nodes, and tools requiring Gateway hooks retain Gateway dispatch. The node captures permission when the launch arrives. Once the node processes a withdrawal or connection replacement, an old grant cannot start another MCP call. Restoring permission requires a fresh grant for a later turn. The model turn can continue.
When a local tool asks the user for input, the worker presents its Gateway-issued grant from this turn. Only the question and answer use the Gateway. A tool with execution permission alone receives a local decline. Workers using the earlier preview protocol fall back to Gateway dispatch.
Evidence
Question routing. A real HTTP MCP server received
engineeringthrough either execution route. After the user answered, retiring the grant or replacing the pairing prevented delivery on both routes. Ending the originating turn also blocked delivery to a worker that was still waiting. With tool execution alone, the worker declined locally and sent zero Gateway requests. The test controls the paired transport and the answering user. Server-side checksTransport compatibility. The direct node runner can receive the Gateway's local execution policy. The macOS app's private bridge keeps MCP calls on Gateway dispatch. The stdio regression test checks that a configured app worker offers the routed MCP command, omits local execution from its inventory and dispatches a routed invocation. The test uses a stub invocation handler. Older preview workers advertising
worker-local-mcp-v1also use Gateway dispatch.Earlier live Console run on a dedicated worker. With a real Slack account, the first turn of revision 1 returned the exact clickable thread permalink in Slack's MCP result, including its thread timestamp. The Gateway trace covered one worker launch and 17 worker control frames. It recorded one admitted search handle, zero worker-to-Gateway invocations for that handle, and zero Gateway-to-node MCP invocations. This run used the OCE runtime backport at e38c4e63 before the diagnostic and launch-race fixes below.
What reaches the MCP server. The integration test uses the production Gateway registry, worker supervisor and node MCP client, and sends requests to a real loopback HTTP MCP server. The Gateway socket, worker process, journal and turn descriptors are controlled test fixtures. The server counts incoming
tools/callframes before it dispatches them. Each successful control also executes the tool.tools/callRun
node scripts/test-projects.mts src/node-host/node-worker-mcp.authority.integration.test.tsto reproduce the server request counts. Other tests exercise turn admission, remote or older workers, live pairing changes, Code Mode result projection, cancellation, and Linux supervisor process ownership.Launch race. On the previously reviewed head
f04d03a9, withdrawing and restoring permission while workspace admission was paused let a queued launch invoke the MCP client once, for both a fresh and a retained child. With this fix, both reject the old handle before invoking the client. Separate ingress coverage checks that the model turn's cancellation signal stays live.The local upstream tests used an existing dependency installation because the registry's package-age rule deferred one dependency in a clean install.
The test allocation covers 1,019 net lines for worker admission, permission withdrawal on retained workers, server request counts, pending answers, result projection and transport fallback. The routed and same-node Gateway event suite passed all 28 tests.
CI
On
5f93758e1fa, all 28 Gateway event tests and all three worker-local MCP tests passed. The repository's test-line check passed after incorporating the baseline reconciliation from main (6,444,905 lines against a ceiling of 6,444,915). Upstream correction · CI for this head