Skip to main content
Glama

explain_query

Read-only

Generate the JSON execution plan for a SQL statement without executing it. Analyze query performance and optimize SQL before running.

Instructions

[READ] Return the JSON execution plan for sql (EXPLAIN FORMAT=JSON).

The statement is planned, not executed.

Args: sql: A single SQL statement to EXPLAIN. target: Target name from config; omit for the default.

Input Schema

NameRequiredDescriptionDefault
sqlYes
targetNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.5.0

TDQS

A3.8/5.0
Behavior4/5

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

Annotations only declare readOnlyHint=true, and the description usefully adds that the statement is planned rather than executed, clarifying there are no side effects. It stops short of describing plan output size or performance cost, but adds genuine context beyond the annotation.

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?

Front-loaded with the core purpose, followed by a concise clarification and compact parameter list. There is minor redundancy between the '[READ]' tag and the readOnlyHint annotation, but no wasted prose.

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?

With no output schema, the description states the return value (a JSON execution plan) and covers both parameters, so an agent has what it needs to call it correctly. Minor gaps remain around target resolution and output volume.

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 description coverage is 0%, so the description carries the full burden, and it does so: sql is defined as 'a single SQL statement to EXPLAIN' and target as a 'target name from config' that defaults when omitted. This compensates for the empty schema descriptions well, though it doesn't clarify target format or valid values.

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?

States a specific verb and resource: it returns the JSON execution plan for a given SQL statement using EXPLAIN FORMAT=JSON. The intent is unmistakable, though it doesn't distinguish itself from diagnostic siblings like slow_query_rca or top_queries.

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?

The line 'The statement is planned, not executed' implies a dry-run/analysis use case, which guides the agent to use it when it wants the plan without side effects. However, it never names when to prefer it over alternatives or states prerequisites, so guidance is only implied.

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