Summary
The CLI has a --count mode (QueryCommandRunner.cs:114-128) that returns just aggregate counts without full result rows. The MCP tool surface has no equivalent — an LLM exploring a large codebase always pays for full payload rows even when it only wanted to know "how many callers exist" before deciding whether to drill in. For widely-called helpers (e.g., Console.WriteLine-equivalent), this can waste tens of KB of LLM context per cheap probing question.
Where
src/CodeIndex/Cli/QueryCommandRunner.cs:114-128 (CLI count mode)
src/CodeIndex/Mcp/McpToolHandlers.cs:306 (MCP search response — no count-only mode)
src/CodeIndex/Mcp/McpToolDefinitions.cs (tool schemas — no count-only param)
Suggested approach
(1) Add a count_only: true boolean parameter to MCP search, references, callers, callees, impact_analysis. (2) When set, the response carries only the count + a small histogram (e.g., per-file count for the top 5 files), not the row payloads. (3) Document the token-savings expectation in the tool description so LLMs adopt the pattern. (4) Optionally add a default behavior: when count > N (e.g., 100), return only count + truncated_warning and require an explicit --with-rows opt-in. (5) Cover with a regression test that asserts count_only payload size scales O(1) regardless of underlying row count.
Summary
The CLI has a
--countmode (QueryCommandRunner.cs:114-128) that returns just aggregate counts without full result rows. The MCP tool surface has no equivalent — an LLM exploring a large codebase always pays for full payload rows even when it only wanted to know "how many callers exist" before deciding whether to drill in. For widely-called helpers (e.g.,Console.WriteLine-equivalent), this can waste tens of KB of LLM context per cheap probing question.Where
src/CodeIndex/Cli/QueryCommandRunner.cs:114-128(CLI count mode)src/CodeIndex/Mcp/McpToolHandlers.cs:306(MCP search response — no count-only mode)src/CodeIndex/Mcp/McpToolDefinitions.cs(tool schemas — no count-only param)Suggested approach
(1) Add a
count_only: trueboolean parameter to MCPsearch,references,callers,callees,impact_analysis. (2) When set, the response carries only the count + a small histogram (e.g., per-file count for the top 5 files), not the row payloads. (3) Document the token-savings expectation in the tool description so LLMs adopt the pattern. (4) Optionally add a default behavior: whencount > N(e.g., 100), return only count +truncated_warningand require an explicit--with-rowsopt-in. (5) Cover with a regression test that assertscount_onlypayload size scales O(1) regardless of underlying row count.