Skip to main content
Glama
Elekto MCP for SQL Server

Elekto MCP for SQL Server

Official

Query Store regressions and plan changes

list_query_store_regressions
Read-onlyIdempotent

Identifies queries that became slower or heavier by comparing recent Query Store metrics with prior days, showing plan changes and regressions. Use it first when a query or process slows down.

Instructions

Finds the queries that got slower or heavier, vary the most or changed plan, from the Query Store: it compares each query's recent window with the days before it, as SSMS's Regressed Queries and Queries With High Variation reports do, and returns per query the executions and the average and maximum of the metric in each window, their ratio, the plans used in each window, whether the dominant plan changed, the plans compiled in the recent window and the aborted or failed executions in it. The variants of a parameter-sensitive query (SQL Server 2022+) count under it. Use it first when a query or a process got slow; for one query's full history use get_query_store_history, and to find a query by its text or procedure use find_query_store_queries. Needs VIEW DATABASE STATE (2022+: VIEW DATABASE PERFORMANCE STATE), which VIEW SERVER STATE implies.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "database": "<database>"
    },
    "name": "list_query_store_regressions"
  }
}

Input Schema

NameRequiredDescriptionDefault
topNoMost queries to return (default 20, at most 100).
metricNoWhat to compare: 'duration' (default), 'cpu', 'logical_reads' or 'physical_reads'. Duration and CPU come in milliseconds, reads in 8 KB pages.duration
databaseYesName of the database as registered in the configuration.
order_byNo'regression' (default): the queries whose average for the metric rose against the history window, worst first by how much more of it their recent executions used in total (time for duration and CPU, pages for reads); 'variation': the least stable over both windows; 'plan_count': the queries that used more than one plan.regression
history_daysNoDays before the recent window to compare it with (default 7).
recent_hoursNoHours in the recent window, which ends now (default 24). A Query Store interval that straddles its start counts as recent.
min_executionsNoFewest executions a query needs in the recent window, and for 'regression' in the history window too, to be listed (default 2).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv2.6.1

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnly, idempotent, and non-destructive, so the safety profile is covered; the description adds real value beyond that by naming the required permission (VIEW DATABASE STATE, or VIEW DATABASE PERFORMANCE STATE on 2022+, implied by VIEW SERVER STATE) and by enumerating what each row contains, including plan change detection and aborted/failed executions. It does not discuss cost, runtime, or result size limits, which keeps it just short of a 5.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose, returned fields, the use-first rule, the alternatives, and the permission requirement are all front-loaded before any elaboration, so an agent can stop reading early. The cost is a very long run-on sentence with stacked clauses, which slows parsing slightly but wastes no content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description carries the burden of explaining return values, and it does so item by item (executions, average and maximum per window, their ratio, plans per window, dominant-plan change, newly compiled plans, aborted executions). Combined with the permission note and the window-comparison semantics, an agent has everything needed to call this correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so each of the seven parameters is already documented with defaults and allowed values, and the baseline of 3 applies. The description clarifies that the returned ratio compares the per-window metric and that parameter-sensitive plan variants (SQL Server 2022+) roll up under their parent query, but it adds little new meaning to individual parameters beyond what the schema states.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb-and-resource pair up front: it finds queries that regressed, varied, or changed plan in the Query Store, and spells out the comparison being made (recent window vs. the preceding days). It also names the sibling tools it is not (get_query_store_history, find_query_store_queries), so an agent can choose without opening any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives an explicit first-choice rule ("Use it first when a query or a process got slow") plus two named alternatives with the condition that selects each: get_query_store_history for one query's full history, find_query_store_queries for lookup by text or procedure. Nothing is left to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.