gkneighb opened a new pull request, #41855:
URL: https://github.com/apache/superset/pull/41855

   ### SUMMARY
   
   Adds a `deleted_state` parameter (`"include"` / `"only"`) to the 
`list_charts` and `list_dashboards` MCP tools, mirroring the REST 
`chart_deleted_state` / `dashboard_deleted_state` rison filters introduced with 
soft-delete (#40128 / #40129). Without it, an MCP client has no way to 
enumerate trashed objects — which makes trash effectively invisible to LLM 
agents (and unrestorable, once restore tools land: #41842).
   
   Design notes:
   
   - **The REST filter classes are reused, not reimplemented.** 
`ChartDeletedStateFilter` / `DashboardDeletedStateFilter` own the 
restore-audience scoping (only owners — or admins — may enumerate soft-deleted 
rows). `ModelListCore` passes them through `BaseDAO.list`'s existing 
`custom_filters` hook via a small `DeletedStateBoundFilter` adapter, because 
the DAO invokes custom filters as `apply(query, None)` and the FAB filter 
treats `None` as "live rows only" — the adapter binds the caller's actual 
value. Keeping the audience scoping in one class means the cross-entity 
deleted-state contract can't drift between REST and MCP.
   - **Session-scoped visibility bypass via the `skip_visibility_filter` 
context manager.** The soft-delete ORM listener appends `deleted_at IS NULL` at 
execution time, and `BaseDAO.list` executes twice (count + fetch), so a 
per-query bypass is not enough. The context manager guarantees release even on 
exceptions, so code running later in the same request sees normal filtered 
visibility — the same scope-discipline the REST layer implements via 
`SoftDeleteApiMixin`.
   - **`deleted_at` is forced into loaded columns** whenever `deleted_state` is 
used (and added to the `ChartInfo`/`DashboardInfo` schemas + serializers), so 
trashed rows are distinguishable from live ones in `include` mode.
   - Resources whose `ModelListCore` doesn't configure a deleted-state filter 
reject the parameter with a clear error.
   
   Part of a series filling out MCP resource-lifecycle coverage (delete: 
#41472, restore: #41842).
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A (MCP service tools; no UI changes)
   
   ### TESTING INSTRUCTIONS
   
   Unit tests (10 new):
   
   ```bash
   pytest 
tests/unit_tests/mcp_service/chart/tool/test_list_charts_deleted_state.py \
          
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py
 \
          tests/unit_tests/mcp_service/test_mcp_core.py
   ```
   
   The underlying filter semantics (audience scoping, include/only behavior) 
are covered by the existing REST integration suite 
(`tests/integration_tests/charts/soft_delete_tests.py`), and the 
`skip_visibility_filter` context manager by 
`tests/unit_tests/models/test_soft_delete_mixin.py` — this PR reuses both 
mechanisms rather than duplicating them.
   
   Manual: with `FEATURE_FLAGS = {"SOFT_DELETE": True}`, delete a chart you 
own, then call `list_charts` with `{"deleted_state": "only"}` — the trashed 
chart is returned with a non-null `deleted_at`. As a non-admin, another user's 
trashed charts do not appear.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [x] Required feature flags: `SOFT_DELETE` (to produce trashed rows; the 
parameter itself is 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]

Reply via email to