Skip to main content
Glama
hangdo-merkle

postgres-mcp

explain_query

Inspect PostgreSQL query execution plans to identify performance issues. Run EXPLAIN or EXPLAIN ANALYZE on any SELECT statement to see how the database executes it, helping you optimize slow queries before deployment.

Instructions

Run EXPLAIN (or EXPLAIN ANALYZE) on a query and return the plan.

Args: sql: The SELECT query to explain. analyze: If True, actually executes the query to get runtime stats (EXPLAIN ANALYZE). Default: False (plan only, no execution).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes
analyzeNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.3/5.0
Behavior4/5

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

With no annotations provided, the description carries the full burden. It discloses that analyze=True actually executes the query for runtime stats, and default is plan-only with no execution. This is key behavioral context beyond the schema. It does not explicitly state that EXPLAIN is read-only, but it specifies 'SELECT query' which implies it. Overall, it provides meaningful disclosure without contradicting anything.

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?

Efficient and front-loaded. The first sentence states the purpose, followed by a compact bullet list of arguments. No redundant words; every sentence adds value.

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?

With an output schema present, it does not need to describe the return format. It covers the key parameter behavior and the execution mode distinction. It lacks explicit guidance on when to use this vs execute_query, which is a minor gap, but overall it is complete for a simple, well-scoped tool.

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 description coverage is 0%, so the description must compensate. It fully explains both parameters: sql as 'The SELECT query to explain' and analyze with behavior and default ('If True, actually executes the query to get runtime stats... Default: False (plan only, no execution)'). This adds substantial meaning beyond the raw schema types.

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 ('Run EXPLAIN') on a specific resource ('a SELECT query') and the output ('return the plan'). This clearly distinguishes the tool from its sibling execute_query, which would run the query itself. The purpose is unambiguous and scoped.

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?

Implies usage: it is for examining execution plans without executing (plan-only by default), and analyze=True adds runtime stats. However, it does not explicitly contrast with execute_query or state when not to use it. There is no direct 'use this instead of X' guidance, so only implied usage.

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