Skip to content

feat(mcp): add list and get tools for saved queries and query history#11

Open
hbrooks wants to merge 9 commits into
masterfrom
demo/pr-40346
Open

feat(mcp): add list and get tools for saved queries and query history#11
hbrooks wants to merge 9 commits into
masterfrom
demo/pr-40346

Conversation

@hbrooks

@hbrooks hbrooks commented May 28, 2026

Copy link
Copy Markdown

aminghadersohi and others added 9 commits May 27, 2026 01:53
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants