fix: route Exa and CodeGraph through shared mcp adapter

This commit is contained in:
云服务部-叶林立
2026-08-19 12:10:24 +08:00
parent a0a4ae44d4
commit 6293ef1c63
9 changed files with 104 additions and 65 deletions
+6 -3
View File
@@ -32,11 +32,14 @@ test("Exa API override keeps registered and active tool names aligned", () => {
});
api.registerTool({ name: "web_fetch_exa", label: "MCP: web_fetch_exa" });
api.setActiveTools(["read", "web_fetch_exa", "web_fetch_exa"]);
api.registerTool({ name: "codegraph_explore", label: "MCP: codegraph_explore" });
api.setActiveTools(["read", "web_fetch_exa", "web_fetch_exa", "codegraph_explore"]);
api.unregisterTool("web_fetch_exa");
api.unregisterTool("codegraph_explore");
assert.equal(registered[0]?.name, "exa_web_fetch");
assert.equal(registered[0]?.label, "Exa Web Fetch");
assert.deepEqual(active, ["read", "exa_web_fetch"]);
assert.deepEqual(unregistered, ["exa_web_fetch"]);
assert.equal(registered[1]?.name, "codegraph_explore");
assert.deepEqual(active, ["read", "exa_web_fetch", "codegraph_explore"]);
assert.deepEqual(unregistered, ["exa_web_fetch", "codegraph_explore"]);
});
+47
View File
@@ -0,0 +1,47 @@
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import test from "node:test";
import { EXA_TOOLS, MCP_CONFIG } from "../extensions/mcp-config.ts";
test("one MCP adapter config contains both Exa and CodeGraph", () => {
assert.deepEqual(MCP_CONFIG, {
settings: {
disableProxyTool: true,
scriptMode: false,
},
mcpServers: {
exa: {
url: `https://mcp.exa.ai/mcp?tools=${EXA_TOOLS.join(",")}`,
protocolVersion: "auto",
lifecycle: "eager",
directTools: EXA_TOOLS,
includeTools: EXA_TOOLS,
toolPrefix: "none",
approveTools: false,
exposeResources: false,
},
codegraph: {
command: "codegraph",
args: ["serve", "--mcp"],
lifecycle: "keep-alive",
directTools: ["codegraph_explore"],
includeTools: ["codegraph_explore"],
toolPrefix: "none",
approveTools: false,
exposeResources: false,
},
},
});
});
test("the package loads only the shared MCP extension entry", async () => {
const packageJson = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8")) as {
pi: { extensions: string[] };
};
const localMcpEntries = packageJson.pi.extensions.filter((entry) =>
entry === "./extensions/mcp.ts" || entry === "./extensions/exa.ts" || entry === "./extensions/codegraph.ts"
);
assert.deepEqual(localMcpEntries, ["./extensions/mcp.ts"]);
});