Skip to content

fix(mcp): hide disconnected server catalogs during recovery - #165158

Merged
steipete merged 2 commits into
mainfrom
fix/w8-mcp
Oct 5, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/w8-mcp

Conversation

@steipete

@steipete steipete commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

When a connected MCP server died (a stdio process crashed, or an SSE session expired), its tools, resources, and prompts stayed in the model's tool list while recovery was in progress. The model kept calling tools that could only fail, and those failures said nothing useful about the server being down.

Why This Change Was Made

Recovery in src/agents/agent-bundle-mcp-runtime.ts kept the last successful catalog for the disconnected server (introduced in 36f5e61f4eb5). The runtime now projects a disconnected server's catalog as unavailable while recovery runs. Its tools, resource, and prompt utilities are hidden through the normal gating, healthy sibling servers are unaffected, and a successful reconnect restores the catalog. This follows the repo rule that unavailable tools are hidden by gating rather than left to fail. A small extraction keeps the runtime file within the line cap and moves the recovery fixture next to its tests.

User Impact

Agents stop calling tools from a crashed or expired MCP server and pick them up again when it reconnects.

Evidence

  • New regressions kill a stdio server and expire an SSE session. Before the fix, the dead server's utilities remained model-visible; after, they disappear during recovery, siblings keep working, and reconnection restores them.
  • Lane proof on Blacksmith Testboxes: full build, full related MCP suites, stdio and HTTP discovery, isolation and recovery from malformed schemas, and 4,096 tools with eight concurrent readers.
  • Production +36/-24; tests and support +555/-462, mostly fixture relocation.

Clear the per-server tool and utility inventory when its transport must be replaced. Keep the failure diagnostic and background retry while leaving healthy sibling servers available.

Regression proof: original code exposed five disconnected stdio entries and an expired SSE tool. Both fail-before regressions pass with the fix; the full runtime and SSE suites pass 68 tests on Blacksmith Testbox.

(cherry picked from commit be29b51c97d95c4f64a75cda0eda804923adb9cf)
…ixture

Keep transport lifetime in the runtime and project unavailable catalogs through the existing catalog owner. Extract shared stdio support and the process-recovery regression so the fix respects line-cap guards without dropping coverage. Full related MCP suites pass on Blacksmith; formatter output is synchronized from the remote proof checkout.

(cherry picked from commit fb28e3c40a6a4574b0869b01a80311283d23d6fa)
@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 4, 2026 22:16
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: XL labels Oct 4, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 4, 2026
@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed October 4, 2026, 6:27 PM ET / 22:27 UTC (Revision 2).

ClawSweeper review

What this changes

The PR hides a disconnected MCP server’s tools, resources, and prompts during recovery, preserves healthy servers, and extracts shared recovery fixtures.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this is a focused recovery fix that fetched main still needs, with no blocking correctness finding.

Likely related people: steipete and Ayaan Zaidi, based on recent MCP runtime work.

Priority: P2
Reviewed head: ef602950bd1078bb67e46d87f0e8affc1c174c70

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable repair with meaningful recovery coverage and no identified blocking code defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a MEMBER author, so ordinary external-contributor proof is exempt. The reported Blacksmith runs target MCP discovery and recovery; inspected stdio coverage uses the production runtime and a real subprocess, while SSE uses mocked fetch. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a MEMBER author, so ordinary external-contributor proof is exempt. The reported Blacksmith runs target MCP discovery and recovery; inspected stdio coverage uses the production runtime and a real subprocess, while SSE uses mocked fetch. No stored-data contract changes.
Evidence reviewed 7 items Pinned introduced change: The merge-base-to-head production diff replaces retention of the failed server’s catalog with an empty catalog carrying its diagnostic. Transport ownership, retry scheduling, and execution guards remain with the existing runtime.
Discovery and sibling isolation: The projection clears tools and server capability metadata. Materialization derives resource and prompt utilities from that metadata; the combined runtime independently merges each server’s current catalog, preserving healthy siblings.
Current-main necessity: Fetched main still spreads currentCatalog into its retry snapshot, retaining disconnected entries. This PR therefore provides a distinct repair. Inspection of the latest release blob failed because its object was unavailable and the promisor fetch returned HTTP 403; shipped-release coverage is unknown.
Findings None None.
Security None None.

How this fits together

OpenClaw’s MCP runtime connects configured servers and turns their catalogs into agent tools. Per-server catalogs are combined for discovery, while transport failures trigger background recovery.

flowchart TD
  A[Configured MCP servers] --> B[Per-server connections]
  B --> C[Connection available]
  C -->|Yes| D[Loaded catalog]
  C -->|No| E[Empty catalog with diagnostic]
  E --> B
  D --> F[Combined discovery]
  E --> F
  F --> G[Agent tools and utilities]
Loading

Before merge

  • Complete next step (P2) - Record measured pnpm test <file> --maxWorkers=1 wall times for the new or materially changed test files and available CI seconds in the PR Evidence section.
Agent review details

Security

None.

PR surface

Source +12, Tests +93, Docs +5. Total +110 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 2 36 24 +12
Tests 4 555 462 +93
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 596 486 +110

Review metrics

None.

Technical review

Best possible solution:

Keep transport recovery in the existing runtime and expose only currently available catalogs through the shared discovery projection.

Do we have a high-confidence way to reproduce the issue?

Yes, source establishes the failure path: an established transport closes or expires, and main retains its previous catalog during retry. The focused regressions exercise those triggers; this review did not execute them.

Is this the best way to solve the issue?

Yes. Updating the existing per-server catalog projection repairs discovery without adding a competing recovery owner, changing configuration, or replaying failed calls.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 42ebb9d73483.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs misleading MCP discovery during a server outage with a limited per-server blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies a MEMBER author, so ordinary external-contributor proof is exempt. The reported Blacksmith runs target MCP discovery and recovery; inspected stdio coverage uses the production runtime and a real subprocess, while SSE uses mocked fetch. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add measured single-worker wall times for the new or materially changed test files and available CI seconds to the PR Evidence section.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-04T22:22:18.436Z sha ef60295 :: needs changes before merge. :: none

@steipete
steipete merged commit f04c2c0 into main Oct 5, 2026
196 of 199 checks passed
@steipete
steipete deleted the fix/w8-mcp branch October 5, 2026 02:16
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
…#165158)

* fix(mcp): hide disconnected server catalogs during recovery

Clear the per-server tool and utility inventory when its transport must be replaced. Keep the failure diagnostic and background retry while leaving healthy sibling servers available.

Regression proof: original code exposed five disconnected stdio entries and an expired SSE tool. Both fail-before regressions pass with the fix; the full runtime and SSE suites pass 68 tests on Blacksmith Testbox.

(cherry picked from commit be29b51c97d95c4f64a75cda0eda804923adb9cf)

* refactor(mcp): separate unavailable catalog projection and recovery fixture

Keep transport lifetime in the runtime and project unavailable catalogs through the existing catalog owner. Extract shared stdio support and the process-recovery regression so the fix respects line-cap guards without dropping coverage. Full related MCP suites pass on Blacksmith; formatter output is synchronized from the remote proof checkout.

(cherry picked from commit fb28e3c40a6a4574b0869b01a80311283d23d6fa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant