Skip to main content
Glama

explain_query

Return the JSON execution plan for a SQL statement. Optionally run the statement to collect real row counts and timing for performance tuning.

Instructions

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

analyze=False (default) plans without executing; analyze=True runs the
statement to collect real timing — only use it for read-only SQL.

Args:
    sql: A single SQL statement to EXPLAIN.
    analyze: If True, execute the statement to gather real row counts/timing.
    target: Target name from config; omit for the default.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes
targetNo
analyzeNo
Behavior4/5

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

With no annotations, the description fully discloses the read behavior and the difference between planning and executing. It warns that analyze=True executes the statement and should be used only for read-only SQL, which is a key behavioral trait.

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?

The description is brief and well-structured: a single-line summary, a short paragraph on the key parameter, and a bullet list of args. Every sentence adds value without redundancy.

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?

The description covers the main functionality and parameter semantics. However, it does not elaborate on the JSON return format or error handling, which could be helpful but is not critical given the standard EXPLAIN output is well-known.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0% but the description explains all three parameters: sql (statement to explain), analyze (whether to execute for real timing), and target (optional config target). This adds full meaning beyond the bare schema.

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?

The description clearly states the tool returns the JSON execution plan for SQL, explicitly marking it as [READ] and distinguishing the two modes (analyze=False vs True). This directly identifies the resource and action, and the sibling tools are distinct for other database operations.

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?

Provides explicit guidance on when to use analyze=True (only for read-only SQL) and describes the default behavior. Does not explicitly exclude use cases or compare to sibling tools, but the context of sibling names implies alternative tools for different concerns.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AIops-tools/Postgres-AIops'

If you have feedback or need assistance with the MCP directory API, please join our Discord server