Skip to main content
Glama

Explain a query

explain
Read-only

Shows the database query plan to check index usage and, on Postgres, can run a read-only query to report actual rows and timings.

Instructions

Shows the plan the database would use for a query, to check that indexes are used. With analyze on Postgres, runs the query (read-only) and reports real timings.

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

Input Schema

NameRequiredDescriptionDefault
sqlYesThe query to explain: one statement, such as a SELECT.
paramsNoValues for the placeholders in `sql`, in order: $1, $2 on Postgres, ? on SQLite.
analyzeNoPostgres only: run it and show actual rows and timings.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false, and the description usefully discloses that analyze actually executes the query while remaining read-only, plus the Postgres-only scope. It does not describe the returned plan format, but the safety-relevant behavior is covered.

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?

Two tight sentences with the core purpose front-loaded and the analyze caveat immediately following. No wasted wording.

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?

For a three-parameter, annotation-rich tool with no output schema, the description covers purpose, the index-checking intent, and the analyze execution caveat. It leaves the structure of the returned plan implicit, a minor gap given the low complexity.

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 sql, params, and analyze are all documented in the schema. The description adds a behavioral nuance about analyze (it actually runs the query, read-only, on Postgres) but little beyond what the schema already states, so baseline 3 applies.

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+resource ('Shows the plan the database would use for a query') and adds the intent ('to check that indexes are used'). It is distinguishable from the sibling `query` tool, though it never names that sibling explicitly.

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?

Gives a clear context for use ('to check that indexes are used') and a concrete condition for the optional path ('With `analyze` on Postgres ... reports real timings'). It does not explicitly say when not to use it or route to the sibling `query`, keeping it below 5.

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

Deploy Server

Other Tools