refactor(mcp): shared trim util + global response size-budget net#28764
refactor(mcp): shared trim util + global response size-budget net#28764Vishnuujain wants to merge 3 commits into
Conversation
…t net, error-message null-guards
…res the size-budget net
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
🟡 Playwright Results — all passed (14 flaky)✅ 4264 passed · ❌ 0 failed · 🟡 14 flaky · ⏭️ 88 skipped
🟡 14 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
Code Review ✅ ApprovedConsolidates payload-trimming logic and parameter coercion into centralized utilities, and implements a global response size-budget net across MCP tools. All functions maintain original truncation behavior while preventing overflows for previously unbounded responses. OptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
De-duplicates payload-trimming logic across MCP tools and adds a dispatch-level size cap so every tool is bounded.
What
McpResponseTrim— single home for the truncation budgets, the 100k size cap, the truncate helpers, and the embedding/vector field list (previously copy-pasted across 4 tools).McpParams— sharedgetInt/getBoolean/getDoublearg coercion (replaces 3 private copies).DefaultToolContext— serializes the result once; if it exceeds 100k chars, returns a compacttruncated:trueenvelope. This is the floor for tools with no per-tool trim (get_entity_details,get_test_definitions)."... null"when an exception has no message.Notes