

























@@ -44,6 +44,8 @@ When code mode is active:
4444 guest program through `ALL_TOOLS` and `tools`.
4545- Guest code can search the hidden catalog, describe a tool, and call a tool
4646 through the same OpenClaw execution path used by normal agent turns.
47+- MCP tools are grouped under the `MCP` namespace. In code mode, this namespace
48+ is the only supported way to call MCP tools.
4749- `wait` resumes a suspended code-mode run when nested tool calls are still
4850 pending.
4951@@ -381,6 +383,7 @@ The guest runtime exposes a small global API:
381383```typescript
382384declare const ALL_TOOLS: ToolCatalogEntry[];
383385declare const tools: ToolCatalog;
386+declare const MCP: Record<string, unknown>;
384387declare const namespaces: Record<string, unknown>;
385388386389declare function text(value: unknown): void;
@@ -432,6 +435,21 @@ const content = await tools.call(fileRead.id, { path: "README.md" });
432435const hits = await tools.web_search({ query: "OpenClaw code mode" });
433436```
434437438+MCP catalog entries are not callable through `tools.call(...)` or convenience
439+functions in code mode. Use the generated `MCP` namespace instead:
440+441+```typescript
442+const issue = await MCP.github.createIssue({
443+ owner: "openclaw",
444+ repo: "openclaw",
445+ title: "Investigate gateway logs",
446+});
447+448+const snapshot = await MCP.chromeDevtools.takeSnapshot({ output: "markdown" });
449+const resource = await MCP.docs.resources.read("memo://one");
450+const prompt = await MCP.docs.prompts.get("brief", { topic: "release" });
451+```
452+435453The guest runtime must not expose host objects directly. Inputs and outputs cross
436454the bridge as JSON-compatible values with explicit size caps.
437455@@ -613,10 +631,10 @@ Namespace changes should cover the security boundary and the guest behavior:
613631- suspended namespace calls resume through `wait`
614632- plugin rollback clears the owning namespace registrations
615633616-Namespaces complement the generic `tools.search` / `tools.call` catalog. Use
617-the catalog for arbitrary enabled tools; use namespaces for plugin-owned,
618-documented domain APIs where concise code is more reliable than repeated schema
619-lookups.
634+Namespaces complement the generic `tools.search` / `tools.call` catalog. Use the
635+catalog for arbitrary enabled OpenClaw, plugin, and client tools; use `MCP` for
636+MCP tools; use other namespaces for plugin-owned, documented domain APIs where
637+concise code is more reliable than repeated schema lookups.
620638621639## Output API
622640@@ -681,6 +699,12 @@ The catalog omits code-mode control tools:
681699682700This prevents recursion and keeps the model-facing contract narrow.
683701702+MCP entries stay in the run-scoped catalog so policy, approvals, hooks,
703+telemetry, transcript projection, and exact tool ids remain shared with normal
704+tool execution. The guest-facing `tools.call(...)` bridge rejects MCP entries;
705+the generated `MCP.<server>.<tool>(...)` namespace resolves back to the exact
706+catalog id and then dispatches through the same executor path.
707+684708## Tool Search interaction
685709686710Code mode supersedes the OpenClaw Tool Search model surface for runs where it is
@@ -693,6 +717,7 @@ When `tools.codeMode.enabled` is true and code mode activates:
693717- The same cataloging idea moves inside the guest runtime.
694718- The guest runtime receives compact `ALL_TOOLS` metadata and search, describe,
695719 and call helpers.
720+- MCP calls use the generated `MCP` namespace instead of `tools.call(...)`.
696721- Nested calls dispatch through the same OpenClaw executor path that Tool Search
697722 uses.
698723@@ -912,6 +937,8 @@ Code mode coverage should prove:
912937- all effective tools appear in `ALL_TOOLS`
913938- denied tools do not appear in `ALL_TOOLS`
914939- `tools.search`, `tools.describe`, and `tools.call` work for OpenClaw tools
940+- MCP namespace calls work for visible MCP tools and direct MCP `tools.call`
941+ attempts fail closed
915942- Tool Search control tools are hidden from both the model surface and the hidden
916943 catalog
917944- nested calls preserve approval and hook behavior
@@ -939,13 +966,16 @@ Run these as integration or end-to-end tests when changing the runtime:
9399665. Send an agent turn with OpenClaw, plugin, MCP, and client test tools.
9409676. Assert the model-visible tool list is exactly `exec`, `wait`.
9419687. In `exec`, read `ALL_TOOLS` and assert the effective test tools are present.
942-8. In `exec`, call `tools.search`, `tools.describe`, and `tools.call`.
943-9. Assert denied tools are absent and cannot be called by guessed id.
944-10. Start a nested tool call that resolves after `exec` returns `waiting`.
945-11. Call `wait` and assert the restored VM receives the tool result.
946-12. Assert the final answer contains output produced after restore.
947-13. Assert timeout, abort, and snapshot expiry clean up runtime state.
948-14. Export trajectory and assert nested calls are visible under the parent
969+8. In `exec`, call OpenClaw/plugin/client tools through `tools.search`,
970+`tools.describe`, and `tools.call`.
971+9. In `exec`, call MCP tools through `MCP.<server>.<tool>(...)` and assert direct
972+ MCP `tools.call(...)` attempts fail.
973+10. Assert denied tools are absent and cannot be called by guessed id.
974+11. Start a nested tool call that resolves after `exec` returns `waiting`.
975+12. Call `wait` and assert the restored VM receives the tool result.
976+13. Assert the final answer contains output produced after restore.
977+14. Assert timeout, abort, and snapshot expiry clean up runtime state.
978+15. Export trajectory and assert nested calls are visible under the parent
949979 code-mode call.
950980951981Docs-only changes to this page should still run `pnpm check:docs`.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。