fix(mcp): parsed separate Exa tools argument

This commit is contained in:
can1357
2026-08-16 02:03:25 +02:00
parent 9af713f2b0
commit 5102d3068f
2 changed files with 17 additions and 2 deletions
+4 -2
View File
@@ -244,8 +244,10 @@ function getRequestedExaMcpTools(config: MCPServerConfig): string[] | null {
}
if (!config.type || config.type === "stdio") {
const stdioConfig = config as { args?: string[] };
for (const arg of stdioConfig.args ?? []) {
const match = arg.match(/(?:^|[\s?&])tools=([^&\s]+)/i) ?? arg.match(/--?tools[=\s]([^\s]+)/i);
const args = stdioConfig.args ?? [];
for (let i = 0; i < args.length; i++) {
if (/^--?tools$/i.test(args[i])) return args[i + 1];
const match = args[i].match(/(?:^|[\s?&])tools=([^&\s]+)/i) ?? args[i].match(/--?tools[=\s]([^\s]+)/i);
if (match) return match[1];
}
}
@@ -63,4 +63,17 @@ describe("Exa MCP filtering", () => {
expect(Object.keys(result.configs)).toEqual(["exa"]);
});
test("keeps a stdio exa server with a separate tools argument", () => {
const configs: Record<string, MCPServerConfig> = {
exa: {
type: "stdio",
command: "npx",
args: ["-y", "exa-mcp-server", "--tools", "web_search_exa,web_fetch_exa"],
},
};
const result = filterExaMCPServers(configs, { exa: SOURCE });
expect(Object.keys(result.configs)).toEqual(["exa"]);
});
});