You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "championble3 (via GitHub)" <gi...@apache.org> on 2026/10/13 08:23:30 UTC
[I] MCP get_chart_data returns different numbers than the dashboard when saved query_context is missing or outdated [superset]
championble3 opened a new issue, #45237:
URL: https://github.com/apache/superset/issues/45237
### Bug description
Problem: Charts created or edited through the REST API/MCP have no query_context, or an outdated one. get_chart_data then rebuilds a generic query from form_data. For chart types where the frontend buildQuery adds logic (time grain, trendline, period comparison, SQL columns), this returns different numbers than the dashboard.
Example: big_number chart with time_grain_sqla: P3M, compare_lag: 1, show_trend_line: true. The dashboard shows the QoQ change; get_chart_data returns the plain sum of the metric.
Why it is hard to notice: the fallback only calls ctx.warning(...), which does not reach the client’s tool result, so an LLM client presents the number as correct. Charts with a stale saved context are not flagged at all.
Suggestions: (1) include a warning in the tool result (e.g. in insights) when the fallback is used; (2) mention in the tool description that exact results need a chart saved from Explore; (3) consider flagging a saved query_context older than the chart’s changed_on.
Related: [apache/superset#39413](https://github.com/apache/superset/pull/39413) (fixed update_chart), [apache/superset#45210](https://github.com/apache/superset/issues/45210), [#28446](https://github.com/apache/superset/issues/28446).
### Screenshots/recordings
_No response_
### Superset version
6.1.0
### Python version
3.11
### Node version
16
### Browser
Chrome
### Additional context
Observed on 6.1.0 (built-in MCP service) with charts created through the API. On current master the fallback still only calls ctx.warning, and insights has no entry for it.
### Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] MCP get_chart_data returns different numbers than the dashboard when saved query_context is missing or outdated [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed issue #45237: MCP get_chart_data returns different numbers than the dashboard when saved query_context is missing or outdated
URL: https://github.com/apache/superset/issues/45237
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] MCP get_chart_data returns different numbers than the dashboard when saved query_context is missing or outdated [superset]
Posted by "championble3 (via GitHub)" <gi...@apache.org>.
championble3 commented on issue #45237:
URL: https://github.com/apache/superset/issues/45237#issuecomment-6162425320
Thanks for the quick fix in [apache/superset#45250](https://github.com/apache/superset/pull/45250), the warning in insights is a big help.
One question about the longer-term picture, because it decides how we document this for our users: is re-saving the chart in Explore intended to remain the only way to get exact numbers from get_chart_data for charts created or edited through MCP?
As far as I can tell, generate_chart never stores a query_context, and update_chart now clears it, so every chart made or changed through MCP ends up in the fallback path, which skips the frontend buildQuery logic (time grain, trend line, period comparison, SQL columns). For those chart types the numbers differ from the dashboard until someone opens the chart in Explore and saves it.
Is there a plan or an appetite for either:
generating and persisting a query_context on the backend when MCP creates or updates a chart, or
having get_chart_data reuse the viz plugin’s query building so the fallback matches the dashboard?
If neither is planned, a note in the get_chart_data / generate_chart tool descriptions saying that charts need to be saved from Explore for exact results would at least set the right expectation for MCP clients.
One data point from testing on 6.1.0, in case it helps the form_data_key discussion in the review: for a monthly bar chart, get_chart_data with an unsaved form_data_key returned a single total (the sum of all months), while the saved chart returned one row per month. So the unsaved path also skips the time grain and gives a misleading number without a caveat.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org