gkneighb opened a new pull request, #43567:
URL: https://github.com/apache/superset/pull/43567
### SUMMARY
Adds a `generate_chart` MCP plugin for the **funnel** chart type (`viz_type:
funnel`), so the MCP `generate_chart` tool can produce funnels. Funnel is a
shipped Superset viz type that had no MCP plugin; this closes that gap.
The plugin mirrors the frontend Funnel `buildQuery` contract: a single
`groupby` dimension whose values become the funnel stages, plus one `metric`
sizing each stage. When `sort_by_metric` is set (the frontend default), the
query orders stages by the metric descending.
It follows the established plugin pattern (`pie`/`waterfall`) — a config
schema, a `map_*_config` mapper, a plugin class, and registration:
- **`FunnelChartConfig`** — `dimension` + `metric` required; optional
`sort_by_metric`, `row_limit` (frontend default 10), `filters`, `color_scheme`.
Added to the `ChartConfig` discriminated union and the `get_chart_type_schema`
adapters. A dimension may not be a `saved_metric`/`sql_expression`
(metric-only), matching the pie schema.
- **`map_funnel_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`).
- **`FunnelChartPlugin`** — registered in the plugin registry; `funnel` was
already present in the recommendation category map.
The field set is intentionally minimal (core query contract). Cosmetic
controls such as `label_type` were deliberately left out for a follow-up —
funnel's `label_type` is a numeric ECharts enum that needs a string→int
mapping, which is out of scope here.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend/MCP only, no UI change.
### TESTING INSTRUCTIONS
`pytest tests/unit_tests/mcp_service/chart/test_funnel_chart.py` — 16 unit
tests cover schema validation (required fields, extra-field rejection,
dimension-not-a-metric), native `groupby` aliasing, `ChartConfig` union
dispatch, `form_data` mapping
(viz_type/groupby/metric/sort/row_limit/filters/saved-metric), and registry
integration (registration, `resolve_viz_type`, `display_name`, `pre_validate`).
To exercise end-to-end: call the `generate_chart` MCP tool with
`{"chart_type": "funnel", "dimension": {"name": "stage"}, "metric": {"name":
"leads", "aggregate": "SUM"}}`.
### 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]