Skip to content

refactor(mcp): shared trim util + global response size-budget net#28764

Open
Vishnuujain wants to merge 3 commits into
mainfrom
fix/mcp-shared-response-trim
Open

refactor(mcp): shared trim util + global response size-budget net#28764
Vishnuujain wants to merge 3 commits into
mainfrom
fix/mcp-shared-response-trim

Conversation

@Vishnuujain
Copy link
Copy Markdown
Contributor

De-duplicates payload-trimming logic across MCP tools and adds a dispatch-level size cap so every tool is bounded.

What

  • New 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).
  • New McpParams — shared getInt/getBoolean/getDouble arg coercion (replaces 3 private copies).
  • Global size net in DefaultToolContext — serializes the result once; if it exceeds 100k chars, returns a compact truncated:true envelope. This is the floor for tools with no per-tool trim (get_entity_details, get_test_definitions).
  • Error messages null-guarded — broad catches no longer surface "... null" when an exception has no message.

Notes

  • Behavior-preserving: the two truncate conventions are kept distinct; per-tool smart trims (search proportional drop, lineage/RCA actionable hints) are unchanged — the global net only adds a floor.
  • Backend repositories and the ES lineage paths are untouched.
  • 98 unit tests pass; live-verified against a running MCP server (no payload-shape change, no vector-key leaks).

@Vishnuujain Vishnuujain added the safe to test Add this label to run secure Github workflows on PRs label Jun 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Add a closing reference such as Fixes #12345 to the PR description (accepted keywords: Fixes, Closes, Resolves).

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 skip-pr-checks label.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

🟡 Playwright Results — all passed (14 flaky)

✅ 4264 passed · ❌ 0 failed · 🟡 14 flaky · ⏭️ 88 skipped

Shard Passed Failed Flaky Skipped
🟡 Shard 1 300 0 1 4
🟡 Shard 2 803 0 1 9
🟡 Shard 3 806 0 5 8
🟡 Shard 4 846 0 1 12
🟡 Shard 5 718 0 3 47
🟡 Shard 6 791 0 3 8
🟡 14 flaky test(s) (passed on retry)
  • Features/Pagination.spec.ts › should test Table columns complete flow with search (shard 1, 1 retry)
  • Features/DataQuality/BundleSuiteBulkOperations.spec.ts › Create new Bundle Suite with bulk selected test cases (shard 2, 1 retry)
  • Features/IncidentManager.spec.ts › Resolving incident & re-run pipeline (shard 3, 1 retry)
  • Features/KnowledgeCenterTextEditor.spec.ts › Rich Text Editor - Advanced Blocks (shard 3, 1 retry)
  • Features/RTL.spec.ts › Verify Following widget functionality (shard 3, 1 retry)
  • Features/UserProfileOnlineStatus.spec.ts › Should not show online status for inactive users (shard 3, 1 retry)
  • Flow/ExploreAggregationCountsMatching.spec.ts › should verify left panel counts and tab search results for normal search (shard 3, 1 retry)
  • Flow/PersonaFlow.spec.ts › Set default persona for team should work properly (shard 4, 1 retry)
  • Pages/Entity.spec.ts › Tier Add, Update and Remove (shard 5, 1 retry)
  • Pages/EntityDataSteward.spec.ts › Tier Add, Update and Remove (shard 5, 1 retry)
  • Pages/ExplorePageRightPanel_KnowledgeCenter.spec.ts › Should remove user owner for knowledgeCenter (shard 5, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify lineage schema filter selection (shard 6, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab IS visible for supported type: searchIndex (shard 6, 1 retry)
  • Pages/Lineage/PlatformLineage.spec.ts › Verify domain platform view (shard 6, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@Vishnuujain Vishnuujain added the To release Will cherry-pick this PR into the release branch label Jun 5, 2026
@gitar-bot
Copy link
Copy Markdown

gitar-bot Bot commented Jun 5, 2026

Code Review ✅ Approved

Consolidates 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.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant