fix(mcp): return all chart query results - #42824
Draft
aminghadersohi wants to merge 1 commit into
Draft
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #42824 +/- ##
==========================================
- Coverage 65.73% 65.71% -0.02%
==========================================
Files 2843 2843
Lines 162672 162727 +55
Branches 37255 37267 +12
==========================================
+ Hits 106935 106941 +6
- Misses 53645 53693 +48
- Partials 2092 2093 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
SUMMARY
get_chart_datapreviously selected only the first entry returned byChartDataCommand, which dropped secondary results from charts whose query context contains multiple queries.This change preserves the existing top-level
columns,data, and row metadata as the first-query view for backward compatibility, and adds an optionalquery_resultsfield containing every query result for multi-query charts. Single-query charts retain their existing behavior. Response-size enforcement applies one shared row cap across the complete multi-query response so additional results cannot bypass the configured token limit.Mixed Timeseries is the chart type that explicitly builds two queries in the MCP chart query helper. The response handling also covers any saved query context containing multiple queries rather than coupling serialization to that visualization type.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Not applicable; this changes an MCP tool response without UI changes.
TESTING INSTRUCTIONS
pytest -q tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py tests/unit_tests/mcp_service/test_middleware.py(182 passed)pytest -q tests/unit_tests/mcp_service(3319 passed, 1 unrelated health-check failure because the local test configuration returned a null application version)uvx pre-commit run --files superset/mcp_service/chart/schemas.py superset/mcp_service/chart/tool/get_chart_data.py superset/mcp_service/utils/token_utils.py tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py tests/unit_tests/mcp_service/test_middleware.pypre-commit run --all-fileswas also run. Python checks passed; the repository-wide frontend hooks could not complete because frontend dependencies such asglobandpostcss-styled-syntaxare not installed, and repository-wide Ruff reported pre-existing violations outside this change.The regression coverage executes the unsaved Mixed Timeseries response path with two command results and asserts that both are returned. Additional coverage verifies the additive single-query behavior and shared response-size limiting.
ADDITIONAL INFORMATION
BACKWARD COMPATIBILITY
This is additive. Existing top-level fields continue to represent the first query, while multi-query responses additionally expose
query_results. Clients that ignore unknown fields are unaffected.EVAL EVIDENCE
Not applicable to this deterministic serialization change; no prompt, model routing, or model-generated output changed. The MCP regression suite results are listed above.
COST & LATENCY DELTA
No model or parameter changes. Multi-query responses include more data by design, bounded by the existing response token limit using response-wide truncation. No external model-cost or latency benchmark is available in the OSS worktree.
PROMPT / NON-DETERMINISM
No prompt changes and no non-deterministic behavior.
REVIEW GUIDANCE
Review the additive schema and response construction first, then the shared-budget truncation logic. Concurrent work touching
get_chart_datamay need to rebase carefully around the response construction paths.