aminghadersohi opened a new pull request, #40961:
URL: https://github.com/apache/superset/pull/40961
### SUMMARY
Adds a new read-only MCP tool, `get_dashboard_datasets`, that lists all
datasets used by a dashboard's charts — the prerequisite context an AI agent
needs before configuring native filters on a dashboard (e.g. picking filter
target columns and datasets).
Design notes:
- Accepts a dashboard identifier as numeric ID, UUID, or slug (same
resolution as `get_dashboard_info`, via `ModelGetInfoCore` with
`supports_slug=True`).
- Groups the dashboard's charts by datasource (mirroring
`Dashboard.datasets_trimmed_for_slices`) using the DAO layer, but returns the
full (capped) column and metric lists, since native-filter configuration
regularly needs columns that no chart references.
- Each dataset includes: id, uuid, table_name, schema, database (id + name +
backend), columns (column_name, type, is_dttm, verbose_name), metrics
(metric_name, expression, verbose_name), and the number of dashboard charts
using it.
- Respects data access: datasets the current user cannot access (per
`security_manager.can_access_datasource`) are excluded from the response and
only counted via `inaccessible_dataset_count`.
- Keeps responses LLM-friendly: per-dataset caps (100 columns / 50 metrics)
with `columns_truncated`/`metrics_truncated` flags and total counts, and all
user-controlled strings are sanitized/escaped with the existing LLM-context
helpers.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A (no UI changes — MCP service tool)
### TESTING INSTRUCTIONS
- Unit tests: `pytest
tests/unit_tests/mcp_service/dashboard/tool/test_get_dashboard_datasets.py`
- Manually: start the MCP service and call `get_dashboard_datasets` with
`{"identifier": <dashboard id|uuid|slug>}`; verify the datasets, columns,
metrics, and database info match the dashboard's charts, and that datasets
outside the user's access are excluded.
### 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
--
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]