Skip to main content
Glama

Get Query Execution Plan

get_query_plan
Idempotent

Retrieve estimated or actual XML execution plans for SELECT queries to inspect optimizer behavior and runtime statistics for performance tuning.

Instructions

Get the estimated or actual XML execution plan for a SELECT query. Estimated plans show the optimizer's plan without executing. Actual plans execute the query and include runtime statistics. Uses the same query validation as read_data (SELECT only).

Input Schema

NameRequiredDescriptionDefault
queryYesSQL SELECT query to get the execution plan for. Only SELECT and WITH (CTE) queries are permitted.
planTypeNoPlan type: 'estimated' (default, does not execute) or 'actual' (executes the query)estimated
outputPathYesFile path for output (e.g. '/tmp/plan.sqlplan')
serverNameYesName of the SQL Server to query (use list_servers to see available names)
databaseNameYesName of the database to query (use list_databases to see available databases)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.3.1

TDQS

A4.2/5.0
Behavior4/5

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

With readOnlyHint=false and idempotentHint=true already declared, the bar is lower, and the description adds the important disclosure that 'actual' plans actually execute the query and return runtime stats — a genuine side-effect warning beyond the annotations. It doesn't cover permissions, plan size/cost, or that the result is written to a file, so it stops short of fully rich behavioral context.

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

Conciseness5/5

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

Three tight sentences: purpose first, then the estimated/actual tradeoff, then the query restriction. Nothing is redundant and the most decision-relevant fact (whether the query executes) is front-loaded.

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

Completeness4/5

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

There is no output schema, so the description carries some return-value burden, and it does say the plan is an XML plan — but it never mentions that the plan is written to the required outputPath file. That omission is a modest gap rather than a serious one, since the parameter is required and self-describing.

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 coverage is 100%, so every parameter is already documented, including planType's estimated/actual semantics and the SELECT/WITH restriction on query. The description reinforces planType behavior but adds no syntax or format detail beyond the schema, making the baseline 3 appropriate.

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?

The description states a specific verb and resource ('Get the estimated or actual XML execution plan') and immediately distinguishes the two modes the tool supports. It also anchors itself in the family by noting it shares query validation with read_data, so an agent can place it relative to siblings.

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

Usage Guidelines4/5

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

It clearly explains the choice between modes: estimated plans don't execute, actual plans execute and add runtime statistics, and only SELECT/WITH queries are permitted. It doesn't explicitly say when to prefer this over read_data or describe_table, but the mode-selection guidance is strong practical context.

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