Skip to content

feat: add code-mode MCP API files - #88763

Merged
steipete merged 2 commits into
mainfrom
feat/code-mode-mcp-api-files
May 31, 2026
Merged

steipete merged 2 commits into
mainfrom
feat/code-mode-mcp-api-files

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • add virtual API.list() / API.read() declaration files for code-mode MCP namespaces (mcp/index.d.ts, mcp/<server>.d.ts)
  • expose MCP calls through MCP.<server>.<tool>() in code mode while keeping MCP tools hidden from the model-visible tool list
  • preserve plugin metadata across provider tool-schema normalization so MCP tools stay classified after OpenAI Responses normalization
  • add deterministic and live Docker gateway smokes that make an agent read the API files, call a file-backed MCP fixture, and prove no $api() / tools.search pollution

Verification

  • node scripts/run-vitest.mjs src/agents/runtime-plan/tools.test.ts src/agents/code-mode.test.ts test/scripts/docker-e2e-plan.test.ts src/agents/embedded-agent-runner/run/attempt-tool-construction-plan.test.ts -- --reporter=dot
  • pnpm check:test-types
  • bash -n scripts/e2e/mcp-code-mode-gateway-docker.sh scripts/e2e/mcp-code-mode-gateway-live-docker.sh && node --check scripts/e2e/mock-openai-server.mjs
  • pnpm test:docker:mcp-code-mode-gateway
  • pnpm test:docker:live-mcp-code-mode-gateway
  • .agents/skills/autoreview/scripts/autoreview --mode local --prompt 'Review only the MCP code-mode/API-file/docker-e2e/runtime-plan changes. Ignore unrelated pre-existing dirty packages/*/dist files in this checkout. The prior finding about exec/wait allowlists was addressed by removing the MCP allowlist bypass; confirm no remaining actionable issues.'

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts docker Docker and sandbox tooling agents Agent runtime and tooling extensions: qa-lab size: XL 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, 4:22 PM ET / 20:22 UTC.

Summary
The branch adds code-mode virtual API.list()/API.read() declaration files for MCP namespaces, preserves tool metadata through provider normalization, and adds docs plus deterministic/live Docker MCP Gateway smoke scripts.

PR surface: Source +189, Tests +111, Docs +3, Config +2, Other +717. Total +1022 across 18 files.

Reproducibility: not applicable. for a feature PR. Current main lacks the new API.list/API.read code-mode surface, and the PR adds tests plus Docker smokes for the new behavior.

Review metrics: 2 noteworthy metrics.

  • Code-mode API surface: 1 global added, 2 methods exposed. API.list and API.read become a new code-mode contract that agents can rely on during MCP calls.
  • Docker automation surface: 2 package scripts, 2 scenario lanes added. The PR changes deterministic and live Docker planning, including a new OpenAI-backed live lane.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof is added.

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

Rank-up moves:

  • [P1] Add redacted output or a linked artifact from pnpm test:docker:mcp-code-mode-gateway and pnpm test:docker:live-mcp-code-mode-gateway.
  • Confirm with the Docker/live lane owner that the new OpenAI-backed live lane belongs in the default tail surface.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body lists verification commands but does not include captured output or a linked artifact showing the changed behavior after the patch; redacted terminal output, logs, screenshots, recordings, or artifacts are needed before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] The PR still lacks redacted terminal output, logs, screenshots, recordings, or linked artifacts proving the deterministic and live Docker MCP Gateway smokes after the patch.
  • [P1] The new live Docker tail lane depends on OpenAI credentials and changes maintainer validation planning, so a lane owner should confirm it belongs in the default live surface.
  • [P1] The new API code-mode global is a user-facing runtime contract and reserves that name for internal API-file discovery, so the naming should be intentional before merge.

Maintainer options:

  1. Require proof and lane-owner confirmation (recommended)
    Ask for redacted output or a linked artifact from the deterministic and live Docker smokes, then have the Docker/live lane owner confirm the new tail lane before merge.
  2. Accept the new live lane as-is
    A maintainer can intentionally accept the broader live automation surface if they are comfortable relying on PR-body commands plus follow-up CI/live runs.
  3. Split the live lane
    If the feature code is wanted but the live lane is not ready, split or defer the live Docker tail lane into a narrower follow-up.

Next step before merge

  • [P1] The remaining action is maintainer approval of a protected, user-facing code-mode API plus live-lane proof, not a narrow automated repair.

Security
Cleared: No concrete security or supply-chain regression was found; the diff adds no dependencies or lockfile changes and uses existing Docker/profile credential patterns without printing secret values.

Review details

Best possible solution:

Land the virtual API-file design only after redacted deterministic/live Docker proof is attached and maintainers accept the new live lane and API global contract.

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

Not applicable for a feature PR. Current main lacks the new API.list/API.read code-mode surface, and the PR adds tests plus Docker smokes for the new behavior.

Is this the best way to solve the issue?

Yes, with a proof and owner-approval caveat: deriving virtual declaration files from the existing MCP namespace model is a maintainable fit that avoids putting MCP schemas in the model-visible tool list. The merge should still wait for captured after-fix proof and maintainer acceptance of the live lane and global name.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.

Label justifications:

  • P2: This is a normal-priority core agent/runtime feature with focused blast radius but maintainer-visible API and automation impact.
  • merge-risk: 🚨 automation: The diff adds Docker package scripts and scenario lanes, including a live OpenAI lane that can affect maintainer validation planning after merge.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • feature: ✨ showcase: ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. Virtual MCP declaration files are a strong agent-workflow idea because they make MCP signatures discoverable in code mode without exposing MCP schemas as model-visible tools.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body lists verification commands but does not include captured output or a linked artifact showing the changed behavior after the patch; redacted terminal output, logs, screenshots, recordings, or artifacts are needed before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +189, Tests +111, Docs +3, Config +2, Other +717. Total +1022 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 6 218 29 +189
Tests 3 111 0 +111
Docs 1 12 9 +3
Config 1 2 0 +2
Generated 0 0 0 0
Other 7 720 3 +717
Total 18 1063 41 +1022

What I checked:

  • PR source: virtual MCP API files: PR head builds mcp/index.d.ts and per-server mcp/<server>.d.ts virtual files from the same MCP namespace model used for runtime calls. (src/agents/code-mode-namespaces.ts:850, 576c83e89585)
  • PR source: worker API global: PR head injects API files into the QuickJS worker and exposes frozen API.list(prefix?) and API.read(path) helpers. (src/agents/code-mode.worker.ts:301, 576c83e89585)
  • PR source: exec path wiring: runExec now reads namespace entries once, creates namespace runtime plus virtual API files, and passes both to the worker. (src/agents/code-mode.ts:860, 576c83e89585)
  • Current main baseline: Current main is b0679d1f13da17fe97b302b1800e9df05852ddc7; local source search found no current-main createCodeModeApiVirtualFiles, API.list, or API.read implementation in the code-mode surfaces. (src/agents/code-mode.ts:859, b0679d1f13da)
  • Automation surface: The PR adds a deterministic Docker lane and a live OpenAI-backed tail lane, so maintainers need to accept the new validation surface before merge. (scripts/lib/docker-e2e-scenarios.mjs:227, 576c83e89585)
  • Proof state: The PR body and existing ClawSweeper comment list verification commands but no captured terminal output, logs, screenshots, recordings, or linked artifacts showing after-fix behavior.

Likely related people:

  • steipete: Merged related MCP code-mode PRs added the namespace and typed API work, and this branch builds directly on those surfaces. (role: feature-history owner and recent area contributor; confidence: high; commits: fe2e38e373e8, 7f00552fd5e2, 4ecbc15b2ec7; files: src/agents/code-mode-namespaces.ts, src/agents/code-mode.ts, src/agents/code-mode.test.ts)
  • Vincent Koc: The shallow current-main blame for the code-mode and Docker scenario surfaces points to a broad recent refactor/lint/perf pass, and a nearby bundle-MCP e2e setup commit touches the adjacent validation area. (role: recent current-main adjacent contributor; confidence: medium; commits: db0209ac5d8a, 07150819904f; files: src/agents/code-mode-namespaces.ts, src/agents/code-mode.ts, scripts/lib/docker-e2e-scenarios.mjs)
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.

@steipete
steipete force-pushed the feat/code-mode-mcp-api-files branch from 8454628 to f9045f7 Compare May 31, 2026 20:04
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. feature: ✨ showcase ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. labels May 31, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels May 31, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for head 576c83e.

Summary:

  • Added file-based code-mode API docs via API.list("mcp") and API.read("mcp/.d.ts"), with MCP..() declarations generated from the MCP catalog.
  • Preserved MCP plugin metadata through provider tool-schema normalization so code mode keeps MCP tools in the MCP namespace.
  • Added deterministic and live Docker Gateway E2E lanes for a file-backed MCP fixture and verified the agent uses the API files efficiently.

Verification:

  • pnpm lint --threads=8
  • node scripts/run-vitest.mjs src/agents/runtime-plan/tools.test.ts src/agents/code-mode.test.ts test/scripts/docker-e2e-plan.test.ts src/agents/embedded-agent-runner/run/attempt-tool-construction-plan.test.ts -- --reporter=dot
  • bash -n scripts/e2e/mcp-code-mode-gateway-docker.sh scripts/e2e/mcp-code-mode-gateway-live-docker.sh && node --check scripts/e2e/mock-openai-server.mjs
  • pnpm test:docker:mcp-code-mode-gateway
  • pnpm test:docker:live-mcp-code-mode-gateway
  • .agents/skills/autoreview/scripts/autoreview --mode local --prompt 'Review only the final MCP code-mode/API-file/docker-e2e/runtime-plan PR branch changes on this rebased checkout. Ignore unrelated generated build artifacts. Confirm no accepted/actionable issues remain after the lint-only follow-up commit.'

Docker behavior proof:

  • Deterministic final text: MCP_CODE_MODE_FILE_OK note=fixture-note-alpha unclear=none improvement=virtual-api-files-were-clear-and-needed-one-exec
  • Deterministic counters: apiCall=0, apiFileList=11, apiFileRead=21, mcpNamespace=10, mcpTool=6, toolSearchPollution=0
  • Live final text: MCP_CODE_MODE_FILE_OK note=fixture-note-alpha unclear=none
  • Live counters: apiCall=0, apiFileList=16, apiFileRead=29, mcpNamespace=14, mcpTool=6, toolSearchPollution=0

GitHub checks: exact head is clean, 140 successful, 0 pending, 0 failing.

@steipete
steipete merged commit e681569 into main May 31, 2026
172 of 174 checks passed
@steipete
steipete deleted the feat/code-mode-mcp-api-files branch May 31, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docker Docker and sandbox tooling docs Improvements or additions to documentation extensions: qa-lab feature: ✨ showcase ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant