feat(mcp): add list and get tools for saved queries and query history#40301
feat(mcp): add list and get tools for saved queries and query history#40301aminghadersohi wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #40301 +/- ##
==========================================
- Coverage 64.15% 63.84% -0.32%
==========================================
Files 2592 2600 +8
Lines 138861 140228 +1367
Branches 32208 32494 +286
==========================================
+ Hits 89085 89523 +438
- Misses 48244 49140 +896
- Partials 1532 1565 +33
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
f7cb7ab to
4c646e9
Compare
Implements list_saved_queries, get_saved_query_info, list_queries, and get_query_info MCP tools in new saved_query/ and query/ domains. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4c646e9 to
2f738a3
Compare
|
Closing in favor of #40346 (branch renamed to follow amin/feature-description convention). |
There was a problem hiding this comment.
Code Review Agent Run #a1ef76
Actionable Suggestions - 1
-
superset/mcp_service/saved_query/tool/list_saved_queries.py - 1
- Missing ownership filter params · Line 117-125
Additional Suggestions - 2
-
superset/mcp_service/saved_query/tool/list_saved_queries.py - 2
-
Docstring may mislead users · Line 62-68The docstring states 'Returns saved queries owned by the current user' which implies default ownership filtering, but this is only true when ownership filters are explicitly applied. The docstring should clarify the default behavior.
Code suggestion
--- superset/mcp_service/saved_query/tool/list_saved_queries.py (lines 62-68) --- 62: """List saved SQL queries with filtering and search. 63: 64: Returns saved queries accessible to the current user, including label, SQL, 65: database ID, and schema. Use created_by_me or owned_by_me filters to 66: return only queries created by or owned by the current user. 67: 68: Sortable columns for order_column: id, label, db_id, schema, 69: changed_on, created_on 70: """ -
Unused parameter in serializer · Line 97-100The `_serialize_saved_query` function signature includes an unused `cols` parameter; consider either using it for field filtering or removing it and updating its caller accordingly.
-
Filtered by Review Rules
Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
-
tests/unit_tests/mcp_service/saved_query/tool/test_saved_query_tools.py - 2
- Missing return type hints · Line 37-272
- Wrong attribute for error response · Line 219-219
-
superset/mcp_service/query/tool/get_query_info.py - 1
- Error handling violates pattern · Line 108-122
Review Details
-
Files reviewed - 17 · Commit Range:
5de1fb7..2f738a3- superset/mcp_service/app.py
- superset/mcp_service/query/__init__.py
- superset/mcp_service/query/schemas.py
- superset/mcp_service/query/tool/__init__.py
- superset/mcp_service/query/tool/get_query_info.py
- superset/mcp_service/query/tool/list_queries.py
- superset/mcp_service/saved_query/__init__.py
- superset/mcp_service/saved_query/schemas.py
- superset/mcp_service/saved_query/tool/__init__.py
- superset/mcp_service/saved_query/tool/get_saved_query_info.py
- superset/mcp_service/saved_query/tool/list_saved_queries.py
- tests/unit_tests/mcp_service/query/__init__.py
- tests/unit_tests/mcp_service/query/tool/__init__.py
- tests/unit_tests/mcp_service/query/tool/test_query_tools.py
- tests/unit_tests/mcp_service/saved_query/__init__.py
- tests/unit_tests/mcp_service/saved_query/tool/__init__.py
- tests/unit_tests/mcp_service/saved_query/tool/test_saved_query_tools.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
| result = list_tool.run_tool( | ||
| filters=request.filters, | ||
| search=request.search, | ||
| select_columns=request.select_columns, | ||
| order_column=request.order_column, | ||
| order_direction=request.order_direction, | ||
| page=max(request.page - 1, 0), | ||
| page_size=request.page_size, | ||
| ) |
There was a problem hiding this comment.
Add created_by_me and owned_by_me parameters to the list_tool.run_tool() call and extend the ListSavedQueriesRequest schema to support these flags, enabling ownership-based filtering.
Code Review Run #a1ef76
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
SUMMARY
Adds four new MCP tools across two new domains (
saved_query/andquery/):list_saved_queries— List saved SQL queries owned by the current user with filtering (label, db_id, schema), search, and paginationget_saved_query_info— Get saved query details by numeric ID or UUIDlist_queries— List SQL query history with filtering (status, database_id, schema), defaulting to most-recent-first (ordered bystart_timedesc, page_size 25)get_query_info— Get query history details by numeric IDBoth domains follow the existing
database/,dataset/,chart/, anddashboard/patterns:ModelListCore/ModelGetInfoCorefor reuse, Pydantic schemas with field-level serialization context,@tooldecorators with RBAC, andevent_loggerinstrumentation.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend API tools only
TESTING INSTRUCTIONS
# Run unit tests for the new tools pytest tests/unit_tests/mcp_service/saved_query/ pytest tests/unit_tests/mcp_service/query/ADDITIONAL INFORMATION