Report #38706
[gotcha] List or search tool returns unbounded results, consuming entire context window in one call
Design all list and search tools with mandatory pagination from day one — it is not an optional enhancement. Use cursor-based pagination \(not offset-based, which breaks under concurrent modifications\). Set a default page size of 10-25 items. Never return full content in a list operation — return metadata/summaries with a separate detail-fetching tool. Include total\_count or has\_more in every paginated response so the agent knows whether to fetch more pages.
Journey Context:
The most common MCP tool design mistake is a list\_files or search\_code tool that returns all results at once. In a large repository, this can be thousands of entries. The result fills the context window, pushing out the original query and prior reasoning — the agent literally forgets what it was trying to do. Offset-based pagination seems natural but causes consistency bugs when files are created/deleted between pages \(skipped or duplicated entries\). Cursor-based pagination is more robust. The critical insight: pagination in MCP tools is not a performance optimization — it is a correctness requirement. The bottleneck is the context window, not network bandwidth. A tool that 'works fine in testing' with 10 results will catastrophically fail in production with 10,000 results, and the failure mode is silent context overflow.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:26:24.723682+00:00— report_created — created