fix(mcp): cap search_graph default limit to 200 (was 500K)#231
Open
amitmynd wants to merge 1 commit intoDeusData:mainfrom
Open
fix(mcp): cap search_graph default limit to 200 (was 500K)#231amitmynd wants to merge 1 commit intoDeusData:mainfrom
amitmynd wants to merge 1 commit intoDeusData:mainfrom
Conversation
The default limit for search_graph used MCP_HALF_SEC_US (500,000), a microsecond timeout constant misused as a row count. Broad queries like file_pattern="**/ads/**" on a 12K-node project returned all 1,287 matches (3.3M characters), exceeding LLM tool result limits. Changes: - MCP handler: default limit 500,000 -> 200 - Store layer: fallback limit ST_HALF_SEC (500,000) -> 200 - Tool description: "Default: unlimited" -> "Default: 200" Pagination via offset/limit still works. The response includes total count and has_more flag for callers that need more results. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
search_graphwith a broadfile_pattern(e.g.**/ads/**) returns output that exceeds LLM tool result limits. In my case, querying a 12K-node project returned 3,358,396 characters, which Claude Code couldn't process:Root cause
The default
limitfor the regex/file_pattern search path usesMCP_HALF_SEC_US(500,000), which appears to be a microsecond timeout constant that was accidentally used as a row count. When no explicitlimitis passed, the query returns up to 500K rows, serializing all of them into the JSON response.src/mcp/mcp.c:1344:cbm_mcp_get_int_arg(args, "limit", MCP_HALF_SEC_US)(500,000)src/store/store.c:2304: fallback toST_HALF_SEC(also 500,000)Fix
Changed the default limit to 200 in both the MCP handler and the store layer. Updated the tool description to reflect this.
Before: 1,287 matching nodes, all returned, 3.3M characters output
After: 1,287 total (reported in
totalfield), 200 returned, 57K characters output,has_more: truePagination with
offsetandlimitcontinues to work as expected for callers that need more results.Changes
src/mcp/mcp.chandle_search_graphsrc/store/store.cST_HALF_SEC-> 200 incbm_store_searchsrc/mcp/mcp.cTest plan
make -f Makefile.cbm cbmsearch_graphwith broadfile_patternreturns 200 results (57K chars) instead of all matches (3.3M chars)total: 1287,has_more: truefor paginationlist_projectsand--helpwork correctlylimitparam still overrides the default🤖 Generated with Claude Code