From aff5df33f9ad2f23fbb5018956bbf62a3aa41121 Mon Sep 17 00:00:00 2001 From: Andrew Hundt Date: Wed, 24 Jun 2026 18:01:42 -0400 Subject: [PATCH] test(mcp): cover classic-mode tools list (CBM_TOOL_MODE=classic) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The merged cbm_mcp_tools_list (src/mcp/mcp.c:868) defaults to streamlined mode when srv is NULL, so tests/test_mcp.c:mcp_tools_list only exercised the 3 consolidated tools. The classic-mode path (CBM_TOOL_MODE=classic, mcp.c:876) that emits all 15 TOOLS[] split tools had no test — the MERGE-TODO flagged at tests/test_mcp.c:172. Add mcp_tools_list_classic_mode: setenv("CBM_TOOL_MODE","classic"), capture the list, then unsetenv BEFORE any ASSERT so a failed assertion cannot leak the classic setting into sibling tests (which expect the streamlined default). Assert the classic split tools (index_repository, search_graph, query_graph) are present and the streamlined-only consolidated search_code_graph + the _hidden_tools progressive-disclosure hint are absent. Registered in suite_mcp. Full suite: 5981 passed / 2 failed (the 2 are the deferred B1 incremental races, unrelated to this test). Signed-off-by: Andrew Hundt --- tests/test_mcp.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_mcp.c b/tests/test_mcp.c index fa43a6c2f..883bf096d 100644 --- a/tests/test_mcp.c +++ b/tests/test_mcp.c @@ -185,6 +185,28 @@ TEST(mcp_tools_list) { PASS(); } +TEST(mcp_tools_list_classic_mode) { + /* Classic mode (CBM_TOOL_MODE=classic) emits the original 15 split tools, + * not the streamlined consolidated set. The env var is read at call time + * (src/mcp/mcp.c:870), so set it, capture the list, then unset it BEFORE any + * ASSERT — a failed assert must not leak the classic setting into sibling + * tests (which expect the streamlined default). */ + setenv("CBM_TOOL_MODE", "classic", 1); + char *json = cbm_mcp_tools_list(NULL); + unsetenv("CBM_TOOL_MODE"); + ASSERT_NOT_NULL(json); + /* Classic split tools are present (TOOLS[] in mcp.c). */ + ASSERT_NOT_NULL(strstr(json, "\"index_repository\"")); + ASSERT_NOT_NULL(strstr(json, "\"search_graph\"")); + ASSERT_NOT_NULL(strstr(json, "\"query_graph\"")); + /* The streamlined-only consolidated tool + progressive-disclosure hint are + * NOT emitted in classic mode. */ + ASSERT_NULL(strstr(json, "\"search_code_graph\"")); + ASSERT_NULL(strstr(json, "_hidden_tools")); + free(json); + PASS(); +} + TEST(mcp_tools_array_schemas_have_items) { /* VS Code 1.112+ rejects array schemas without "items" (see * https://github.com/microsoft/vscode/issues/248810). @@ -2269,6 +2291,7 @@ SUITE(mcp) { /* MCP protocol helpers */ RUN_TEST(mcp_initialize_response); RUN_TEST(mcp_tools_list); + RUN_TEST(mcp_tools_list_classic_mode); RUN_TEST(mcp_tools_array_schemas_have_items); RUN_TEST(mcp_text_result); RUN_TEST(mcp_text_result_error);