mcp-sql-querystore
v0.1.1Read-only SQL Server diagnostics for LLM agents: Query Store, waits, plans, indexes
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
get_regressed_queries
Detect queries whose performance regressed by comparing a recent period against an earlier baseline period from Query Store.
| Parameter | Type | Description |
|---|---|---|
database_name * | string | Target SQL Server database name. |
baseline_hours | integer | Length of the baseline window preceding the recent window, in hours (default 7 days). |
metric | string | Metric to evaluate regression against. |
min_executions | integer | Ignore queries with fewer executions than this in either period (filters noise). |
recent_hours | integer | Length of the recent window, in hours. |
regression_threshold | number | Minimum fractional worsening to flag (0.5 = 50% worse than baseline). |
top_n | integer | Max rows to return. |
get_query_execution_plan
Fetch execution plan(s) for a Query Store query_id and return a compact summary (missing indexes, warnings, lookups) plus optional raw XML.
| Parameter | Type | Description |
|---|---|---|
database_name * | string | Target SQL Server database name. |
query_id * | integer | Query Store Query ID. |
include_xml | boolean | Include raw showplan XML alongside summary. |
analyze_parameter_sniffing
Detect queries whose runtime varies widely across multiple compiled plans — the classic parameter-sniffing signature. Ranks by the ratio of slowest to fastest plan mean duration.
| Parameter | Type | Description |
|---|---|---|
database_name * | string | Target SQL Server database name. |
min_plan_count | integer | Minimum distinct plans for a query to be considered (2 = at least two plans). |
top_n | integer | Max rows to return. |
get_missing_index_impact
Aggregate missing-index recommendations found in Query Store plans, ranked by the optimizer's estimated impact score. Groups duplicate recommendations across queries.
| Parameter | Type | Description |
|---|---|---|
database_name * | string | Target SQL Server database name. |
plan_scan_limit | integer | How many recent plans (that contain missing indexes) to scan and aggregate. Higher = more thorough, slower. |
top_n | integer | Max index recommendations to return. |
get_wait_stats
Aggregate query wait time by wait category over a time window — shows WHY queries are slow (CPU, blocking/locks, IO, memory, etc.) rather than which are slow. Ranked by total wait time.
| Parameter | Type | Description |
|---|---|---|
database_name * | string | Target SQL Server database name. |
recent_hours | integer | Lookback window in hours. |
top_n | integer | Max wait categories to return. |
sweep_regressions
Run regression detection across ALL online databases that have Query Store enabled, and return the worst regressions found per database. Use this to triage a whole instance instead of one database at a time.
| Parameter | Type | Description |
|---|---|---|
baseline_hours | integer | Length of the baseline window, in hours. |
database_names | array | Optional explicit list of databases to sweep. If omitted, sweeps all Query Store-enabled online databases. |
metric | string | Metric to evaluate regression against. |
min_executions | integer | Ignore queries below this execution count. |
recent_hours | integer | Length of the recent window, in hours. |
regression_threshold | number | Minimum fractional worsening to flag. |
top_n_per_db | integer | Max regressed queries to return per database. |