feat(mcp): support owners in update_dashboard tool#42002
Conversation
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.
Code Review Agent Run #3e475dActionable Suggestions - 0Additional Suggestions - 2
Filtered by Review RulesBito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Code Review Agent Run #ad1665Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
SUMMARY
The MCP
update_dashboardtool can edit a dashboard's title, description, slug,publishedflag, tags, CSS, layout andjson_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
ownersfield toupdate_dashboard: a full-replacement list of user IDs, mirroring the REST dashboard owners semantics.OwnersNotFounderror.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.pycover: owners replaced with the resolved users, an unknown ID returningOwnersNotFoundwith no mutation, an empty list clearing owners, and duplicate IDs being deduplicated.Manual: call
update_dashboardwith{"identifier": <id>, "owners": [<user_id>, ...]}and verify owners change; a non-existent ID returnsOwnersNotFound; 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.