feat(mcp): add list and get tools for saved queries and query history#11
Open
hbrooks wants to merge 9 commits into
Open
feat(mcp): add list and get tools for saved queries and query history#11hbrooks wants to merge 9 commits into
hbrooks wants to merge 9 commits into
Conversation
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>
…ies tools - Drop sql from DEFAULT_QUERY_COLUMNS (25 rows × full SQL bodies is too heavy for default LLM responses; callers use select_columns or get_query_info to access SQL) - Add changed_on to SORTABLE_QUERY_COLUMNS for queries (column is indexed on the model, same treatment as saved queries) - Remove QueryError.create() and SavedQueryError.create() dead code - Fix list_queries instruction text in app.py: use '(1-based pagination)' to match the wording used by all other list tools - Add tests: select_columns field projection and invalid order_column rejection
…ies tools - Narrow exception type in order_column test from Exception to ValueError - Add count assertion to saved query pagination test
…ror response The full error details are already logged via ctx.error() to the server log; return a generic message to the client to avoid exposing internal DB errors.
start_time is a nullable epoch float that is not set for queries inserted outside of normal SQL Lab execution. Sorting by changed_on (always populated) gives stable, deterministic ordering regardless of how the query record was created.
…ies tools - Fix test_list_queries_default_order_is_start_time_desc → changed_on after default sort column change - Sanitize get_query_info error response: return generic message instead of str(e) to match get_saved_query_info (prevents leaking internal error text) - Add test_get_query_info_internal_error and test_get_saved_query_info_internal_error covering the InternalError exception path in both get-tools - Add test_list_saved_queries_select_columns_projects_fields and test_list_saved_queries_invalid_order_column_raises to match query tool coverage
fastmcp client wraps tool ValueError as ToolError at the protocol level, so pytest.raises(ValueError) never matched. Use ToolError instead.
- QueryInfo: add executed_sql, catalog, user_id fields - QueryFilter.col: add user_id and start_time as filterable columns - SavedQueryInfo: add catalog and last_run fields - SavedQueryFilter.col: add catalog and created_by_fk as filterable columns - ALL_QUERY_COLUMNS / ALL_SAVED_QUERY_COLUMNS: include new fields - Tests: update filter schema tests to reflect new valid columns, update mock factories with new fields
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.
Mirror of apache/superset#40346 by @aminghadersohi