feat(mcp): add create_saved_query MCP tool#40361
Draft
aminghadersohi wants to merge 1 commit into
Draft
Conversation
Adds a `create_saved_query` mutation tool to the MCP service so AI assistants can persist SQL queries to the Saved Queries list. - `superset/commands/query/create.py`: new `CreateSavedQueryCommand` that validates database access then creates the record via DAO - `superset/commands/query/exceptions.py`: adds `SavedQueryCreateFailedError` - `superset/mcp_service/saved_query/`: new module with Pydantic schemas and the `@tool`-decorated `create_saved_query` function - `superset/mcp_service/app.py`: registers the tool and updates the LLM instructions Shortcut: #107311
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #40361 +/- ##
==========================================
- Coverage 64.20% 64.17% -0.03%
==========================================
Files 2592 2596 +4
Lines 139004 139111 +107
Branches 32273 32281 +8
==========================================
+ Hits 89241 89279 +38
- Misses 48231 48300 +69
Partials 1532 1532
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:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
Adds a
create_saved_querymutation tool to the MCP service so AI assistants can persist SQL queries to the Saved Queries list.New files:
superset/commands/query/create.py—CreateSavedQueryCommandvalidates database access (existence + security) and creates the record viaSavedQueryDAOsuperset/commands/query/exceptions.py— addsSavedQueryCreateFailedErrorsuperset/mcp_service/saved_query/— new module with Pydantic request/response schemas and the@tool-decoratedcreate_saved_queryfunctionsuperset/mcp_service/app.py— registers the tool and updates LLM instructionsTool signature:
Follows the same mutation pattern as
create_virtual_dataset.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend MCP tool only.
TESTING INSTRUCTIONS
create_saved_querywith a validdb_id,label, andsql/savedqueryview/list/and can be opened in SQL Lab via the returned URLdb_idand verify a structured error is returned (no exception thrown to the client)ADDITIONAL INFORMATION