Skip to content

feat(mcp): add delete_dashboard and restore_dashboard tools - #40956

Closed
aminghadersohi wants to merge 5 commits into
masterfrom
mcp-delete-dashboard
Closed

aminghadersohi wants to merge 5 commits into
masterfrom
mcp-delete-dashboard

Conversation

@aminghadersohi

@aminghadersohi aminghadersohi commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

Adds delete_dashboard and restore_dashboard tools to the Superset MCP service. AI agents that generate test dashboards (e.g. via generate_dashboard) previously had no way to clean them up — this closes that CRUD gap, with a recovery path.

delete_dashboard

  • Params: dashboard_id (int) and a required confirm boolean safety gate. The tool refuses with a clear error unless confirm=true is explicitly passed, forcing the caller (LLM) to state destructive intent. Single delete only — no bulk.
  • Backed by the existing DeleteDashboardCommand, so ownership checks, the report-schedule guard, and transactional semantics are identical to the REST API delete path. When the SOFT_DELETE feature flag is enabled the command soft-deletes (recoverable); otherwise it hard-deletes.
  • The response reports which semantics applied via a permanent field, and echoes what was deleted (id, title, slug, uuid) so the agent can restore it later. Confirm-gate messaging also adapts to the flag.
  • Structured error responses for: not confirmed, not found, forbidden (DashboardForbiddenError), and delete failure (including associated alerts/reports).

restore_dashboard

  • Named to match the platform vocabulary (POST /api/v1/dashboard/<uuid>/restore, RestoreDashboardCommand, SoftDeleteMixin.restore()).
  • Params: dashboard_id (int). Resolves the soft-deleted row (visibility filter skipped; base filter skipped so an owner's own trash stays reachable) and delegates to RestoreDashboardCommand, which re-checks ownership and slug uniqueness.
  • Structured error responses for: not found (hard-deleted rows included), exists-but-not-deleted, forbidden, slug conflict with an active dashboard (DashboardSlugConflictError), and restore failure.
  • No confirm gate — restore is the non-destructive direction (destructiveHint=False).

Both tools are tagged mutate with class_permission_name="Dashboard" and method_permission_name="write". Title/slug and error text are sanitized before LLM exposure, matching the other dashboard tools.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — backend MCP tools only, no UI changes.

TESTING INSTRUCTIONS

  1. pytest tests/unit_tests/mcp_service/dashboard/tool/test_delete_dashboard.py tests/unit_tests/mcp_service/dashboard/tool/test_restore_dashboard.py
  2. Or manually with SOFT_DELETE enabled: call delete_dashboard with {"dashboard_id": <id>, "confirm": false} and verify it refuses; retry with "confirm": true and verify the response has deleted: true, permanent: false; then call restore_dashboard with the same ID and verify the dashboard is visible again.
  3. With SOFT_DELETE disabled: delete_dashboard returns permanent: true and restore_dashboard reports the dashboard as not found.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: SOFT_DELETE (only for the recoverable-delete path and restore_dashboard; delete_dashboard works without it as a hard delete)
  • 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

@codecov

codecov Bot commented Jun 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 39.31624% with 71 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.54%. Comparing base (15f8b8e) to head (468ac19).
⚠️ Report is 18 commits behind head on master.

Files with missing lines Patch % Lines
...set/mcp_service/dashboard/tool/delete_dashboard.py 20.00% 32 Missing ⚠️
...et/mcp_service/dashboard/tool/restore_dashboard.py 21.05% 30 Missing ⚠️
superset/mcp_service/dashboard/schemas.py 75.67% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #40956      +/-   ##
==========================================
- Coverage   64.60%   64.54%   -0.07%     
==========================================
  Files        2712     2720       +8     
  Lines      151114   151572     +458     
  Branches    34751    34796      +45     
==========================================
+ Hits        97625    97826     +201     
- Misses      51663    51914     +251     
- Partials     1826     1832       +6     
Flag Coverage Δ
hive 39.07% <39.31%> (+0.01%) ⬆️
mysql 57.41% <39.31%> (-0.09%) ⬇️
postgres 57.46% <39.31%> (-0.09%) ⬇️
presto 40.57% <39.31%> (+0.01%) ⬆️
python 58.86% <39.31%> (-0.10%) ⬇️
sqlite 57.06% <39.31%> (-0.09%) ⬇️
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.

@aminghadersohi
aminghadersohi marked this pull request as ready for review June 29, 2026 17:25
@dosubot dosubot Bot added the dashboard Namespace | Anything related to the Dashboard label Jun 29, 2026

@bito-code-review bito-code-review Bot 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.

Code Review Agent Run #2b445d

Actionable Suggestions - 2
  • tests/unit_tests/mcp_service/dashboard/tool/test_delete_dashboard.py - 1
  • superset/mcp_service/dashboard/schemas.py - 1
Review Details
  • Files reviewed - 5 · Commit Range: 12dc548..12dc548
    • superset/mcp_service/app.py
    • superset/mcp_service/dashboard/schemas.py
    • superset/mcp_service/dashboard/tool/__init__.py
    • superset/mcp_service/dashboard/tool/delete_dashboard.py
    • tests/unit_tests/mcp_service/dashboard/tool/test_delete_dashboard.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 force-pushed the mcp-delete-dashboard branch from 12dc548 to acb7f3d Compare July 7, 2026 20:34
@pull-request-size pull-request-size Bot added size/XL and removed size/L labels Jul 7, 2026
@aminghadersohi aminghadersohi changed the title feat(mcp): add delete_dashboard tool feat(mcp): add delete_dashboard and undelete_dashboard tools Jul 7, 2026
@aminghadersohi
aminghadersohi force-pushed the mcp-delete-dashboard branch from acb7f3d to 5df704d Compare July 7, 2026 21:46

@bito-code-review bito-code-review Bot 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.

Code Review Agent Run #c968bf

Actionable Suggestions - 1
  • tests/unit_tests/mcp_service/dashboard/tool/test_delete_dashboard.py - 1
    • Extract shared test fixtures to conftest · Line 30-30
Additional Suggestions - 1
  • tests/unit_tests/mcp_service/dashboard/tool/test_undelete_dashboard.py - 1
    • Incomplete command call verification · Line 169-192
      `test_slug_conflict` asserts the error response but does not verify `RestoreDashboardCommand.run()` was invoked. `test_successful_restore` (line 99) already calls `mock_restore_cmd.run.assert_called_once()`. Consistency requires the same check here — a silent command skip would not be caught by the current assertions.
Filtered by Review Rules

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

  • superset/mcp_service/dashboard/tool/delete_dashboard.py - 2
Review Details
  • Files reviewed - 8 · Commit Range: 31a3b51..5df704d
    • superset/mcp_service/app.py
    • superset/mcp_service/dashboard/schemas.py
    • superset/mcp_service/dashboard/tool/__init__.py
    • superset/mcp_service/dashboard/tool/delete_dashboard.py
    • superset/mcp_service/dashboard/tool/undelete_dashboard.py
    • tests/unit_tests/mcp_service/dashboard/test_dashboard_schemas.py
    • tests/unit_tests/mcp_service/dashboard/tool/test_delete_dashboard.py
    • tests/unit_tests/mcp_service/dashboard/tool/test_undelete_dashboard.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

- Add test for the DashboardDeleteFailedError path (associated alerts/reports)
- Add sanitization tests for DeletedDashboardSummary, DeleteDashboardResponse,
  and UndeleteDashboardResponse schemas
- Annotate test fixture return types
@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #43d5ca

Actionable Suggestions - 0
Additional Suggestions - 1
  • tests/unit_tests/mcp_service/dashboard/tool/test_undelete_dashboard.py - 1
    • Missing test case for generic restore failure · Line 1-192
      The production handler at `undelete_dashboard.py:148-158` catches `DashboardRestoreFailedError` and returns a structured response, but no test exercises this path. If the handler contains a logic error, it will go undetected.
Filtered by Review Rules

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

  • tests/unit_tests/mcp_service/dashboard/tool/test_delete_dashboard.py - 2
Review Details
  • Files reviewed - 8 · Commit Range: cfc0515..50985f8
    • superset/mcp_service/app.py
    • superset/mcp_service/dashboard/schemas.py
    • superset/mcp_service/dashboard/tool/__init__.py
    • superset/mcp_service/dashboard/tool/delete_dashboard.py
    • superset/mcp_service/dashboard/tool/undelete_dashboard.py
    • tests/unit_tests/mcp_service/dashboard/test_dashboard_schemas.py
    • tests/unit_tests/mcp_service/dashboard/tool/test_delete_dashboard.py
    • tests/unit_tests/mcp_service/dashboard/tool/test_undelete_dashboard.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

@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #e5b5d5

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 50985f8..af2392d
    • tests/unit_tests/mcp_service/dashboard/tool/test_undelete_dashboard.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

Matches the platform vocabulary: the REST API exposes
POST /api/v1/dashboard/<uuid>/restore, the command layer is
RestoreDashboardCommand/BaseRestoreCommand, and SoftDeleteMixin's
recovery method is restore(). "undelete" appeared nowhere else in
the codebase.
@aminghadersohi aminghadersohi changed the title feat(mcp): add delete_dashboard and undelete_dashboard tools feat(mcp): add delete_dashboard and restore_dashboard tools Jul 10, 2026
@netlify

netlify Bot commented Jul 10, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 468ac19
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a505eb748b8850008fdb3f6
😎 Deploy Preview https://deploy-preview-40956--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.

RestoreDashboardResponse,
)

logger = logging.getLogger(__name__)

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.

Suggestion: Add an explicit type annotation to the module logger variable to satisfy the type-hint requirement for relevant variables. [custom_rule]

Severity Level: Minor ⚠️

Why it matters? 🤔

The module defines a long-lived logger variable without a type annotation even though its type is known and can be annotated. This matches the type-hint rule for relevant variables.

Rule source 📖

.cursor/rules/dev-standard.mdc (line 28)

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset/mcp_service/dashboard/tool/restore_dashboard.py
**Line:** 39:39
**Comment:**
	*Custom Rule: Add an explicit type annotation to the module logger variable to satisfy the type-hint requirement for relevant variables.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment on lines +75 to +79
dashboard = DashboardDAO.find_by_id(
request.dashboard_id,
skip_base_filter=True,
skip_visibility_filter=True,
)

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.

Suggestion: Annotate the dashboard lookup variable with its expected optional model type so this key local variable is explicitly typed. [custom_rule]

Severity Level: Minor ⚠️

Why it matters? 🤔

The lookup result is assigned to a local variable without an explicit annotation, and the code later treats it as an optional dashboard object. That is a real omission under the type-hint rule.

Rule source 📖

.cursor/rules/dev-standard.mdc (line 28)

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset/mcp_service/dashboard/tool/restore_dashboard.py
**Line:** 75:79
**Comment:**
	*Custom Rule: Annotate the dashboard lookup variable with its expected optional model type so this key local variable is explicitly typed.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎


with patch(
"superset.is_feature_enabled",
side_effect=lambda flag: flag == "SOFT_DELETE" and soft_delete_enabled,

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.

Suggestion: Replace the untyped lambda with a named helper function that includes explicit parameter and return type hints. [custom_rule]

Severity Level: Minor ⚠️

Why it matters? 🤔

The new lambda is an untyped Python function in modified code, and the project rule requires type hints on new or modified functions where possible. Replacing it with a named helper annotated with parameter and return types would satisfy the rule.

Rule source 📖

.cursor/rules/dev-standard.mdc (line 28)

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** tests/unit_tests/mcp_service/dashboard/tool/test_delete_dashboard.py
**Line:** 84:84
**Comment:**
	*Custom Rule: Replace the untyped lambda with a named helper function that includes explicit parameter and return type hints.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@aminghadersohi

Copy link
Copy Markdown
Contributor Author

duplicate / dont need

@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #b80064

Actionable Suggestions - 0
Review Details
  • Files reviewed - 5 · Commit Range: af2392d..468ac19
    • superset/mcp_service/app.py
    • superset/mcp_service/dashboard/schemas.py
    • superset/mcp_service/dashboard/tool/__init__.py
    • superset/mcp_service/dashboard/tool/delete_dashboard.py
    • tests/unit_tests/mcp_service/dashboard/test_dashboard_schemas.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

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 review:draft size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants