Skip to content

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

Merged
aminghadersohi merged 2 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/mcp-xy-series-limit
May 22, 2026
Merged

feat(mcp): add series_limit to generate_chart XY config#40307
aminghadersohi merged 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

@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.13%. Comparing base (e25d708) to head (c256076).
⚠️ Report is 1 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.13%   64.13%   -0.01%     
==========================================
  Files        2592     2592              
  Lines      138907   138912       +5     
  Branches    32217    32218       +1     
==========================================
+ Hits        89085    89087       +2     
- Misses      48290    48293       +3     
  Partials     1532     1532              
Flag Coverage Δ
hive 39.30% <33.33%> (+<0.01%) ⬆️
mysql 58.81% <33.33%> (-0.01%) ⬇️
postgres 58.89% <33.33%> (-0.01%) ⬇️
presto 40.97% <33.33%> (-0.01%) ⬇️
python 60.45% <33.33%> (-0.01%) ⬇️
sqlite 58.53% <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.

@aminghadersohi aminghadersohi force-pushed the aminghadersohi/mcp-xy-series-limit branch 3 times, most recently from c3a7704 to f658a82 Compare May 21, 2026 15:10
@aminghadersohi aminghadersohi marked this pull request as ready for review May 21, 2026 17:51
@dosubot dosubot Bot added the api Related to the REST API label May 21, 2026
@aminghadersohi aminghadersohi requested a review from geido May 21, 2026 17:52
@github-actions github-actions Bot removed the api Related to the REST API label May 21, 2026
aminghadersohi and others added 2 commits May 21, 2026 19:17
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.
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>
@aminghadersohi aminghadersohi force-pushed the aminghadersohi/mcp-xy-series-limit branch from e25e5f8 to 563989a Compare May 21, 2026 23:19
@pull-request-size pull-request-size Bot added size/L and removed size/M labels May 21, 2026
@aminghadersohi aminghadersohi force-pushed the aminghadersohi/mcp-xy-series-limit branch from 563989a to c256076 Compare May 21, 2026 23:22
@pull-request-size pull-request-size Bot added size/M and removed size/L labels May 21, 2026
@aminghadersohi aminghadersohi merged commit 5966bb1 into apache:master May 22, 2026
67 of 69 checks passed
@bito-code-review
Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped – PR Already Merged

Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.
No action is needed if you didn't intend to review it. To get a review, you can type /review in a comment and save it

sha174n pushed a commit to sha174n/superset that referenced this pull request May 22, 2026
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.

2 participants