Skip to main content
Glama

Explain query

explain_query

Explain SELECT queries as JSON summaries with total cost, node types, sequential scans, and index scans—without executing the query or allowing writes.

Instructions

Run EXPLAIN (FORMAT JSON) for a SELECT query and return a plain summary: total cost, node types, sequential scans, and index scans. The query is planned, never executed, and writes are rejected.

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

Input Schema

NameRequiredDescriptionDefault
queryYesThe SELECT query to explain, e.g. "SELECT * FROM orders WHERE customer_id = 1".

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?

With no annotations, the description carries the full burden and does the most important part well: it states the query is planned but never executed and that writes are rejected, which is exactly the safety profile an agent needs before passing SQL. It also enumerates the summary fields returned. Gaps remain on permissions/role requirements and any size or timeout limits.

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 sentences, no waste. The operation and its return contents come first, and the non-execution guarantee follows as the key caveat. Every clause earns its place.

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?

Single required string parameter, no nested objects, no output schema. The description covers the operation, the accepted input class, the safety guarantee, and the shape of the result, which is everything needed to invoke it correctly and interpret the response.

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% and the parameter example is in the schema, so the baseline is 3. The description adds real constraint semantics beyond the schema's plain string type by narrowing accepted input to SELECT queries and declaring that writes are rejected, telling the agent what will and won't validate.

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?

Names a specific verb+resource: EXPLAIN (FORMAT JSON) for a SELECT query, plus the exact contents of the returned summary (total cost, node types, seq scans, index scans). Very clear what it does. It stops short of explicitly differentiating from a sibling like suggest_indexes, which also concerns query performance, so it lands at 4 rather than 5.

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: you reach for this when you want to inspect a query plan's cost and scan behavior. There is no explicit 'use this when... / use suggest_indexes instead when...' guidance, and no stated prerequisites, so the agent must infer its place among the sibling tools.

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