From 5bf3586b8a3fa8293f09b020d6037a564290eb62 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Fri, 4 Dec 2026 06:23:54 +0800 Subject: [PATCH] test(server): share tool catalog message fixtures (#16492) --- src/server/toolCatalogSearch.test.ts | 41 ++++++++-------------------- 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/src/server/toolCatalogSearch.test.ts b/src/server/toolCatalogSearch.test.ts index 80b311e17b8..6db2789c038 100644 --- a/src/server/toolCatalogSearch.test.ts +++ b/src/server/toolCatalogSearch.test.ts @@ -167,45 +167,26 @@ describe("suggestAdvertisedTools", () => { }); describe("formatUnknownMcpToolMessage", () => { + const message = (name: string, discoveryAvailable: boolean) => + formatUnknownMcpToolMessage(name, { + tools: SAMPLE_CATALOG, + discoveryAvailable, + }); + it("formats full-catalog and progressive-catalog messages for zero, one, and multiple matches", () => { - expect( - formatUnknownMcpToolMessage("zzzzzz", { - tools: SAMPLE_CATALOG, - discoveryAvailable: false, - }), - ).toBe( + expect(message("zzzzzz", false)).toBe( "The requested MCP tool is not advertised by this REA server. Call tools/list, select an advertised tool, and retry; do not repeat the unknown tool name.", ); - expect( - formatUnknownMcpToolMessage("open-binary", { - tools: SAMPLE_CATALOG, - discoveryAvailable: false, - }), - ).toBe( + expect(message("open-binary", false)).toBe( "The requested MCP tool is not advertised by this REA server. Closest advertised tool: open_binary. Select an advertised tool or call tools/list, and retry; do not repeat the unknown tool name.", ); - expect( - formatUnknownMcpToolMessage("decompile", { - tools: SAMPLE_CATALOG, - discoveryAvailable: false, - }), - ).toBe( + expect(message("decompile", false)).toBe( "The requested MCP tool is not advertised by this REA server. Closest advertised tools: batch_decompile, decompile_all, procedure_pseudo_code, import_managed_reconstruction. Select an advertised tool or call tools/list, and retry; do not repeat the unknown tool name.", ); - expect( - formatUnknownMcpToolMessage("zzzzzz", { - tools: SAMPLE_CATALOG, - discoveryAvailable: true, - }), - ).toBe( + expect(message("zzzzzz", true)).toBe( "The requested MCP tool is not advertised by this REA server. Call discover_tools to find and load an in-scope tool, then retry; do not repeat the unknown tool name.", ); - expect( - formatUnknownMcpToolMessage("open-binary", { - tools: SAMPLE_CATALOG, - discoveryAvailable: true, - }), - ).toBe( + expect(message("open-binary", true)).toBe( "The requested MCP tool is not advertised by this REA server. Closest advertised tool: open_binary. Select an advertised tool or call discover_tools to find and load other in-scope tools, then retry; do not repeat the unknown tool name.", ); });