Summary
When MCP search/references/callers/callees tools cap their result sets at the requested limit, the response includes count but no truncated / more_available field. An LLM client cannot distinguish "we found exactly N matches" from "we found N+ but capped at N". This causes silently incomplete analyses — the LLM summarizes from a truncated set and confidently asserts its summary is exhaustive.
Where
src/CodeIndex/Mcp/McpToolHandlers.cs:280-313 (search result construction)
- Same pattern across other graph-tool handlers in the file
Suggested approach
(1) When results.Count == limit, set truncated: true (or more_available: true) on the response payload. (2) Alternatively, query for limit + 1 rows and emit the boolean based on whether the extra row exists; return only limit rows in the payload either way. (3) Apply to: search, references, callers, callees, impact, unused, outline, find_in_file, excerpt. (4) Document the field in the MCP tool description so LLMs use it. (5) Add the same field to the CLI --json output for consistency. (6) Cover with a regression test that asserts truncated=true when limit is reached.
Summary
When MCP search/references/callers/callees tools cap their result sets at the requested limit, the response includes
countbut notruncated/more_availablefield. An LLM client cannot distinguish "we found exactly N matches" from "we found N+ but capped at N". This causes silently incomplete analyses — the LLM summarizes from a truncated set and confidently asserts its summary is exhaustive.Where
src/CodeIndex/Mcp/McpToolHandlers.cs:280-313(search result construction)Suggested approach
(1) When
results.Count == limit, settruncated: true(ormore_available: true) on the response payload. (2) Alternatively, query forlimit + 1rows and emit the boolean based on whether the extra row exists; return onlylimitrows in the payload either way. (3) Apply to:search,references,callers,callees,impact,unused,outline,find_in_file,excerpt. (4) Document the field in the MCP tool description so LLMs use it. (5) Add the same field to the CLI--jsonoutput for consistency. (6) Cover with a regression test that asserts truncated=true when limit is reached.