Skip to content

fix(nodes): keep MCP calls within the published catalog - #124652

Merged
steipete merged 2 commits into
mainfrom
steipete/gateway-mcp-stress-testing-93f04b
Aug 16, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/gateway-mcp-stress-testing-93f04b

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #124580

What Problem This Solves

Fixes an issue where node-hosted MCP could execute tools omitted from its bounded published catalog, and where a tool remained advertised after its backing MCP server disconnected.

Why This Change Was Made

The bounded node MCP descriptor list is now the sole call-authority set. When a connected MCP server closes, the node removes that server's descriptors in place and republishes the surviving MCP and plugin inventory. The same change removes obsolete configuredServerCount bookkeeping and shrinks the assertion-safety baseline after the production cleanup.

The fix stays inside the node-host MCP owner: no protocol, config, storage, migration, or compatibility surface changes.

AI-assisted: yes. The architecture, live evidence, implementation, simplification, and final diff were reviewed directly; no agent transcript is attached.

User Impact

Operators can trust the Gateway's node tool inventory as the actual callable MCP surface. Tools dropped by count or byte limits cannot be reached through raw mcp.tools.call.v1, and dead MCP servers disappear from new agent turns while healthy sibling servers and ordinary node plugin tools remain available.

Evidence

  • Pre-fix bounded-catalog reproduction: a server listed 130 tools, published 128, and an omitted tool was still callable.
  • Post-fix reproduction: the same omitted tool returns MCP_TOOL_UNAVAILABLE.
  • Authenticated isolated Gateway proof with openai/gpt-5.6-luna: the model used the nodes tool to invoke a node-local MCP server, received an unprompted MCP-only nonce, and returned it exactly.
  • The same live run used official Everything, Filesystem, and Memory MCP reference servers plus a controlled local server; stopping only the controlled server removed all flaky_* tools from both node.list and tools.effective while the node stayed connected.
  • Blacksmith Testbox tbx_01m05az9achqcch9hcws2r676y (run 31948957813):
    • exact source build passed;
    • 107 focused node-host/invoke/agent-tool tests passed;
    • process-boundary Gateway + node + MCP publication/withdrawal proof passed on Linux/Node 24.
  • Rebased exact-path check:changed passed, including production/test typecheck, core lint, architecture guards, import cycles, formatting, and assertion ratchets.
  • Rebased focused Vitest proof: 106 tests passed.
  • Rebased pnpm build passed.
  • Final Codex autoreview: clean, no accepted or actionable findings.

Production LOC: +62/-70 (net -8) | Tests: +96/-85 (net +11) | Ratchet metadata: +2/-2.

Provenance: the split discovered-tool/published-descriptor authority entered with #90431 on 2026-07-11; this repair makes the bounded descriptor catalog canonical for both visibility and invocation.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 16, 2026
@steipete
steipete marked this pull request as ready for review August 16, 2026 15:00
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 11:07 AM ET / 15:07 UTC.

ClawSweeper review

What this changes

This PR makes the bounded node-host MCP tool catalog both the published inventory and the sole callable tool set, and removes entries when their MCP server closes.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for normal maintainer landing: current main still has the proven split between published descriptors and callable MCP tools, while this PR is the linked repair. No concrete patch defect was found; exact PR blobs could not be materialized locally because the partial checkout’s remote was offline.

Priority: P1
Reviewed head: 77a92767d2591ea479234b94079c237ecb64e3d9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The reported process-boundary proof and owner-boundary repair are strong; refresh the exact-head review once the promised blobs are available.
Proof confidence 🦞 diamond lobster (5/6) Not applicable: This maintainer PR includes detailed authenticated Gateway and Testbox after-fix evidence; the external-contributor proof gate does not apply.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer PR includes detailed authenticated Gateway and Testbox after-fix evidence; the external-contributor proof gate does not apply.
Evidence reviewed 8 items Current defect source: Current main records all discovered tool names in each session, but separately bounds the published descriptors, so an omitted tool can remain callable.
Correct enforcement owner: The node invocation handler delegates decoded MCP server and tool parameters directly to the MCP manager.
Publication callback boundary: The runtime combines node plugin tools with MCP descriptors and sends inventory changes to the runner for Gateway publication.
Findings None None.
Security None None.

How this fits together

A node host discovers tools from configured MCP servers and publishes a bounded inventory to the Gateway for agent use. Later node invocations return to the MCP manager, so the published inventory and invocation authorization must remain aligned.

flowchart LR
  A[Configured MCP servers] --> B[Node host discovery]
  B --> C[Bounded published catalog]
  C --> D[Gateway tool inventory]
  D --> E[Agent or raw node invocation]
  E --> F[Node-host call authorization]
  B --> G[Server close event]
  G --> C
Loading

Before merge

  • Resolve merge risk (P1) - Existing direct callers of a tool omitted from the published catalog will intentionally receive MCP_TOOL_UNAVAILABLE after merge; that is the intended authority correction.
  • Resolve merge risk (P1) - The exact PR source blobs could not be read locally while the partial clone’s remote was unavailable, so the exact-head diff and checks should be refreshed before merge.
  • Complete next step (P2) - This maintainer-labeled PR should proceed through the normal exact-head maintainer merge gate rather than an automated repair lane.
Agent review details

Security

None.

PR surface

Source -8, Tests +11, Other 0. Total +3 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 2 62 70 -8
Tests 6 96 85 +11
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 2 0
Total 9 160 157 +3

Review metrics

Metric Value Why it matters
Production vs test LOC production +62/-70 (net -8); tests +96/-85 (net +11); ratchet metadata +2/-2 The repair reduces production code while adding focused authority and inventory-withdrawal coverage.

Merge-risk options

Maintainer options:

  1. Land the authority correction (recommended)
    Accept that unsupported direct calls to bounded-out tools will now fail because the published catalog becomes the callable security boundary.

Technical review

Best possible solution:

Make the mutable published descriptor catalog the MCP manager’s one authority set, withdraw a closed server through the existing inventory callback, and retain focused manager/runtime plus process-boundary proof.

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

Yes. Current main separately stores discovered tools for invocation and bounds published descriptors, so the supplied 130-tool path is source-reproducible.

Is this the best way to solve the issue?

Yes. The MCP manager is the invocation owner and the runtime already owns inventory republishing; the approach removes the divergent authority set rather than adding a downstream guard.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b90d7efddbc0.

Labels

Label changes:

  • add P1: A node-host MCP authority boundary can expose callable tools that the Gateway did not publish.
  • add merge-risk: 🚨 compatibility: The patch intentionally makes raw calls to bounded-out MCP tools unavailable.
  • add merge-risk: 🚨 security-boundary: The patch changes MCP invocation authority to the published bounded catalog.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer PR includes detailed authenticated Gateway and Testbox after-fix evidence; the external-contributor proof gate does not apply.

Label justifications:

  • P1: A node-host MCP authority boundary can expose callable tools that the Gateway did not publish.
  • merge-risk: 🚨 compatibility: The patch intentionally makes raw calls to bounded-out MCP tools unavailable.
  • merge-risk: 🚨 security-boundary: The patch changes MCP invocation authority to the published bounded catalog.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer PR includes detailed authenticated Gateway and Testbox after-fix evidence; the external-contributor proof gate does not apply.

Evidence

What I checked:

  • Current defect source: Current main records all discovered tool names in each session, but separately bounds the published descriptors, so an omitted tool can remain callable. (src/node-host/mcp.ts:369, b90d7efddbc0)
  • Correct enforcement owner: The node invocation handler delegates decoded MCP server and tool parameters directly to the MCP manager. (src/node-host/invoke.ts:1088, b90d7efddbc0)
  • Publication callback boundary: The runtime combines node plugin tools with MCP descriptors and sends inventory changes to the runner for Gateway publication. (src/node-host/runtime.ts:354, b90d7efddbc0)
  • Existing regression coverage: Current tests establish the 128-descriptor bound but do not require an omitted discovered tool to be unavailable for invocation. (src/node-host/mcp.test.ts:209, b90d7efddbc0)
  • Feature provenance: The node-hosted MCP feature and its paired-node publication design were introduced by the merged feature commit. (src/node-host/mcp.ts:352, 49b5b862acf3)
  • Base remains current on this surface: No changed path from this PR differs between its base and current main; the branch is behind only on unrelated main changes. (src/node-host/mcp.ts:1, b90d7efddbc0)

Likely related people:

  • steipete: Authored the merged node-host feature and is identified by current source blame on the MCP manager and runtime boundary. (role: feature owner and recent area contributor; confidence: high; commits: 49b5b862acf3, 509f947a20fa; files: src/node-host/mcp.ts, src/node-host/runtime.ts)

Rank-up moves

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

  • Refresh the exact-head diff and relevant checks before merge.

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.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 77a92767d2591ea479234b94079c237ecb64e3d9:

  • Exact-head CI: run 31954349862 — green.
  • Focused rebased tests: node scripts/run-vitest.mjs src/node-host/mcp.test.ts src/node-host/runner.test.ts src/node-host/runtime.test.ts src/node-host/runtime.worker-supervisor.test.ts src/node-host/runner.optional-publication.test.ts src/node-host/invoke.mcp.test.ts src/agents/node-plugin-tools.test.ts — 106 passed.
  • Exact-path changed gate: env OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 node scripts/check-changed.mjs -- config/assertion-safety-baseline.txt src/node-host/invoke.mcp.test.ts src/node-host/mcp.test.ts src/node-host/mcp.ts src/node-host/runner.optional-publication.test.ts src/node-host/runner.test.ts src/node-host/runtime.test.ts src/node-host/runtime.ts src/node-host/runtime.worker-supervisor.test.ts — passed.
  • Rebased pnpm build — passed.
  • Blacksmith Testbox tbx_01m05az9achqcch9hcws2r676y (run 31948957813) — build plus 107 focused tests passed; isolated Gateway/node/MCP publication-withdrawal proof passed on Linux/Node 24.
  • Authenticated isolated local proof: OpenAI invoked node-local MCP through the model-visible nodes tool, received an unprompted MCP-only nonce, returned it exactly, then the controlled server exited and all of its tools disappeared from node.list and tools.effective while healthy Everything, Filesystem, and Memory MCP tools remained.
  • Final branch autoreview — clean, no accepted/actionable findings.
  • git diff --check origin/main...HEAD — passed.

ClawSweeper rank-up move applied: exact-head diff/checks were refreshed before merge. Its compatibility/security-boundary note is intentional: tools omitted from the bounded published catalog now fail closed with MCP_TOOL_UNAVAILABLE.

Known proof detail: the Testbox profile did not hydrate an OpenAI credential, so the authenticated provider turn ran against an isolated local Gateway with the key loaded from 1Password; the source build, Linux process boundary, and exact-head CI remained independently proven on Testbox/GitHub.

@steipete
steipete merged commit 146350f into main Aug 16, 2026
228 checks passed
@steipete
steipete deleted the steipete/gateway-mcp-stress-testing-93f04b branch August 16, 2026 15:20
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 17, 2026
)

* fix(nodes): align MCP calls with published catalog

* chore(tests): shrink assertion safety baseline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

[Bug]: Node-host MCP invokes tools outside its published catalog

1 participant