Skip to main content
Glama

explain_query

Read-onlyIdempotent

Show a SQL query's execution plan with cost estimates to diagnose performance, optionally running SELECTs for real statistics or simulating hypothetical indexes.

Instructions

Show the execution plan of a SQL query with cost estimates. A query with $1-style placeholders (as in query statistics) is explained with a generic plan. Hypothetical indexes need the hypopg extension.

Input Schema

NameRequiredDescriptionDefault
sqlYesSQL query to explain
analyzeNoRun the query to show real execution statistics; only for a SELECT that passes the read check, inside the time limit
hypothetical_indexesNoHypothetical indexes to simulate with hypopg; they are removed before the call ends

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.6/5.0
Behavior3/5

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

The annotations already declare readOnlyHint=true, idempotentHint=true and destructiveHint=false, so the description has a lower burden. It adds real context, namely the generic-plan behavior for placeholders and the hypopg dependency, but it never states that analyze=true actually runs the query, which is the most consequential behavioral trait here and is only in the schema.

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 short sentences, front-loaded with the core action, then the two conditional gotchas. No filler or repetition.

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

Completeness3/5

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

With three parameters, full schema coverage and no output schema, the description should say what the plan looks like when returned, for example a text plan versus structured rows, and confirm that analyze has side effects at execution. Those gaps matter because no output schema backs them up.

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. The description still adds meaning the schema does not: it explains how $1-style placeholders are handled for the sql param, and it names the hypopg extension requirement for hypothetical_indexes. Only the analyze parameter goes unaddressed.

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

Purpose4/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: 'Show the execution plan of a SQL query with cost estimates.' That distinguishes it from execute_sql by implication, but it never names the siblings it competes with, such as analyze_query_indexes or diagnose, which also touch query performance.

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

Usage Guidelines3/5

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

Usage is only implied. The notes on $1 placeholders and on hypothetical indexes needing hypopg are useful conditional hints, but the description never says when to pick this over execute_sql or when to prefer the index-analysis siblings. There are no explicit exclusions.

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