gkneighb opened a new pull request, #43568:
URL: https://github.com/apache/superset/pull/43568
### SUMMARY
Adds a `generate_chart` MCP plugin for the **gauge** chart type (`viz_type:
gauge_chart`), so the MCP `generate_chart` tool can produce gauge charts. Gauge
is a shipped Superset viz type that had no MCP plugin; this closes that gap.
The plugin mirrors the frontend Gauge `buildQuery` contract: a single
`metric` whose value the dial displays, plus an optional multi `groupby` — with
no groupby the chart is a single dial; with a groupby it renders one dial per
row (capped at the frontend's limit of 10). `min_val`/`max_val` fix the dial
scale (both default to auto).
Follows the established plugin pattern (`pie`/`funnel`/`waterfall`) — a
config schema, a `map_*_config` mapper, a plugin class, and registration:
- **`GaugeChartConfig`** — `metric` required; optional `groupby` (list, one
dial per row), `row_limit` (default 10, capped 1–10 to match the frontend),
`min_val`/`max_val`, `filters`, `color_scheme`. Added to the `ChartConfig`
discriminated union and the `get_chart_type_schema` adapters. `groupby` entries
may not be `saved_metric`/`sql_expression` (dimensions, not metrics).
- **`map_gauge_config`** — maps the config to `form_data`; saved metrics
pass through as a bare name string, ad-hoc metrics as SIMPLE/SQL adhoc objects
(via the shared `create_metric_object`).
- **`GaugeChartPlugin`** — registered in the plugin registry; `gauge_chart`
was already present in the recommendation category map.
The field set is intentionally minimal (core query contract + the dial
scale). Cosmetic ECharts controls (start/end angle, intervals, pointer,
progress, etc.) are left for a follow-up.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend/MCP only, no UI change.
### TESTING INSTRUCTIONS
`pytest tests/unit_tests/mcp_service/chart/test_gauge_chart.py` — 17 unit
tests cover schema validation (metric required, groupby optional, row-limit cap
at 10, groupby-not-a-metric, extra-field rejection), `ChartConfig` union
dispatch, `form_data` mapping
(viz_type/groupby/metric/row_limit/min_val/max_val/filters/saved-metric), and
registry integration (registration, `resolve_viz_type`, `display_name`,
`pre_validate` with and without groupby).
To exercise end-to-end: call the `generate_chart` MCP tool with
`{"chart_type": "gauge_chart", "metric": {"name": "progress", "aggregate":
"AVG"}}`.
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [x] Introduces new feature or API
- [ ] Removes existing feature or API
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]