feat(mcp): add remove_chart_from_dashboard tool#40958
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #40958 +/- ##
==========================================
+ Coverage 64.19% 64.29% +0.10%
==========================================
Files 2655 2658 +3
Lines 143925 145858 +1933
Branches 33181 33536 +355
==========================================
+ Hits 92386 93783 +1397
- Misses 49919 50398 +479
- Partials 1620 1677 +57
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:
|
Code Review Agent Run #19fe4aActionable Suggestions - 0Filtered 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 |
SUMMARY
Adds a new MCP tool,
remove_chart_from_dashboard, the missing inverse ofadd_chart_to_existing_dashboard. Without it, agents that add a wrong chart to a dashboard have no recovery path.The tool:
position_json(a chart can appear under multiple tabs), and prunes ROW/COLUMN containers left empty by the removal so no orphaned wrapper nodes remain. TAB/TABS/GRID/ROOT containers are intentionally never pruned.slicesrelationship (ORM objects with the removed chart excluded) toUpdateDashboardCommand, since updatingposition_jsonalone does not syncdashboard.slices.json_metadata:expanded_slices,timed_refresh_immune_slices, andfilter_scopes(both filter-chart keys and per-columnimmunelists). When metadata changed, the new layout is included under"positions"soDashboardDAO.set_dash_metadatatakes its legacy branch that preserves and re-scopesfilter_scopesinstead of dropping them.permission_denied=Trueso the LLM informs the user instead of attempting a workaround), and chart not present in the dashboard.ToolAnnotations(readOnlyHint=False, destructiveHint=True)andtags=["mutate"]/Dashboard-writeRBAC, mirroringadd_chart_to_existing_dashboard(same authorization, command write, and post-write eager re-fetch patterns).The chart itself is not deleted — it remains available to other dashboards.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A (MCP service tool, no UI changes)
TESTING INSTRUCTIONS
pytest tests/unit_tests/mcp_service/dashboard/tool/test_remove_chart_from_dashboard.pyadd_chart_to_existing_dashboardwith adashboard_id/chart_id, thenremove_chart_from_dashboardwith the same arguments.json_metadatano longer references the chart.Tests cover: dashboard not found, permission denied, chart not in dashboard, simple grid removal with empty-row pruning, chart inside a COLUMN (sibling kept; lone chart prunes COLUMN+ROW), chart under multiple tabs (all occurrences removed, tabs kept),
json_metadatacleanup, chart attached to slices but absent from layout, and malformed-metadata robustness.ADDITIONAL INFORMATION