tien238lnd opened a new pull request, #44337: URL: https://github.com/apache/superset/pull/44337
### SUMMARY The MCP server can create datasets but cannot delete them or change them: an agent that creates exploratory virtual datasets has no way to clean them up, and fixing a virtual dataset's SQL means creating a new dataset and repointing every chart. Charts and dashboards already have delete, restore and trash listing (#41472, #41842, #41855), and dataset soft-delete landed in #40130, but the MCP side of it was never added. **`delete_dataset`** — delete by numeric ID or UUID through `DeleteDatasetCommand`, which enforces editorship. The response reports whether the row went to trash (`SOFT_DELETE`) or was removed permanently, plus the number of charts and dashboards built on the dataset, counted the same way as `GET /api/v1/dataset/<pk>/related_objects` so inaccessible objects are not disclosed. There is deliberately no purge tool; permanently emptying the trash stays a UI action. **`restore_dataset`** — restore a trashed dataset through `RestoreDatasetCommand`, with distinct `NotFound`, `NotDeleted` and `LogicalDuplicate` errors. **`list_datasets`** — a `deleted_state` parameter (`include` / `only`) reusing `DatasetDeletedStateFilter`, so trashed datasets can be found and restored. `DatasetInfo` gains `deleted_at`. **`update_dataset`** — partially updates `table_name`, `sql` (virtual datasets only), `description`, `main_dttm_col` and `cache_timeout`. It runs the same pair of commands as `PUT /api/v1/dataset/<pk>?override_columns=true`: `UpdateDatasetCommand`, then `RefreshDatasetCommand` when columns need re-syncing. Columns re-sync by default when the SQL changes, as "Sync columns from source" does in the dataset editor, and the response lists added and removed columns so the caller can warn about charts using removed ones. The update commits before the refresh, so a failed refresh is reported as a warning next to the saved change rather than as a failure. Clearing `sql` is rejected, since that would silently turn a virtual dataset into a physical one; columns, metrics, editors and the source database are out of scope. All three mutating tools are added to `MCP_CACHE_CONFIG["excluded_tools"]`. ### TESTING INSTRUCTIONS `pytest tests/unit_tests/mcp_service/dataset` Manually, through an MCP client: - `create_virtual_dataset`, then `update_dataset` with new `sql` — columns re-sync and `added_columns`/`removed_columns` match the change. - Set `main_dttm_col` to a column that does not exist — the call is rejected and names the problem. - `delete_dataset` the same dataset. With `SOFT_DELETE` on, `list_datasets` with `deleted_state="only"` shows it and `restore_dataset` brings it back; with the flag off the delete is permanent and `restore_dataset` returns `NotFound`. - As a user who is neither owner nor Admin, all three write tools must be refused. ### ADDITIONAL INFORMATION - [x] Introduces new 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]
