gkneighb opened a new pull request, #41860:
URL: https://github.com/apache/superset/pull/41860
### SUMMARY
Adds **histogram** and **box plot** chart type plugins to the MCP
`generate_chart` registry (#39922), extending the creatable chart types from 7
families to 9. These are the first statistical charts the MCP service can
generate — agents doing exploratory analysis previously had no way to look at a
value distribution or compare spreads.
Design notes:
- **Follows the plugin contract exactly**: each type is a self-contained
`ChartTypePlugin` under `superset/mcp_service/chart/plugins/` (schema
pre-validation with LLM-friendly fix suggestions, column-ref
extraction/canonicalization, form_data mapping, name generation), registered in
`plugins/__init__.py`. No registry or core changes.
- **form_data matches the frontend buildQuery contracts** for
`viz_type="histogram_v2"` (single `column` string, `groupby` names,
`bins`/`normalize`/`cumulative` — bins default 5, same as the controlPanel) and
`viz_type="box_plot"` (`columns` = distribute-across values, `groupby` = series
dimensions, `metrics`, `whiskerOptions`). Box plot whiskers use an enum-style
`whisker_type` (`tukey` / `min_max` / `percentile` with validated
`percentile_low < percentile_high`) that serializes to the exact strings the
frontend `boxplotOperator` parses, including its `"<low>/<high> percentiles"`
regex format — an LLM never has to guess the magic strings.
- **Config schemas are strict** (unknown fields rejected, SQL expressions
rejected on dimension-position columns, saved_metric rejected on the
histogram's binned column) with descriptive Pydantic errors, consistent with
the existing chart configs.
- `histogram_v2` added to the viz_type→chart_type alias map so clients that
send Superset's public viz name instead of the discriminator get translated
rather than rejected; `get_chart_type_schema` gains both types with examples;
`generate_chart` docstring and server instructions updated.
Part of a series extending MCP chart-type coverage (registry groundwork:
#39922).
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A (MCP service; no UI changes)
### TESTING INSTRUCTIONS
```bash
pytest tests/unit_tests/mcp_service/chart/test_histogram_boxplot_charts.py
# 24 new tests
pytest tests/unit_tests/mcp_service/chart/
# full chart suite
```
Manual: via an MCP client, `generate_chart` with
`{"dataset_id": <id>, "config": {"chart_type": "histogram", "column":
{"name": "<numeric_col>"}, "bins": 20}}`
returns a working preview; same for
`{"chart_type": "box_plot", "metrics": [{"name": "<col>", "aggregate":
"AVG"}], "distribute_across": [{"name": "<category_col>"}]}`.
### 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)
https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
--
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]