Skip to content

feat(mcp): deleted_state trash listing for list_charts and list_dashboards - #41855

Merged
rusackas merged 4 commits into
apache:masterfrom
gkneighb:feat/mcp-deleted-state-list-filter
Jul 16, 2026
Merged

rusackas merged 4 commits into
apache:masterfrom
gkneighb:feat/mcp-deleted-state-list-filter

Conversation

@gkneighb

@gkneighb gkneighb commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

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):

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:
  • 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)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8

…oards

Expose the soft-delete trash (apache#40128, apache#40129) to MCP list tools via a
deleted_state param ('include'/'only'). Reuses the REST
Chart/DashboardDeletedStateFilter classes — which own the restore-
audience scoping (owners or admins only) — through BaseDAO.list's
custom_filters hook, with a DeletedStateBoundFilter adapter binding the
caller's value since the DAO invokes custom filters with value=None.
The DAO call is wrapped in the skip_visibility_filter context manager
so the soft-delete ORM listener is bypassed for both the count and
fetch executions, with guaranteed release. deleted_at is forced into
loaded columns and added to ChartInfo/DashboardInfo so trashed rows
are distinguishable in 'include' mode. 10 unit tests.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
@dosubot dosubot Bot added api Related to the REST API dashboard Namespace | Anything related to the Dashboard labels Jul 7, 2026
@bito-code-review

bito-code-review Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #811aea

Actionable Suggestions - 0
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • superset/mcp_service/app.py - 1
Review Details
  • Files reviewed - 11 · Commit Range: 8eb3b58..8eb3b58
    • superset/mcp_service/app.py
    • superset/mcp_service/chart/schemas.py
    • superset/mcp_service/chart/tool/list_charts.py
    • superset/mcp_service/dashboard/schemas.py
    • superset/mcp_service/dashboard/tool/list_dashboards.py
    • superset/mcp_service/mcp_core.py
    • tests/unit_tests/mcp_service/chart/tool/test_generate_chart.py
    • tests/unit_tests/mcp_service/chart/tool/test_list_charts_deleted_state.py
    • tests/unit_tests/mcp_service/dashboard/tool/test_dashboard_tools.py
    • tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py
    • tests/unit_tests/mcp_service/test_mcp_core.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@github-actions github-actions Bot removed the api Related to the REST API label Jul 7, 2026
Comment thread superset/mcp_service/mcp_core.py Resolved
@bito-code-review

Copy link
Copy Markdown
Contributor

The suggestion to add an explicit return type hint to the fixture function is correct and aligns with standard Python type-annotation practices. To resolve this, you should update the function signature to include the appropriate return type, for example: def mock_auth() -> Any:.

Regarding other comments on this PR, I have checked the available review data, and there are no additional comments recorded in the provided review file. Therefore, no further fixes are required at this time.

tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py

@pytest.fixture
def mock_auth() -> Any:
    # ... implementation ...

@netlify

netlify Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 1eda9e7
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a52efd286bae500088469c6
😎 Deploy Preview https://deploy-preview-41855--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 24.32432% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.82%. Comparing base (5e6b29d) to head (3b1d364).
⚠️ Report is 48 commits behind head on master.

Files with missing lines Patch % Lines
superset/mcp_service/mcp_core.py 16.12% 26 Missing ⚠️
superset/mcp_service/chart/tool/list_charts.py 0.00% 1 Missing ⚠️
...rset/mcp_service/dashboard/tool/list_dashboards.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #41855      +/-   ##
==========================================
- Coverage   64.88%   64.82%   -0.06%     
==========================================
  Files        2742     2746       +4     
  Lines      153378   153671     +293     
  Branches    35168    35201      +33     
==========================================
+ Hits        99516    99616     +100     
- Misses      51958    52145     +187     
- Partials     1904     1910       +6     
Flag Coverage Δ
hive 39.04% <24.32%> (-0.03%) ⬇️
mysql 57.87% <24.32%> (-0.10%) ⬇️
postgres 57.93% <24.32%> (-0.10%) ⬇️
presto 41.03% <24.32%> (-0.03%) ⬇️
python 59.31% <24.32%> (-0.11%) ⬇️
sqlite 57.54% <24.32%> (-0.10%) ⬇️
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…ip rename: owned_by_me -> edited_by_me, editor_filter_column)
Comment thread superset/mcp_service/mcp_core.py Resolved
Comment thread superset/mcp_service/mcp_core.py Resolved
@bito-code-review

bito-code-review Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #81f0c8

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 8eb3b58..2420e52
    • 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
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@aminghadersohi aminghadersohi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RBAC/tenancy verdict: SOUND. BaseDAO.list() applies base_filter (ChartFilter/DashboardAccessFilter) unconditionally, before custom_filters — the new DeletedStateBoundFilter adapter only forwards the caller's choice into the pre-existing ChartDeletedStateFilter/DashboardDeletedStateFilter (OSS #40130, untouched by this diff), which already restrict soft-deleted rows to editors/admins. Trashed-row visibility = base_filter ∩ editor-or-admin — never looser than live-row visibility. Guest/embedded tokens excluded by the same pre-existing guest-scoping check. No cross-tenant/guest trash exposure found.

Default-is-active: confirmed — deleted_state defaults to None, and _build_deleted_state_filter short-circuits before any filter/bypass engages, so existing callers are unaffected.

deleted_state validation: sound — bounded Literal["include","only"] | None at the schema layer, with a defensive re-validation in the shared core class.

Two findings below (no BLOCKER/HIGH). Existing codeant/bito type-annotation threads are already declined by the author with a standing rationale — not re-filed here.

Comment thread superset/mcp_service/mcp_core.py Resolved
- Direct unit tests for the defensive core branches: None short-circuit,
  invalid-value rejection (which pydantic's Literal shields at the
  schema layer), and unconfigured-resource rejection
- Mirror the three chart-side tests on the dashboard tool for parity
(review: aminghadersohi)

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
@bito-code-review

bito-code-review Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #dcec7f

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 2420e52..3b1d364
    • tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py
    • tests/unit_tests/mcp_service/test_mcp_core.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@aminghadersohi aminghadersohi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at new HEAD 3b1d364dfa5dda5771c207fd0d551b6084e7328d (prior HEAD 2420e52946160ce64df2489e65c03bf079a4cc18, review #4688865568). Diff is test-only — no production code changed since round 1, so the round-1 RBAC-scoping / default-is-active / deleted_state-validation verdicts still hold as-is.

Both round-1 findings are cleanly closed by commit 3b1d364dfa:

  • MEDIUM (mcp_core.py:334 coverage gap): test_mcp_core.py now has test_build_deleted_state_filter_none_short_circuits, test_build_deleted_state_filter_rejects_invalid_value, and test_build_deleted_state_filter_rejects_unconfigured_resource — exercising _build_deleted_state_filter directly (bypassing the pydantic Literal schema gate), which is exactly the coverage gap flagged: both raise ValueError branches are now hit by a real test, not just shielded by schema validation.
  • NIT (dashboard test parity): test_list_dashboards_deleted_state.py now mirrors all three chart-side tests (..._default_has_no_deleted_state_filter, ..._no_deleted_state_no_visibility_bypass, ..._deleted_state_invalid_value_rejected).

No new findings from us this round. The 3 new codeant threads since round 1 are the same inferable-type-annotation nit pattern already declined by the author with a standing rationale (constants/locals/test lambdas with inferable types, mypy passes) — not re-raised here.

@rusackas

Copy link
Copy Markdown
Member

@gkneighb did you want to address anything from the thread before merging? Seems we're not blocked, per se, but I don't want to cause the need for a follow-up PR.

@gkneighb

Copy link
Copy Markdown
Contributor Author

Nothing outstanding — all review threads are resolved and CI is green. The two findings from the review pass (defensive-branch coverage in _build_deleted_state_filter and dashboard/chart test parity) are fixed at HEAD, and the type-annotation threads were declined with the standing rationale you've seen on the sibling PRs. Ready to merge; no follow-up needed. Thanks!

@rusackas
rusackas merged commit 2f7afe4 into apache:master Jul 16, 2026
62 checks passed
rdg0 pushed a commit to rdg0/superset that referenced this pull request Jul 20, 2026
tien238lnd added a commit to tien238lnd/superset that referenced this pull request Sep 17, 2026
…e for list_datasets

The MCP server can create datasets but cannot delete them, so an agent that
creates exploratory virtual datasets has no way to clean them up. Charts and
dashboards already have delete, restore and trash listing (apache#41472, apache#41842,
apache#41855), and dataset soft-delete landed in apache#40130, but the MCP side of it
was never added.

- delete_dataset: delete by numeric ID or UUID via 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.
- restore_dataset: restore a trashed dataset via RestoreDatasetCommand, with
  distinct NotFound, NotDeleted and LogicalDuplicate errors. The lookup uses
  the same filter bypasses as the command.
- list_datasets: deleted_state ('include' / 'only') reusing
  DatasetDeletedStateFilter, so trashed datasets can be found and restored.
  DatasetInfo gains deleted_at.

Co-Authored-By: Claude Opus 5 <[email protected]>
rusackas added a commit that referenced this pull request Sep 23, 2026
…dashboards

#41855 added a deleted_state parameter to list_charts and list_dashboards for
listing soft-deleted (trashed) objects, but the MCP server docs never
mentioned it.

Co-Authored-By: Evan Rusackas <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dashboard Namespace | Anything related to the Dashboard size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants