Skip to content

feat(mcp): support owners in update_dashboard tool#42002

Open
guilleov wants to merge 5 commits into
apache:masterfrom
guilleov:feat/mcp-update-dashboard-owners
Open

feat(mcp): support owners in update_dashboard tool#42002
guilleov wants to merge 5 commits into
apache:masterfrom
guilleov:feat/mcp-update-dashboard-owners

Conversation

@guilleov

@guilleov guilleov commented Jul 13, 2026

Copy link
Copy Markdown

SUMMARY

The MCP update_dashboard tool can edit a dashboard's title, description, slug, published flag, tags, CSS, layout and json_metadata, but it had no way to set the dashboard's owners, and no other MCP tool sets owners either.

Because of this, a dashboard created through the MCP (generate_dashboard) is owned only by the MCP agent's user. An unpublished dashboard is visible only to its owners, so the human driving the agent cannot see or manage their own new dashboard, and no MCP client can transfer ownership to them. The only workarounds today are the Superset UI or direct metadata-DB access.

This PR adds an optional owners field to update_dashboard: a full-replacement list of user IDs, mirroring the REST dashboard owners semantics.

  • Unknown user IDs are rejected up front with an OwnersNotFound error.
  • An empty list clears all owners.
  • Omitting the field leaves owners unchanged.

Editorship is still enforced via raise_for_editorship, so only current owners or an Admin can change owners (same guarantee as the REST PUT path).

Related discussion: #42001

TESTING INSTRUCTIONS

Unit tests added in tests/unit_tests/mcp_service/dashboard/tool/test_update_dashboard.py cover: owners replaced with the resolved users, an unknown ID returning OwnersNotFound with no mutation, an empty list clearing owners, and duplicate IDs being deduplicated.

Manual: call update_dashboard with {"identifier": <id>, "owners": [<user_id>, ...]} and verify owners change; a non-existent ID returns OwnersNotFound; an empty list clears owners; omitting the field leaves owners unchanged.

ADDITIONAL INFORMATION

Adds a new optional field to an existing MCP tool. No database migration, no UI change, and no new dependencies.

The update_dashboard MCP tool could edit title, description, slug,
published, tags, css, layout and json_metadata, but there was no way to
change a dashboard's owners from MCP. A dashboard created by an MCP agent
is therefore owned only by that agent, and no MCP client can hand it to a
human owner.

Add an optional owners field (full-replacement list of user IDs, mirroring
the REST dashboard owners semantics): unknown IDs are rejected up front
with an OwnersNotFound error, an empty list clears owners, and omitting it
leaves owners unchanged. Editorship is still enforced via
raise_for_editorship, so only current owners or an Admin can change owners.
@dosubot dosubot Bot added the api:dashboard Related to the REST endpoints of the Dashboard label Jul 13, 2026
@bito-code-review

bito-code-review Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #3e475d

Actionable Suggestions - 0
Additional Suggestions - 2
  • superset/mcp_service/dashboard/tool/update_dashboard.py - 1
    • Missing tests for dedup and empty-clear · Line 156-177
      The deduplication behavior implemented in `_resolve_owners` (lines 167-171) and the empty-list clearing path (line 230: `if request.owners is not None`) are both untested despite being shipped in the diff.
  • superset/mcp_service/dashboard/schemas.py - 1
    • Missing test for owners clear edge case · Line 883-891
      The `owners` field documents that "An empty list clears all owners" but this behavior is not covered by any existing test. According to BITO.md rule [11730], new tools must cover edge cases. Add a test that passes `owners: []` to verify the clear-all-owners behavior is implemented correctly.
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_update_dashboard.py - 2
Review Details
  • Files reviewed - 3 · Commit Range: 438497f..438497f
    • superset/mcp_service/dashboard/schemas.py
    • superset/mcp_service/dashboard/tool/update_dashboard.py
    • tests/unit_tests/mcp_service/dashboard/tool/test_update_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 evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Comment thread superset/mcp_service/dashboard/tool/update_dashboard.py Outdated
Comment thread superset/mcp_service/dashboard/tool/update_dashboard.py Outdated
Comment thread superset/mcp_service/dashboard/tool/update_dashboard.py Outdated
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 11.76471% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.04%. Comparing base (e165762) to head (f06caa9).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...set/mcp_service/dashboard/tool/update_dashboard.py 9.09% 30 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42002      +/-   ##
==========================================
- Coverage   65.05%   65.04%   -0.01%     
==========================================
  Files        2747     2747              
  Lines      153767   153799      +32     
  Branches    35250    35257       +7     
==========================================
+ Hits       100028   100041      +13     
- Misses      51829    51848      +19     
  Partials     1910     1910              
Flag Coverage Δ
hive 39.04% <11.76%> (-0.02%) ⬇️
mysql 57.86% <11.76%> (-0.03%) ⬇️
postgres 57.92% <11.76%> (-0.03%) ⬇️
presto 41.02% <11.76%> (-0.02%) ⬇️
python 59.30% <11.76%> (-0.03%) ⬇️
sqlite 57.53% <11.76%> (-0.03%) ⬇️
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.

Address review feedback on the update_dashboard owners change:
- Wrap owner resolution in _validate_update_request with SQLAlchemyError
  handling so a transient DB failure returns a structured DatabaseError
  instead of escaping as an unhandled tool error (it runs before the main
  SQLAlchemy wrapper).
- Add tests for the empty-list clear-all-owners path and for ID
  deduplication (first-seen order preserved).
- Add explicit type annotations on the owner-resolution unpackings and
  docstrings on the new tests.
@netlify

netlify Bot commented Jul 14, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

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

Comment thread superset/mcp_service/dashboard/tool/update_dashboard.py Outdated
guilleov added 3 commits July 14, 2026 10:48
Owners were resolved twice (once to validate, once to write), and the
write phase ignored newly-missing IDs, so a user removed between the two
lookups would be silently dropped. Resolve and validate owners exactly
once via _resolve_and_validate_owners and pass the resolved list to
_apply_field_updates for the write.
@bito-code-review

bito-code-review Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #ad1665

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 438497f..f06caa9
    • superset/mcp_service/dashboard/tool/update_dashboard.py
    • tests/unit_tests/mcp_service/dashboard/tool/test_update_dashboard.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ 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 evan@preset.io.

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

api:dashboard Related to the REST endpoints of the Dashboard size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant