Skip to content

feat(mcp): add series_limit to generate_chart XY config#40307

Draft
aminghadersohi wants to merge 2 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/mcp-xy-series-limit
Draft

feat(mcp): add series_limit to generate_chart XY config#40307
aminghadersohi wants to merge 2 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/mcp-xy-series-limit

Conversation

@aminghadersohi
Copy link
Copy Markdown
Contributor

SUMMARY

Adds a series_limit parameter to XYChartConfig in the generate_chart MCP tool.

When group_by is set on an XY chart (line, bar, area, scatter), users can now control the maximum number of distinct series rendered by specifying series_limit. The value is forwarded as form_data["series_limit"], which Superset's echarts timeseries plugins use to cap the number of rendered series lines/bars.

Usage example:

{
  "dataset_id": 123,
  "config": {
    "chart_type": "xy",
    "x": {"name": "order_date"},
    "y": [{"name": "revenue", "aggregate": "SUM"}],
    "group_by": [{"name": "region"}],
    "kind": "line",
    "series_limit": 10
  }
}

When series_limit is not set (default None), the field is omitted from form_data and Superset applies no series cap.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — backend schema change only.

TESTING INSTRUCTIONS

  1. Call generate_chart with an XY config that includes group_by and series_limit: 5
  2. Verify the returned form_data contains "series_limit": 5
  3. Open the explore URL — the chart should show at most 5 series
  4. Call without series_limit — verify form_data does not contain series_limit

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

Add series_limit parameter to XYChartConfig so callers can control
how many distinct series (group_by values) the chart renders.  When
set, the value is forwarded as form_data["series_limit"], which
Superset's echarts timeseries plugins interpret to cap the number of
rendered series lines/bars.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.18%. Comparing base (68c145a) to head (aba0b42).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
superset/mcp_service/chart/chart_utils.py 20.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #40307      +/-   ##
==========================================
- Coverage   64.18%   64.18%   -0.01%     
==========================================
  Files        2591     2591              
  Lines      138455   138460       +5     
  Branches    32118    32119       +1     
==========================================
+ Hits        88871    88873       +2     
- Misses      48052    48055       +3     
  Partials     1532     1532              
Flag Coverage Δ
hive 39.41% <33.33%> (+<0.01%) ⬆️
mysql 59.06% <33.33%> (-0.01%) ⬇️
postgres 59.14% <33.33%> (-0.01%) ⬇️
presto 41.09% <33.33%> (-0.01%) ⬇️
python 60.57% <33.33%> (-0.01%) ⬇️
sqlite 58.78% <33.33%> (-0.01%) ⬇️
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Extract row/series limit assignment into a private helper to keep
map_xy_config within the McCabe complexity threshold, removing the
noqa: C901 suppression. Move series_limit schema tests out of
TestRowLimit and into a dedicated TestSeriesLimit class.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant