gkneighb opened a new pull request, #41842:
URL: https://github.com/apache/superset/pull/41842
### SUMMARY
Adds `restore_chart` and `restore_dashboard` MCP tools, exposing the
soft-delete restore capability introduced in #40129 / #40128 to MCP clients.
With soft-delete rolling out behind the `SOFT_DELETE` feature flag, an LLM
agent can trash a chart or dashboard via the REST-backed delete flows (and,
pending #41472, via MCP delete tools) but has no way to undo it — these tools
close that loop.
Design notes:
- **Delegates to `Restore{Chart,Dashboard}Command`** — ownership checks, the
"is actually soft-deleted" guard, and transactional wrapping all live in the
existing command layer; the tools add no new authorization logic.
- **Accepts numeric ID or UUID.** The restore commands are UUID-keyed, but
MCP list/info/delete tools deal in numeric IDs, so the tools resolve the
identifier via `find_by_id_or_uuid(..., skip_visibility_filter=True)`. Matching
the command's own lookup semantics, the visibility filter is the *only* bypass
— the DAO `base_filter` stays in effect, so rows the user can't see in the live
UI stay hidden, and ownership is then enforced by the command.
- **Not gated on `SOFT_DELETE`** — mirroring the REST `POST
/api/v1/chart/<uuid>/restore` endpoint, restore stays available even if the
flag is later disabled, so rows trashed while it was on remain recoverable.
- **LLM-friendly errors** — distinct `NotFound` vs `NotDeleted` (`"is not in
trash; nothing to restore"`) error types, and the established
`permission_denied: true` / "do not retry; ask the user" convention for
ownership failures.
Part of a series filling out MCP resource-lifecycle coverage (delete:
#41472).
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A (MCP service tools; no UI changes)
### TESTING INSTRUCTIONS
Unit tests (12 new, run through the async FastMCP client like the other tool
tests):
```bash
pytest tests/unit_tests/mcp_service/chart/tool/test_restore_chart.py \
tests/unit_tests/mcp_service/dashboard/tool/test_restore_dashboard.py
```
Manual: with `FEATURE_FLAGS = {"SOFT_DELETE": True}`, delete a chart you own
(UI or API), then call the `restore_chart` MCP tool with its numeric ID or UUID
— the chart reappears in list/detail endpoints. Calling it again returns
`error_type: "NotDeleted"`. Calling it on someone else's trashed chart returns
`permission_denied: true`.
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [x] Required feature flags: `SOFT_DELETE` (to produce trashed rows; the
restore tools themselves are not gated)
- [ ] 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]