aminghadersohi opened a new pull request, #41611:
URL: https://github.com/apache/superset/pull/41611
### SUMMARY
Adds 4 new MCP tools that surface Superset's semantic layer to LLM clients,
spanning both built-in `SqlaTable` datasets and external `SemanticView`
implementations.
**Primary workflow** (as recommended in research spike):
1. `list_metrics` → discover available metrics and their compatible
dimensions inline
2. `get_table` → query data using chosen metrics and dimensions
**Tools added:**
- **`list_metrics`** — Unified metric discovery across built-in datasets and
external semantic views. Returns `MetricInfo` objects with
`compatible_dimensions` included per metric for progressive query building.
Supports search by name/description, filtering by `dataset_id` or `view_id`,
and pagination.
- **`get_table`** — Query a data source (built-in or external) using metric
and dimension names. Routes to `ChartDataCommand` (built-in `SqlaTable`) or the
semantic view's query path (external) based on `dataset_id` vs `view_id`.
Returns tabular results with column metadata and cache status.
- **`get_compatible_dimensions`** — Returns dimensions valid to add to the
current metric/dimension selection. For built-in datasets: all groupby-enabled
columns. For external semantic views: delegates to
`SemanticView.get_compatible_dimensions()`.
- **`get_compatible_metrics`** — Returns metrics valid to add given a
dimension selection. For built-in datasets: all metrics (SQL GROUP BY has no
metric-level constraints). For external: delegates to
`SemanticView.get_compatible_metrics()`.
**Design decisions:**
- External semantic view calls degrade gracefully when the registry is empty
(OSS default — logs a warning per view, continues)
- All tools use `dataset_id` / `view_id` from `list_metrics` to avoid
ambiguity when metric names collide across sources
- Follows all existing patterns: `@tool` decorator with
`tags`/`class_permission_name`/`ToolAnnotations`, Pydantic schemas, DAO-based
lookups, `event_logger`, `ctx` logging, ASF license headers
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — MCP tool additions (no UI changes)
### TESTING INSTRUCTIONS
1. Start the MCP server
2. List metrics: `list_metrics(request={"search": "revenue"})`
3. Pick a metric from the response, note its `dataset_id` (or `view_id`) and
a `compatible_dimensions` entry
4. Query: `get_table(request={"dataset_id": <id>, "metrics": ["<metric>"],
"dimensions": ["<dim>"], "row_limit": 10})`
5. For external semantic views (requires a registered SemanticView): use
`view_id` in place of `dataset_id`
6. Verify `get_compatible_dimensions` and `get_compatible_metrics` return
valid subsets for a known view
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
- [x] Introduces new feature or API
- [ ] Removes existing feature or API
--
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]