diff --git a/src/agents/pi-bundle-mcp-tools.materialize.test.ts b/src/agents/pi-bundle-mcp-tools.materialize.test.ts index 05b7db9088c..5dc928d4a61 100644 --- a/src/agents/pi-bundle-mcp-tools.materialize.test.ts +++ b/src/agents/pi-bundle-mcp-tools.materialize.test.ts @@ -19,24 +19,29 @@ afterEach(async () => { await cleanupBundleMcpHarness(); }); -describe("createBundleMcpToolRuntime", () => { - it("loads bundle MCP tools and executes them", async () => { - const workspaceDir = await makeTempDir("openclaw-bundle-mcp-tools-"); - const pluginRoot = path.join(workspaceDir, ".openclaw", "extensions", "bundle-probe"); - const serverScriptPath = path.join(pluginRoot, "servers", "bundle-probe.mjs"); - await writeBundleProbeMcpServer(serverScriptPath); - await writeClaudeBundle({ pluginRoot, serverScriptPath }); +async function createBundleProbeRuntime(params?: { reservedToolNames?: string[] }) { + const workspaceDir = await makeTempDir("openclaw-bundle-mcp-tools-"); + const pluginRoot = path.join(workspaceDir, ".openclaw", "extensions", "bundle-probe"); + const serverScriptPath = path.join(pluginRoot, "servers", "bundle-probe.mjs"); + await writeBundleProbeMcpServer(serverScriptPath); + await writeClaudeBundle({ pluginRoot, serverScriptPath }); - const runtime = await createBundleMcpToolRuntime({ - workspaceDir, - cfg: { - plugins: { - entries: { - "bundle-probe": { enabled: true }, - }, + return await createBundleMcpToolRuntime({ + workspaceDir, + cfg: { + plugins: { + entries: { + "bundle-probe": { enabled: true }, }, }, - }); + }, + reservedToolNames: params?.reservedToolNames, + }); +} + +describe("createBundleMcpToolRuntime", () => { + it("loads bundle MCP tools and executes them", async () => { + const runtime = await createBundleProbeRuntime(); try { expect(runtime.tools.map((tool) => tool.name)).toEqual(["bundleProbe__bundle_probe"]); @@ -55,21 +60,7 @@ describe("createBundleMcpToolRuntime", () => { }); it("disambiguates bundle MCP tools that collide with existing tool names", async () => { - const workspaceDir = await makeTempDir("openclaw-bundle-mcp-tools-"); - const pluginRoot = path.join(workspaceDir, ".openclaw", "extensions", "bundle-probe"); - const serverScriptPath = path.join(pluginRoot, "servers", "bundle-probe.mjs"); - await writeBundleProbeMcpServer(serverScriptPath); - await writeClaudeBundle({ pluginRoot, serverScriptPath }); - - const runtime = await createBundleMcpToolRuntime({ - workspaceDir, - cfg: { - plugins: { - entries: { - "bundle-probe": { enabled: true }, - }, - }, - }, + const runtime = await createBundleProbeRuntime({ reservedToolNames: ["bundleProbe__bundle_probe"], });