Skip to main content
Glama
Postgres MCP Server

Postgres MCP Server

by Zotriq

explain_query

Inspect the PostgreSQL query plan for a SELECT statement without running it, so you can diagnose performance issues and validate queries safely.

Instructions

Show the PostgreSQL query plan for a SELECT without running it.

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

Input Schema

NameRequiredDescriptionDefault
sqlYes
databaseNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

B3.3/5.0
Behavior3/5

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

With no annotations, the description carries the full burden, and it does disclose the key behavioral fact that the query is not executed. It omits other relevant traits: whether EXPLAIN ANALYZE-style execution is ever triggered, what permissions or connection are required, and how errors or non-SELECT input are handled.

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?

A single tight sentence with the operation front-loaded and the non-execution caveat attached where it matters. No filler or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/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-value explanation is unnecessary, and the tool is simple with two parameters. Still, for a tool with zero annotation coverage and zero schema descriptions, the definition leaves the `database` parameter and permission/error behavior entirely unexplained.

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

Parameters2/5

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

Schema description coverage is 0% for both parameters, so the description must compensate. It clarifies that `sql` should be a SELECT, but says nothing about the `database` parameter — an agent gets no indication of which database the plan is generated against or what the default null means.

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 and resource ("Show the PostgreSQL query plan") and scopes it to SELECT statements, which is enough for an agent to recognize the operation. It does not name run_query as the contrasting sibling, but the phrase "without running it" implicitly separates it from execution tools.

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?

The clause "without running it" implies the use case (inspect a plan when you don't want to execute), and "for a SELECT" implies the boundary against run_query. However, there is no explicit statement of when to prefer this over run_query or what to do for non-SELECT statements, leaving the agent to infer the routing.

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