Skip to main content
Glama
pg-readonly-mcp

pg-readonly-mcp

by vinit1009

explain_query

Read-onlyIdempotent

Shows PostgreSQL's query plan for a SELECT without executing it, helping you check for slow-query risks before running it on large tables.

Instructions

Show PostgreSQL's query plan for one SELECT without running it (EXPLAIN, no ANALYZE). Use it before a query that might be slow on a large table.

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

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.2/5.0
Behavior3/5

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

Annotations already declare readOnly/idempotent/non-destructive, and the description usefully reinforces this by clarifying that no execution occurs (EXPLAIN, no ANALYZE). Beyond that it adds nothing about cost, plan format, or limits, so it does not exceed the annotation baseline by much.

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 short sentences with zero filler; the core behavior is front-loaded and the usage hint follows. Nothing redundant or buried.

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 need no explanation, and the tool is simple enough that behavior plus one usage hint is nearly sufficient. Only minor gaps remain, such as the precise sql string constraints and any statement-timeout or permission considerations.

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?

With one parameter at 0% schema description coverage, the description carries the full burden. It constrains that parameter meaningfully by saying it must be 'one SELECT' (single statement, SELECT only), though it says nothing about whether a trailing semicolon is allowed or what error results otherwise.

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 and resource ('Show PostgreSQL's query plan') and pins down scope: one SELECT, EXPLAIN without ANALYZE. The phrase 'without running it' implicitly separates it from run_query, so an agent can pick correctly without opening the sibling schema.

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: 'Use it before a query that might be slow on a large table,' which is clear usage context. It stops short of stating when not to bother (e.g., trivial queries or when the query must actually be executed), so it is strong but not fully exhaustive.

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

Deploy Server

Other Tools