fix(mcp): cap search_metadata response size to prevent LLM context overflow#28383
Conversation
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
1 similar comment
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
Code Review ✅ Approved 2 resolved / 2 findingsLimits search_metadata response size with a 100k character cap and 0.8 safety factor to prevent LLM context overflow. Resolves excessive log noise by downgrading response size messaging to DEBUG. ✅ 2 resolved✅ Performance: INFO-level log on every search response is noisy
✅ Edge Case: Proportional trimming may not bring response under the cap
OptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
There was a problem hiding this comment.
Pull request overview
This PR mitigates LLM context-window overflows caused by overly large search_metadata responses in the MCP module by adding a hard response-size cap and updating the tool schema guidance to encourage smaller result sets for broad queries.
Changes:
- Added a
MAX_RESPONSE_CHARScap (100k) tosearch_metadataresponses and trim results when exceeded. - Updated the tool schema (
tools.json) to guide smallersizevalues for broad/generic queries and adjusted the pagination example default. - Refined the “many results” guidance message to push toward narrower queries.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/SearchMetadataTool.java |
Adds response-size measurement + trimming logic and updates user guidance messaging. |
openmetadata-mcp/src/main/resources/json/data/mcp/tools.json |
Updates the size parameter description and example to reduce broad-query payload sizes. |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
8ac97a1 to
41f37a6
Compare
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
🟡 Playwright Results — all passed (10 flaky)✅ 4247 passed · ❌ 0 failed · 🟡 10 flaky · ⏭️ 87 skipped
🟡 10 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 |
…erflow (#28383) * fix(mcp): cap search_metadata response size and truncate columnNames * fix(mcp): remove column truncation, guide LLM to use smaller page sizes
Describe your changes:
Fixes #28382
Type of change:
High-level design:
N/A — small change.
Tests:
Use cases covered
Unit tests
Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes #28382: fix(mcp): cap search_metadata response size to prevent LLM context overflowFixes #28382above.Summary by Gitar
DEBUGto reduce log noise.testResponseTrimmedWhenExceedingCharLimitand related cases toSearchMetadataAggregationTestto verify payload truncation logic.This will update automatically on new commits.