Skip to content

feat: add MCP code-mode namespace#88636

Merged
steipete merged 2 commits into
mainfrom
codex/code-mode-mcp-namespace
May 31, 2026
Merged

feat: add MCP code-mode namespace#88636
steipete merged 2 commits into
mainfrom
codex/code-mode-mcp-namespace

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • Add MCP metadata to bundled MCP catalog entries and carry it into the Tool Search catalog.
  • Generate a code-mode-only MCP namespace grouped by MCP server, with tools plus resource/prompt helpers dispatching through exact catalog ids.
  • Reject direct MCP tools.call(...) attempts in code mode so MCP calls have one supported path.
  • Document the MCP namespace contract and add regressions for tool calls, resource/prompt helpers, default argument mapping, unsafe identifier suffixing, and direct-call rejection.

Verification

  • node scripts/run-vitest.mjs src/agents/code-mode.test.ts src/agents/agent-bundle-mcp-tools.materialize.test.ts -- --reporter=dot
  • PATH="/opt/homebrew/opt/node@24/bin:$PATH" node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo && PATH="/opt/homebrew/opt/node@24/bin:$PATH" node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core-test.tsbuildinfo
  • pnpm build
  • pnpm exec oxfmt --check docs/reference/code-mode.md src/agents/agent-bundle-mcp-materialize.ts src/agents/agent-bundle-mcp-tools.materialize.test.ts src/agents/code-mode-namespaces.ts src/agents/code-mode.test.ts src/agents/code-mode.ts src/agents/tool-search.ts src/plugins/tools.ts
  • git diff --check
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main

Known unrelated local gate issues seen during verification:

Real behavior proof

Behavior addressed: MCP tools in code mode now have one supported call path: generated MCP.<server>.<tool>(...) namespace calls.
Real environment tested: Local OpenClaw checkout on macOS, Node 24 for typecheck and Node 26 for build/test runner defaults.
Exact steps or command run after this patch: node scripts/run-vitest.mjs src/agents/code-mode.test.ts src/agents/agent-bundle-mcp-tools.materialize.test.ts -- --reporter=dot; pnpm build; final autoreview command above.
Evidence after fix: Code-mode regression tests show MCP.github.createIssue(...), MCP.docs.resources.read(...), and MCP.docs.prompts.get(...) dispatch through exact catalog ids, while direct tools.github__create_issue(...) rejects.
Observed result after fix: MCP namespace calls return full tool results, schema defaults are applied, unsafe namespace identifiers are suffixed, and direct MCP calls fail closed with the new error.
What was not tested: A live external MCP server call through a real provider session; CI will cover the hosted Linux lanes after PR creation.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels May 31, 2026
@clawsweeper

clawsweeper Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed May 31, 2026, 9:39 AM ET / 13:39 UTC.

Summary
The PR adds MCP metadata to bundled MCP catalog entries, generates a code-mode MCP namespace for tools/resources/prompts, and rejects direct MCP calls through tools.call.

PR surface: Source +325, Tests +219, Docs +30. Total +574 across 8 files.

Reproducibility: yes. for the review finding by source inspection: a code-mode snippet that searches/describes an MCP entry and then calls tools.call(id, args) is forwarded in v2026.5.28 but throws after this PR's new MCP source check.

Review metrics: 2 noteworthy metrics.

  • Code-mode API compatibility: 1 shipped call path removed. The PR removes direct MCP calls through the generic code-mode tool bridge that shipped in v2026.5.28.
  • Code-mode global surface: 1 added (MCP). A new global namespace becomes part of the user-facing code-mode contract and should be reviewed as an API addition.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🌊 off-meta tidepool
Patch quality: 🦪 silver shellfish
Result: blocked by patch quality or review findings.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Preserve direct MCP tools.call compatibility or add maintainer-approved deprecation/migration evidence.
  • [P2] Add or cite live MCP/provider proof if maintainers want confidence beyond the mocked MCP runtime tests.

Risk before merge

  • [P1] Merging as-is would make shipped code-mode MCP calls through tools.call(id, args) or unambiguous tools.<name>(args) convenience functions throw during upgrade.
  • [P1] The PR body records local regression/build validation but explicitly does not test a live external MCP server call through a real provider session.

Maintainer options:

  1. Preserve MCP direct-call compatibility (recommended)
    Keep tools.call and generated convenience calls working for MCP entries while adding docs/tests that present MCP.<server>... as the preferred path.
  2. Approve a breaking MCP code-mode change
    Maintainers can intentionally keep the fail-closed behavior, but the PR should carry explicit release-note and migration rationale for shipped code-mode users.
  3. Pause for live MCP proof
    If the API direction is still uncertain, pause until a live MCP/provider session proves the namespace path and upgrade behavior end to end.

Next step before merge

  • [P1] The blocker is a maintainer API-compatibility decision because the branch intentionally makes the new MCP namespace the only supported path.

Security
Cleared: No concrete security or supply-chain regression found; the diff adds no dependencies, workflows, secret handling, or external downloads, and namespace dispatch still uses exact catalog ids through the existing executor.

Review findings

  • [P1] Keep shipped MCP tools.call compatibility — src/agents/code-mode.ts:522-526
Review details

Best possible solution:

Land the MCP namespace as an additive preferred API while preserving the shipped generic MCP tools.call path, unless maintainers explicitly approve a documented deprecation or migration window.

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

Yes for the review finding by source inspection: a code-mode snippet that searches/describes an MCP entry and then calls tools.call(id, args) is forwarded in v2026.5.28 but throws after this PR's new MCP source check.

Is this the best way to solve the issue?

No as written: the generated MCP namespace is a good additive direction, but making it the only supported path breaks the shipped generic catalog-call contract.

Full review comments:

  • [P1] Keep shipped MCP tools.call compatibility — src/agents/code-mode.ts:522-526
    This change rejects every code-mode call whose described catalog source is mcp. In v2026.5.28 the bridge forwarded tools.call(id, args) directly, and the docs tell users to call described catalog entries through tools.call; MCP entries are also catalog entries. Existing code-mode snippets that search/describe an MCP tool and call its id will now fail, so keep the generic MCP call path working while adding the MCP namespace, or add an explicit maintainer-approved deprecation/migration path.
    Confidence: 0.86

Overall correctness: patch is incorrect
Overall confidence: 0.86

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 5dc4531fdf56.

Label changes

Label changes:

  • add P2: This is a normal-priority feature PR with a concrete compatibility blocker but limited blast radius before merge.
  • add merge-risk: 🚨 compatibility: The diff changes a shipped code-mode calling contract by making existing MCP tools.call snippets fail closed.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The PR is maintainer-labeled, so the external-contributor proof gate does not apply; the body records local runtime tests/builds but no live external MCP session.

Label justifications:

  • P2: This is a normal-priority feature PR with a concrete compatibility blocker but limited blast radius before merge.
  • merge-risk: 🚨 compatibility: The diff changes a shipped code-mode calling contract by making existing MCP tools.call snippets fail closed.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The PR is maintainer-labeled, so the external-contributor proof gate does not apply; the body records local runtime tests/builds but no live external MCP session.
Evidence reviewed

PR surface:

Source +325, Tests +219, Docs +30. Total +574 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 5 341 16 +325
Tests 2 220 1 +219
Docs 1 41 11 +30
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 602 28 +574

What I checked:

  • Protected maintainer review context: The live PR context has the protected maintainer label, so this workflow should not close it even though the compatibility issue is concrete. (fe2e38e373e8)
  • Repository policy applied: Root policy treats plugin/MCP surfaces and fail-closed behavior as compatibility-sensitive, which makes the direct-call removal a merge risk rather than a routine cleanup. (AGENTS.md:23, 5dc4531fdf56)
  • Shipped direct call behavior: In v2026.5.28, code-mode call forwarded the requested id to params.runtime.call(...) with no MCP carveout, so MCP catalog ids remained callable through the generic bridge. (src/agents/code-mode.ts:503, e93216080aa1)
  • Shipped docs contract: The v2026.5.28 code-mode docs instruct guest code to call described catalog entries via tools.call(fileRead.id, ...) and do not exclude MCP entries. Public docs: docs/reference/code-mode.md. (docs/reference/code-mode.md:427, e93216080aa1)
  • MCP catalog classification: Current main classifies bundled MCP tools as catalog source mcp, so the PR's new source check targets real visible catalog entries. (src/agents/tool-search.ts:608, 5dc4531fdf56)
  • Patch-introduced rejection: The PR changes the code-mode call bridge to describe the id and throw when the catalog entry source is mcp. (src/agents/code-mode.ts:522, fe2e38e373e8)

Likely related people:

  • steipete: Recent GitHub commit history ties this handle to generic code mode, internal code-mode namespaces, MCP operability, and this PR's branch. (role: feature owner and recent area contributor; confidence: high; commits: 0844e771a8df, 287687da2098, 38d3d11cbc0c; files: src/agents/code-mode.ts, src/agents/code-mode-namespaces.ts, src/agents/agent-bundle-mcp-materialize.ts)
  • SebTardif: Co-authored recent Tool Search catalog reuse work that affects the catalog/runtime surface this PR extends. (role: adjacent Tool Search contributor; confidence: medium; commits: 60e8e60306e8; files: src/agents/tool-search.ts)
  • Pluviobyte: Co-authored recent MCP materialization work around structured MCP tool results in the same bundled MCP projection file. (role: adjacent MCP materialization contributor; confidence: medium; commits: 2df8021cdab8; files: src/agents/agent-bundle-mcp-materialize.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fe2e38e373

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +675 to +677
const mcpEntry = createMcpNamespaceEntry(catalog);
if (mcpEntry) {
entries.push(mcpEntry);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reserve the built-in MCP namespace id

If any registered plugin namespace uses id mcp with a different global name, this new built-in MCP entry is serialized for the MCP global, but createCodeModeNamespaceRuntime later builds byId from all entries and the plugin registration wins the same mcp key. In runs with visible MCP tools, MCP.<server>.<tool>(...) will then resolve against the plugin namespace and fail as not callable; reserve/reject the mcp id or make the built-in namespace id collision-proof.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels May 31, 2026
@openclaw-barnacle openclaw-barnacle Bot added the channel: discord Channel integration: discord label May 31, 2026
@steipete
steipete merged commit ec8cb8b into main May 31, 2026
151 of 153 checks passed
@steipete
steipete deleted the codex/code-mode-mcp-namespace branch May 31, 2026 14:02
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 1, 2026
* feat: add MCP code-mode namespace

* fix: unblock mcp namespace ci gates
SYU8384 pushed a commit to SYU8384/openclaw that referenced this pull request Jun 3, 2026
* feat: add MCP code-mode namespace

* fix: unblock mcp namespace ci gates
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
* feat: add MCP code-mode namespace

* fix: unblock mcp namespace ci gates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: discord Channel integration: discord docs Improvements or additions to documentation maintainer Maintainer-authored PR rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant