Skip to main content
Glama

explain_query_working

Explains in plain English how a SQL query runs, covering logical clause order and the physical plan to diagnose slow performance before execution.

Instructions

Explain in plain English HOW a query behaves — two layers: (1) the logical gather order (FROM -> WHERE -> GROUP BY -> HAVING -> SELECT -> ORDER BY -> LIMIT), why 'LIMIT 10' can still be slow; and (2) the actual physical plan the engine chose for THIS query, bottom-up. Call when a user asks why a query is slow or how it runs. Teaching tool. Pass target= in a multi-DB setup.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes
targetNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A3.9/5.0
Behavior3/5

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

No annotations are provided, so the description carries the full behavioral burden. It does disclose the shape of the output (two layers, bottom-up physical plan) and the multi-DB targeting rule, but never states whether the query is actually executed, its read-only/cost profile, or any permission requirements — meaningful gaps for an unannotated tool.

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-loads the two output layers, then usage, then a one-word role marker, then the targeting note — each sentence carries information. It is slightly dense with parentheticals but nothing is redundant.

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?

An output schema exists, so return values needn't be spelled out, and the description still usefully previews the two layers. Given no annotations, the only real omissions are side-effect/execution semantics and error behavior — minor for a read-only explain tool.

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 0%, so the description must compensate. It adds real meaning for 'target' ('Pass target=<name> in a multi-DB setup'), but says nothing about 'sql' beyond the obvious, and gives no format/syntax hints for either parameter.

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?

Names a precise verb+resource (explain how a query behaves) and breaks the deliverable into two concrete layers: logical gather order and the engine's physical plan. This is unmistakably a teaching/diagnostic tool, cleanly separable from siblings like preflight_query (validation) or rewrite_query (rewriting), even without naming them.

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 an explicit trigger: 'Call when a user asks why a query is slow or how it runs,' which tells the agent when this tool fits. It stops short of when-not-to-use guidance or naming the sibling alternatives (preflight_query, suggest_query) an agent might otherwise pick.

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