feat(mcp): add get_dashboard_datasets tool#40961
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #40961 +/- ##
==========================================
- Coverage 64.50% 64.48% -0.02%
==========================================
Files 2666 2667 +1
Lines 146864 146973 +109
Branches 33910 33918 +8
==========================================
+ Hits 94728 94779 +51
- Misses 50421 50477 +56
- Partials 1715 1717 +2
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:
|
There was a problem hiding this comment.
Code Review Agent Run #a262d1
Actionable Suggestions - 1
-
superset/mcp_service/dashboard/schemas.py - 1
- Semantic duplication in request schemas · Line 377-385
Additional Suggestions - 1
-
superset/mcp_service/app.py - 1
-
Missing companion tool hint · Line 131-131The tool description mentions 'native filters' but doesn't indicate its companion relationship to `get_dashboard_info` for filter configuration, unlike `get_dashboard_layout` which explicitly states '(companion to get_dashboard_info...)'. For consistency, consider adding similar context to clarify the tool's role in the dashboard configuration workflow.
-
Review Details
-
Files reviewed - 5 · Commit Range:
21fa014..21fa014- superset/mcp_service/app.py
- superset/mcp_service/dashboard/schemas.py
- superset/mcp_service/dashboard/tool/__init__.py
- superset/mcp_service/dashboard/tool/get_dashboard_datasets.py
- tests/unit_tests/mcp_service/dashboard/tool/test_get_dashboard_datasets.py
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- 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
21fa014 to
226fba7
Compare
…+ avoid N+1 Address CodeAnt review on #40961: - Add @requires_data_model_metadata_access decorator and body gate so dashboard-only viewers without dataset metadata permission cannot read dataset columns/metrics/database via this tool (mirrors get_dataset_info). - Eager-load each slice's dataset columns, metrics, and database to avoid N+1 queries when serializing dashboards with many datasets.
Code Review Agent Run #8ef41fActionable Suggestions - 0Additional Suggestions - 1
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 |
…+ avoid N+1 Address CodeAnt review on #40961: - Add @requires_data_model_metadata_access decorator and body gate so dashboard-only viewers without dataset metadata permission cannot read dataset columns/metrics/database via this tool (mirrors get_dataset_info). - Eager-load each slice's dataset columns, metrics, and database to avoid N+1 queries when serializing dashboards with many datasets.
b5f2d71 to
6b43384
Compare
…+ avoid N+1 Address CodeAnt review on #40961: - Add @requires_data_model_metadata_access decorator and body gate so dashboard-only viewers without dataset metadata permission cannot read dataset columns/metrics/database via this tool (mirrors get_dataset_info). - Eager-load each slice's dataset columns, metrics, and database to avoid N+1 queries when serializing dashboards with many datasets.
6b43384 to
4f3d048
Compare
|
Already fixed in 4f3d048 — |
rusackas
left a comment
There was a problem hiding this comment.
chart_count groups on datasource_id only (mirrors datasets_trimmed_for_slices), theoretically over-countable across datasource types. Otherwise LGTM
Code Review Agent Run #fa57cdActionable 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 |
…+ avoid N+1 Address CodeAnt review on #40961: - Add @requires_data_model_metadata_access decorator and body gate so dashboard-only viewers without dataset metadata permission cannot read dataset columns/metrics/database via this tool (mirrors get_dataset_info). - Eager-load each slice's dataset columns, metrics, and database to avoid N+1 queries when serializing dashboards with many datasets.
4f3d048 to
dad30f8
Compare
…+ avoid N+1 Address CodeAnt review on #40961: - Add @requires_data_model_metadata_access decorator and body gate so dashboard-only viewers without dataset metadata permission cannot read dataset columns/metrics/database via this tool (mirrors get_dataset_info). - Eager-load each slice's dataset columns, metrics, and database to avoid N+1 queries when serializing dashboards with many datasets.
DashboardError.create() was producing naive timestamps via datetime.now(), inconsistent with the direct constructor path which uses datetime.now(timezone.utc).
…counter Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tInfo Add alias="schema" and ConfigDict(populate_by_name=True) to DashboardDatasetSummary.schema_name, mirroring the identical pattern in DatasetInfo (dataset/schemas.py:137,184). Without the alias, model_json_schema() advertises "schema_name" while the model_serializer outputs "schema", creating an API contract mismatch for strict JSON-schema clients and typed SDKs. With the alias, both the advertised schema and runtime payload agree on "schema". Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2bd6bf5 to
648ebbb
Compare
Group slices by the full datasource key (id, type) instead of id alone, preventing chart_count over-counting across datasource types that share the same numeric id. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Bito Automatic Review Skipped – PR Already Merged |
SUMMARY
Adds a new read-only MCP tool,
get_dashboard_datasets, that lists all datasets used by a dashboard's charts — the prerequisite context an AI agent needs before configuring native filters on a dashboard (e.g. picking filter target columns and datasets).Design notes:
get_dashboard_info, viaModelGetInfoCorewithsupports_slug=True).Dashboard.datasets_trimmed_for_slices) using the DAO layer, but returns the full (capped) column and metric lists, since native-filter configuration regularly needs columns that no chart references.security_manager.can_access_datasource) are excluded from the response and only counted viainaccessible_dataset_count.columns_truncated/metrics_truncatedflags and total counts, and all user-controlled strings are sanitized/escaped with the existing LLM-context helpers.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A (no UI changes — MCP service tool)
TESTING INSTRUCTIONS
pytest tests/unit_tests/mcp_service/dashboard/tool/test_get_dashboard_datasets.pyget_dashboard_datasetswith{"identifier": <dashboard id|uuid|slug>}; verify the datasets, columns, metrics, and database info match the dashboard's charts, and that datasets outside the user's access are excluded.ADDITIONAL INFORMATION