gkneighb opened a new pull request, #43573:
URL: https://github.com/apache/superset/pull/43573
### SUMMARY
Adds a `generate_chart` MCP plugin for the **sankey** chart type (`viz_type:
sankey_v2`), so the MCP `generate_chart` tool can produce sankey flow diagrams.
Sankey is a shipped Superset viz type that had no MCP plugin; this closes that
gap.
The plugin mirrors the frontend Sankey `buildQuery` contract: a `source` and
a `target` column define the edges of the flow diagram (the query groups by
both) and one `metric` weights each edge. When `sort_by_metric` is set (the
frontend default), edges are ordered by the metric descending.
Follows the established plugin pattern
(`pie`/`funnel`/`gauge`/`treemap`/`heatmap`/`radar`/`bubble`/`waterfall`) — a
config schema, a `map_*_config` mapper, a plugin class, and registration:
- **`SankeyChartConfig`** — `source`, `target`, and `metric` required;
optional `sort_by_metric`, `row_limit`, `filters`, `color_scheme`. Added to the
`ChartConfig` discriminated union and the `get_chart_type_schema` adapters.
`source`/`target` may not be `saved_metric`/`sql_expression` (node dimensions,
not metrics).
- **`map_sankey_config`** — maps the config to `form_data`; saved metrics
pass through as a bare name string, ad-hoc metrics as SIMPLE/SQL adhoc objects.
- **`SankeyChartPlugin`** — registered in the plugin registry. `sankey_v2`
was absent from the recommendation category map, so this adds it (its own
`sankey` category).
The field set is intentionally minimal (core query contract).
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend/MCP only, no UI change.
### TESTING INSTRUCTIONS
`pytest tests/unit_tests/mcp_service/chart/test_sankey_chart.py` — 18 unit
tests cover schema validation (three required fields, `source`/`target`
not-a-metric, extra-field rejection), `ChartConfig` union dispatch, `form_data`
mapping (source/target/metric/sort/filters/saved-metric), and registry
integration (registration, `resolve_viz_type`, `display_name`, `pre_validate`,
recommendation category).
To exercise end-to-end: call the `generate_chart` MCP tool with
`{"chart_type": "sankey_v2", "source": {"name": "from_stage"}, "target":
{"name": "to_stage"}, "metric": {"name": "users", "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]