Skip to content

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

Draft
aminghadersohi wants to merge 1 commit into
masterfrom
mcp-queries-99978
Draft

feat(mcp): add list and get tools for saved queries and query history#40301
aminghadersohi wants to merge 1 commit into
masterfrom
mcp-queries-99978

Conversation

@aminghadersohi
Copy link
Copy Markdown
Contributor

SUMMARY

Adds four new MCP tools across two new domains (saved_query/ and query/):

  • list_saved_queries — List saved SQL queries owned by the current user with filtering (label, db_id, schema), search, and pagination
  • get_saved_query_info — Get saved query details by numeric ID or UUID
  • list_queries — List SQL query history with filtering (status, database_id, schema), defaulting to most-recent-first (ordered by start_time desc, page_size 25)
  • get_query_info — Get query history details by numeric ID

Both domains follow the existing database/, dataset/, chart/, and dashboard/ patterns: ModelListCore/ModelGetInfoCore for reuse, Pydantic schemas with field-level serialization context, @tool decorators with RBAC, and event_logger instrumentation.

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

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 67.11409% with 98 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.19%. Comparing base (a273fe4) to head (d501ad2).

Files with missing lines Patch % Lines
superset/mcp_service/query/tool/list_queries.py 33.33% 20 Missing ⚠️
...mcp_service/saved_query/tool/list_saved_queries.py 33.33% 20 Missing ⚠️
superset/mcp_service/query/schemas.py 83.15% 15 Missing and 1 partial ⚠️
superset/mcp_service/saved_query/schemas.py 82.02% 15 Missing and 1 partial ⚠️
superset/mcp_service/query/tool/get_query_info.py 43.47% 13 Missing ⚠️
...p_service/saved_query/tool/get_saved_query_info.py 43.47% 13 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master   #40301    +/-   ##
========================================
  Coverage   64.19%   64.19%            
========================================
  Files        2591     2599     +8     
  Lines      138459   138757   +298     
  Branches    32118    32130    +12     
========================================
+ Hits        88880    89080   +200     
- Misses      48047    48143    +96     
- Partials     1532     1534     +2     
Flag Coverage Δ
hive 39.54% <67.11%> (+0.13%) ⬆️
mysql 59.10% <67.11%> (+0.03%) ⬆️
postgres 59.18% <67.11%> (+0.03%) ⬆️
presto 41.21% <67.11%> (+0.12%) ⬆️
python 60.60% <67.11%> (+0.03%) ⬆️
sqlite 58.82% <67.11%> (+0.03%) ⬆️
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant