Repository navigation
fix(node-host): recover MCP catalogs and sessions - #125092
Conversation
Share placement-neutral MCP lifecycle and result projection while keeping Gateway session ownership and node process ownership separate. Refresh node catalogs live, recover closed or expired transports without replay, and preserve MCP application errors across node.invoke.\n\nFixes #125044
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 2:38 AM ET / 06:38 UTC. ClawSweeper reviewWhat this changesThe PR centralizes MCP client lifecycle and result projection, then makes node-hosted MCP catalogs refresh and recover live after transport closure or stateful HTTP-session expiry. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open for protected maintainer handling. Current main still has the reported one-shot catalog behavior, and the PR provides a coherent node-lifecycle owner with focused and real-process coverage; no concrete patch defect was found in this review. Priority: P1 Review scores
Verification
How this fits togetherNode-hosted MCP connects external tool servers to a paired OpenClaw node, which publishes tool descriptors through the Gateway for agents. This change governs connection recovery, descriptor publication, and the resulting tool-call payloads. flowchart LR
A[MCP servers] --> B[Node-host MCP client]
B --> C[Catalog and recovery manager]
C --> D[Paired Gateway]
D --> E[Agent tool catalog]
E --> F[Tool call]
F --> B
B --> G[Model-visible result]
Decision needed
Why: The protected maintainer label and cross-owner lifecycle refactor require explicit human architectural acceptance despite no concrete patch defect. Before merge
Agent review detailsSecurityNone. PR surfaceSource +222, Tests +1963, Docs +6, Other +2. Total +2193 across 20 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one shared lifecycle/result-projection path and one node-local catalog recovery owner, then land after protected maintainer approval. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main performs initial listing and only withdraws descriptors on close, leaving no live refresh or reconnect path. This review did not execute it because node_modules are absent. Is this the best way to solve the issue? Yes, as far as source establishes: session/requester ownership stays separate while shared lifecycle work is extracted once and node process recovery remains local. Direct MCP SDK inspection is the remaining reviewer-side limitation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ac5c8be00196. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Maintainer merge review is complete for exact head Evidence:
Dependency contract confirmation for the ClawSweeper rank-up move:
The +222 net production lines are accepted as the smallest coherent owner boundary after the simplification passes: shared lifecycle/result projection replaces duplicate placement code, while the node-local state machine adds the missing process-lifetime catalog refresh, stale-session fencing, bounded retry, and reconnect ownership. ClawSweeper reported no code findings; its dependency-contract, positive-LOC, maintainer-review, and exact-head-CI items are now resolved. Authenticated external-model proof remains explicitly limited: both approved OpenAI keys reached the real Responses endpoint but returned HTTP 401, so this PR does not claim a successful external-model call. |
|
Merged via squash.
|
* fix(node-host): recover MCP catalogs and sessions Share placement-neutral MCP lifecycle and result projection while keeping Gateway session ownership and node process ownership separate. Refresh node catalogs live, recover closed or expired transports without replay, and preserve MCP application errors across node.invoke.\n\nFixes openclaw#125044 * test: register node MCP CI inventory * fix(node-host): stop MCP recovery after abort
What Problem This Solves
Node-hosted MCP reused the same configuration and low-level transport/filter primitives as Gateway/session MCP, but independently reimplemented client lifecycle and result projection. That drift left node tool catalogs stale after
tools/list_changed, left expired stateful Streamable HTTP sessions broken until restart, abandoned server-side HTTP sessions during shutdown, and converted MCP application errors into failed node RPCs.Closes #125044.
Why This Change Was Made
Keeps the two correct architectural owners—session/requester lifetime in the Gateway and process lifetime on the node—while moving placement-neutral behavior into shared MCP primitives.
The shared client-lifecycle owner now handles initialize deadlines, parent aborts, bounded teardown, forced stdio cleanup, Streamable HTTP termination, and exact stateful-session expiry classification. The node owner now serializes per-server refresh/recovery, globally rebuilds the bounded descriptor catalog, republishes only effective changes, and reconnects with bounded backoff. The current published descriptor array remains the sole call authority.
The result projector now preserves the MCP contract:
CallToolResult.isErroris delivered as a model-visible failed tool result with structured and non-text content, while unavailable servers, unpublished tools, timeouts, and transport/protocol failures remain failednode.invokeRPCs.AI-assisted: yes. The implementation received independent architecture, proof-coverage, dependency-contract, result-semantics, recovery, simplification, and structured autoreview passes. No agent transcript is attached.
User Impact
Node-hosted MCP tools now update live when the server changes its catalog. Closed stdio/SSE/HTTP transports and expired stateful Streamable HTTP sessions withdraw stale tools and recover without restarting the node host. The call that discovers an expired session still fails once and is never replayed; later calls use the replacement connection after republishing.
Gateway/session MCP behavior is unchanged except for sharing the same lifecycle and result-projection owners. Node MCP application errors now retain useful structured content so the model can correct its request.
Evidence
openclaw node runE2E: passed.node.pluginTools.updatepublication andnode.invokecalls;tools/list_changed;tools.effectivenode inventory and disconnect cleanup.tbx_01m072smmrmhprtjfzbanbw8jz(run); format, ratchets, dead exports, core/core-test/root typechecks, core/scripts lint, import cycles, and architecture guards all passed.2a4005519d52d396d926ff2d3970559a4d9f67b4(run).@modelcontextprotocol/sdk1.30.0 source for status-preservingStreamableHTTPError, session-ID handling, DELETE termination, abort propagation, and close-on-initialize-failure.92cbfb4d2431for stateful-404-only expiry classification, single-flight session reinitialization, DELETE termination, and owned stdio shutdown.Production LOC: +571/-349 (net +222) | Tests/support: +2005/-42 | Docs/ratchets/tooling: +10/-2. The production growth is the process-lifetime node recovery/catalog owner plus shared bounded lifecycle handling; duplicate per-placement projectors and teardown paths were removed.