fix(tools): report the ListMcpResources cap in resources, not bytes - #425
Open
kevin9327 wants to merge 1 commit into
Open
fix(tools): report the ListMcpResources cap in resources, not bytes#425kevin9327 wants to merge 1 commit into
kevin9327 wants to merge 1 commit into
Conversation
`gate_mcp_resources` caps the list at `MCP_RESOURCE_LIMIT` (200 resources),
then describes that truncation with `truncation_notice`, which is written
for byte budgets and was handed `MCP_TEXT_LIMIT`. A server returning 250
resources produced:
[truncated: ListMcpResources result exceeded 32768 bytes; showing 200 of 250 bytes]
Neither figure describes what happened: 32768 is a text budget this path
never applies, and the counts are resources rather than bytes. The notice
goes into a sentinel resource's description, so it is what the model reads
to learn why the list is short -- and it invites the conclusion that the
list was cut for size and would fit under a smaller byte budget.
State the cap that was actually applied, in its own unit, matching the
wording the sibling item-count truncation in `gate_mcp` already uses.
Co-Authored-By: Claude Opus 5 <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.
Follow-up in the area
0f564c0("fix(tools): preserve accurate truncation notices") just curated.The bug
gate_mcp_resourcescaps the list by resource count:…and then describes that truncation with
truncation_notice, which is written for byte budgets, handedMCP_TEXT_LIMIT:An MCP server returning 250 resources therefore produces:
Neither figure describes what happened.
32768is a limit this path never applies, and the counts are resources, not bytes.This string is not diagnostic-only: it is the
descriptionof thetruncated:list-mcp-resourcessentinel resource appended to the list, so it is what the model reads to learn why the list is short. As written it invites the conclusion that the list was cut for size and would fit under a smaller byte budget, when the cap is a flat count and nothing about resource size would change it.The fix
State the cap that was actually applied, in its own unit — matching the wording the sibling item-count truncation in
gate_mcpalready uses 130 lines above:"[truncated: MCP content items exceeded {MCP_CONTENT_ITEM_LIMIT} items; showing {MCP_CONTENT_ITEM_LIMIT} of {original_items} items]"truncation_noticeis left alone; every one of its other callers really is gating bytes.Verification
cargo +1.95 test --package cursor-server --lib tool_call_result::gateBefore (notice reverted, test kept) — the assertion prints the exact shipped string:
After:
gate_mcp_resourceshad no test before this; the new one also pins that the sentinel is appended and carries thetruncated:list-mcp-resourcesuri, which is the marker the function uses to stay idempotent.Gates (
make check, Rust half):cargo fmt --all -- --check— cleancargo clippy --workspace --all-targets -- -D warnings— clean on CI's stable; see notecargo test --workspace --all-targets— all suites greenToolchain note: this machine's
stableis broken, so the gates ran with+1.95. Clippy 1.95 reports acollapsible_matcherror atserver/src/cursor/compile/model.rs:109on unmodifiedmain; that is a 1.95-only false positive (its own suggestion,"fast" if parse_bool(parameter)? =>, does not compile —?is not allowed in a match guard) and CI's 1.98.1 does not emit it, somainis green. Clippy here therefore ran with-A clippy::collapsible_match; this diff is unaffected either way.