Skip to main content
Glama

explain_query

Read-only

Returns the execution plan for a SELECT, TABLE, or VALUES statement without running it, highlighting full scans, filesort, temporary tables, and estimated rows so you can spot slow queries first.

Instructions

Returns the execution plan for one SELECT, TABLE or VALUES statement without running it: the EXPLAIN FORMAT=JSON document plus a summary (full table scans, filesort, temporary table, max estimated rows), or the TREE text. Use it before running a query that may be slow.

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": {
      "sql": "<sql>"
    },
    "name": "explain_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesOne SQL statement.
formatNojson
databaseNoDefault database for unqualified table names. Omit if every name is qualified as db.table.

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.5/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false and openWorldHint=false, so the safety profile is covered. The description adds the non-obvious behavioral fact that the statement is not executed and previews what the response contains, which goes beyond what the annotations state.

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?

A single dense sentence front-loads the action and the non-execution guarantee, then lists the concrete diagnostics returned. No filler, no repetition of the schema, and the usage tip is placed last where it belongs.

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?

For a three-parameter read-only tool with an output schema and full annotation coverage, the description supplies everything an agent needs: what it does, that nothing is executed, what comes back, and when to reach for it. Return-value detail is legitimately left to the output schema.

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 67%; the bare 'format' enum gains meaning from the description's contrast between the JSON document plus summary and the TREE text, and 'one ... statement' reinforces the single-statement constraint on sql. The 'database' parameter is never addressed in the description, leaving a small gap that the schema partially fills.

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 ('Returns the execution plan for one SELECT, TABLE or VALUES statement') plus the crucial scope qualifier 'without running it'. It also names the return artifact (EXPLAIN FORMAT=JSON plus a summary of full table scans, filesort, temporary table, max estimated rows, or TREE text), which clearly separates it from run_query.

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?

'Use it before running a query that may be slow' gives a concrete trigger for choosing this tool over executing the statement. It stops short of naming the alternative (run_query) or stating exclusions such as what to do for DML statements, so it is clear context rather than full when/when-not guidance.

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