MCP budget: lower get_index_usage's default row limit under budget (#4198) - #4260
Merged
Merged
Conversation
…4198) 200 rows (get_index_usage's caller-optional limit default since #2636) measured 69,290 bytes on a busy production store, more than double McpResponseBudget's 32 KB target. Lowers the default to 75 on both Darling and Lite, matching the per-row math #4198 measured elsewhere; an explicit limit still gets every row it asks for. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TszxYhJJbTEh4LrZ56NYo3
Matches the Darling live test's diagnostic line so both products' PR numbers come from the same test run. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TszxYhJJbTEh4LrZ56NYo3
erikdarlingdata
marked this pull request as ready for review
September 25, 2026 07:44
This was referenced Sep 25, 2026
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.
Part of #4198.
Why
get_index_usagealready had a caller-optionallimitparameter (#2636), but its default value was still the pre-#2636 hardcoded cap of 200 rows. #4198 measured a default call, with no arguments, at 69,290 bytes on a busy production store (848 ms). That is more than doubleMcpResponseBudget.DefaultBytes, 32 KB. A default call's reply was large enough for an MCP client to refuse it outright, the same failure #4198 found across the read-tool set.What changes
DarlingMcpObjectStatsTools.GetIndexUsage) and Lite (McpObjectStatsTools.GetIndexUsage):IndexUsageTop, thelimitparameter's default, drops from 200 to 75 rows. That size comes from the measured rate, about 346 bytes per row (69,290 bytes over 200 rows). The parameter itself, its validation (McpHelpers.ValidateTop), and the truncation envelope (returned_index_count,matching_index_count,truncated,note) stay the same. [BUG] - get_index_usage MCP tool hardcodes a 200-row cap ordered unused-first, silently hiding all "Active"/"Write-only" indexes and any database whose indexes don't rank in the global top 200 #2636 already built that shape. This lane only resizes the fallback. An explicitlimitstill gets exactly what it asks for, up toMcpHelpers.MaxTop.tools/listbyte-budget pins (DarlingMcpObjectStatsTools.txt,McpObjectStatsTools.txt) drop from 36 to 35 bytes to match, one fewer digit.Darling.Tests/IndexUsageBudgetLiveTests.cs. It seeds 200 index rows across 10 databases on a real PostgreSQL store and checks three things. The default call stays under budget and comes backtruncated. An explicitlimitcovering the seeded set returns every row untruncated.Lite.Tests/IndexUsageBudgetTests.cs, the same three checks against Lite's shared DuckDB fixture. No rig needed.get_index_usageis not on A budget pin over every MCP read tool (part of #4198) #4224'sMcpReadToolBudgetLiveTestsExemptOffendersroster. That fixture does not seedindex_object_stats, soMcpReadToolBudgetLiveTests.csitself is untouched here. This lane's own fixture covers the gap A budget pin over every MCP read tool (part of #4198) #4224 already documents for this tool.Test plan
Darling.Testsbuild: 0 Warning(s), 0 Error(s).Lite.Testsbuild: 0 Warning(s), 0 Error(s).IndexUsageBudgetLiveTests: default call measured 25,913 bytes, down from the 69,290 bytes the field measurement found, under the 32,768-byte budget.truncatedis true. An explicitlimit=200returns all 200 seeded rows, not truncated.IndexUsageBudgetTests: default call measured 25,902 bytes. Same three checks, passing.IndexUsageBudgetLiveTests,IndexUsageTruncationTests,IndexUsageTruncationLivePostgresTests,DarlingMcpObjectStatsToolsSurfaceAndSqlTests,DarlingMcpObjectStatsToolsLivePostgresTests,DarlingIndexLockingRenamedDatabaseLivePostgresTests,McpToolsListBudgetTests,McpPayloadContractCensusTests. Lite:IndexUsageBudgetTests,IndexUsageTruncationTests,McpToolsListBudgetTests,CrossAppMcpToolInventoryPinTests.Lite.Testssuite after mergingorigin/dev: 5,340 total, 0 failed.Darling.Testssuite after mergingorigin/dev: 13,849 total, 3 failed, 47 skipped, 1 not run. All 3 failures passed cleanly when re-run alone right after, on a freshly recreated database:CaptureDownChunkOrderTests...AgainstDevPostgres,ServerListAndSummaryPlanShapeTests...AgainstDevPostgres,TrendPayloadBudgetLiveTests.EveryDefaultAnswer.... These are suite-order, chunk-count flakes from a 13,800-test run sharing one database, not from this change.TrendPayloadBudgetLiveTestsis the exact flake the MCP read tools have no default response-size budget: at default arguments 12 tools return >50 KB and 3 return >100 KB for one server, more than an agent client's per-result cap #4198 common brief already names as failing locally on unrelated branches tonight. None of the three touchindex_object_stats,DarlingObjectStatsReader, or either object-stats tools file.CHANGELOG entry
SECTION: Fixed
ENTRY:
limitargument, always returned up to 200 rows regardless of width. That measured over 69 KB on a busy server, large enough for an MCP client to refuse it outright. The defaultlimitis now 75 on both Darling and Lite. An explicitlimitstill returns exactly what was asked for.REF:
[MCP budget: lower get_index_usage's default row limit under budget (#4198) #4260]: MCP budget: lower get_index_usage's default row limit under budget (#4198) #4260
Generated with Claude Code
https://claude.ai/code/session_01TszxYhJJbTEh4LrZ56NYo3