feat(mcp): add manage_native_filters tool#40960
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #40960 +/- ##
==========================================
+ Coverage 64.19% 64.33% +0.14%
==========================================
Files 2655 2658 +3
Lines 143925 145679 +1754
Branches 33181 33504 +323
==========================================
+ Hits 92386 93719 +1333
- Misses 49919 50283 +364
- 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 #13a2f1Actionable Suggestions - 0Additional Suggestions - 2
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,
manage_native_filters, to the Superset MCP service. Native filters are what make dashboards interactive; the MCP server could previously read them (viaget_dashboard_info) but not write them.The tool exposes four operations on a dashboard's native filters, translated into the
deleted/modified/reorderedpayload consumed by the existingUpdateDashboardNativeFiltersCommand(the same command behind thePUT /api/v1/dashboard/{pk}/filtersendpoint):filter_select(dropdown: dataset + column target,multiSelect,defaultToFirstItem,enableEmptyFilter,sortAscending,searchAllOptions) andfilter_time(time range with optional default). Other filter types (numerical range, time column, time grain) are documented as not yet supported.native_filter_configurationand merges changes into FULL filter configs. Type-incompatible fields (e.g.default_time_rangeon afilter_select) are rejected.Design notes:
NATIVE_FILTER-<random>, matching the frontend'sgenerateFilterIdconvention, and returned in the response (added_filter_ids).Filtertype shape:{id, type: "NATIVE_FILTER", filterType, name, description, scope, targets, controlValues, defaultDataMask, cascadeParentIds}.scope_chart_idsper filter is translated into the frontend's exclusion-list scope ({rootPath: ["ROOT_ID"], excluded: [...]}); IDs not on the dashboard are rejected. When omitted, the filter applies to all charts.DatasetDAOwith an error that lists available columns so LLM callers can self-correct.tags=["mutate"],class_permission_name="Dashboard",method_permission_name="write", andToolAnnotations(readOnlyHint=False, destructiveHint=True)sinceremovedeletes filters.DashboardForbiddenError/TagForbiddenErrorsurface as structuredpermission_deniedresponses.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — MCP service only, no UI changes.
TESTING INSTRUCTIONS
pytest tests/unit_tests/mcp_service/dashboard/tool/test_manage_native_filters.pymanage_native_filterswith e.g.{"dashboard_id": 1, "add": [{"filter_type": "filter_select", "name": "Region", "dataset_id": 5, "column": "region"}]}and verify the filter appears on the dashboard's filter bar; exerciseupdate,remove, andreordersimilarly.ADDITIONAL INFORMATION