Skip to content

Capped result sets omit truncated / more_available hint, hiding limit hits #1727

Description

@Widthdom

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions