mcp-sql-querystore

v0.1.1
io.github.deepeshd87/mcp-sql-querystore Checked 10 hours ago Published 1 month ago

Read-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.

ParameterTypeDescription
database_name *stringTarget SQL Server database name.
baseline_hoursintegerLength of the baseline window preceding the recent window, in hours (default 7 days).
metricstringMetric to evaluate regression against.
min_executionsintegerIgnore queries with fewer executions than this in either period (filters noise).
recent_hoursintegerLength of the recent window, in hours.
regression_thresholdnumberMinimum fractional worsening to flag (0.5 = 50% worse than baseline).
top_nintegerMax 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.

ParameterTypeDescription
database_name *stringTarget SQL Server database name.
query_id *integerQuery Store Query ID.
include_xmlbooleanInclude 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.

ParameterTypeDescription
database_name *stringTarget SQL Server database name.
min_plan_countintegerMinimum distinct plans for a query to be considered (2 = at least two plans).
top_nintegerMax 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.

ParameterTypeDescription
database_name *stringTarget SQL Server database name.
plan_scan_limitintegerHow many recent plans (that contain missing indexes) to scan and aggregate. Higher = more thorough, slower.
top_nintegerMax 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.

ParameterTypeDescription
database_name *stringTarget SQL Server database name.
recent_hoursintegerLookback window in hours.
top_nintegerMax 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.

ParameterTypeDescription
baseline_hoursintegerLength of the baseline window, in hours.
database_namesarrayOptional explicit list of databases to sweep. If omitted, sweeps all Query Store-enabled online databases.
metricstringMetric to evaluate regression against.
min_executionsintegerIgnore queries below this execution count.
recent_hoursintegerLength of the recent window, in hours.
regression_thresholdnumberMinimum fractional worsening to flag.
top_n_per_dbintegerMax regressed queries to return per database.