Skip to main content
Glama
Elekto MCP for SQL Server

Elekto MCP for SQL Server

Official

Execution plan summary

get_query_plan_summary
Read-onlyIdempotent

Summarizes a Query Store or cached SQL Server execution plan, replacing bulky XML with per-statement cost, rows, warnings, missing indexes, and operator tree details.

Instructions

Summarizes one execution plan instead of returning its XML, which can run to hundreds of thousands of characters: a Query Store plan by plan_id, or a plan in the plan cache by plan_handle, whole or the one statement its offsets pick out. Per statement (an IF or WHILE condition and each cursor operation count as one): estimated rows and cost, cardinality estimator version, whether the plan is parallel and why not when it is serial, memory grant, the parameter values the plan was compiled for, the statistics the optimizer used with their last update and modifications, the warnings, each with the operator it is on (implicit conversions, missing statistics or join predicates), missing-index suggestions, and the operators as a compact tree with object, index, seek, scan or lookup, predicates and join keys, estimated rows and share of the cost. Query Store and cached plans are estimated plans, so nothing measured at run time, such as spills, is in them. Use it with a plan_id from get_query_store_history or list_query_store_regressions, or a plan_handle from find_cached_queries or get_active_requests, and compare two plans of a query by summarizing each; for the statistics themselves use get_table_statistics. A plan_handle needs VIEW SERVER STATE (2022+: VIEW SERVER PERFORMANCE STATE).

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": "get_query_plan_summary"
  }
}

Input Schema

NameRequiredDescriptionDefault
plan_idNoQuery Store plan id, from get_query_store_history or list_query_store_regressions. 0 (default) when plan_handle is given instead.
databaseYesName of the database as registered in the configuration.
statementNoNumber of one statement to return alone, its statement_number. 0 (default) returns every statement, or the 20 costliest, with statement_index listing them all, when there are more.
plan_handleNoA plan in the plan cache, as find_cached_queries or get_active_requests write its plan_handle: 0x and hexadecimal digits. Empty when plan_id is given instead. A plan the cache has dropped since is reported as gone; those tools give the handle of the plan in use now.
max_operatorsNoHow many of the costliest operators to keep per statement (default 40, at most 200). Every operator above them comes too, so that the tree reads from the root, and operators_shown can exceed this.
statement_end_offsetNoWith plan_handle, where the statement ends, as those tools return it with statement_start_offset. -1 (the default) goes only with statement_start_offset 0: both mean every statement of the plan.
statement_start_offsetNoWith plan_handle, where the statement starts in its batch, as find_cached_queries or get_active_requests return it, to summarize that statement alone, with its statement_end_offset. Leave it at 0, and statement_end_offset at -1, for every statement of the plan.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv2.6.1

TDQS

A4.7/5.0
Behavior5/5

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

Beyond the read-only/idempotent annotations, it discloses that Query Store and cached plans are estimated plans so runtime measures like spills are absent, that a dropped cached plan is reported as gone, and that a plan_handle requires VIEW SERVER STATE (2022+: VIEW SERVER PERFORMANCE STATE). These are exactly the non-obvious constraints an agent needs before calling.

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

Conciseness3/5

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

The opening clause is well front-loaded (summarize vs. huge XML), but the return-value enumeration is delivered as one enormous run-on sentence that is hard to parse. Since there is no output schema, the content is largely justified, but its packing into a single sentence hurts scanability.

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 and seven parameters, the description carries the full burden and does: it enumerates what comes back per statement (rows/cost, CE version, parallelism and reasons, memory grant, parameters, statistics, warnings with operators, missing indexes, operator tree), names the input sources, and states the permission prerequisite.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3, but the description adds real semantics on top: the plan_id/plan_handle mutual exclusivity, how max_operators interacts with tree completeness ('every operator above them comes too, so operators_shown can exceed this'), and the joint meaning of the two statement offsets as all-statements vs. one statement.

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 ('summarizes one execution plan') and immediately contrasts it with the alternative behavior ('instead of returning its XML, which can run to hundreds of thousands of characters'), so the agent can distinguish it from get_estimated_plan without opening a 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?

Explicitly routes the agent by input source: plan_id from get_query_store_history or list_query_store_regressions, plan_handle from find_cached_queries or get_active_requests, and explicitly sends the agent elsewhere for statistics ('for the statistics themselves use get_table_statistics'). It also describes a workflow (compare two plans by summarizing each).

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