Skip to main content
Glama
AkshaySwami14

pg-schema-scout

explain_query

Read-onlyIdempotent

Plan a SELECT query to estimate its cost before execution, useful for large tables, missing WHERE clauses, or multiple joins. Avoids running the query, showing only the plan.

Instructions

Plan a SELECT without executing it.

Use this before run_query when the query touches a large table, has no WHERE clause, or joins several tables, so you can see the cost before committing to it. The query is planned only; no rows are read and nothing is executed. EXPLAIN ANALYZE is deliberately not offered, because it would run the statement.

Read total_cost as a relative number, useful for comparing two phrasings of the same query rather than as a time.

On failure:

  • "Blocked: ..." means the same read-only policy as run_query rejected it. Rewrite as a plain SELECT.

  • A "column does not exist" error means the schema assumption was wrong. Call describe_table and fix the column names.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes
noteNo
planYesEXPLAIN output, one line per plan node.
plan_rowsNoPlanner's estimated output row count.
total_costNoPlanner's estimated total cost of the top node.
Behavior5/5

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

Annotations already declare read-only and idempotent, but the description goes further: 'no rows are read and nothing is executed', explains why EXPLAIN ANALYZE is omitted, and clarifies total_cost as relative. It also discloses failure modes, adding significant context beyond annotations.

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 compact, front-loaded with the primary action, and uses a bulleted list for failure cases. Every sentence adds value—no fluff or repetition.

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

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite having only one parameter and no param descriptions, the description covers usage context, safety, failure handling, and relative output interpretation. An output schema exists, so return values need not be described. It is fully complete for an agent to use correctly.

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?

Schema coverage is 0% and there is one parameter (sql). The description compensates by implying sql must be a plain SELECT (via 'Rewrite as a plain SELECT') and explains column-error behavior. It does not explicitly label the parameter but the meaning is clear from context.

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 starts with a specific verb+resource: 'Plan a SELECT without executing it.' This clearly distinguishes the tool from run_query (which executes) and explains its core function. It also scopes it to SELECT statements, avoiding ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly instructs to 'Use this before run_query' under conditions (large table, no WHERE, joins), and names the alternative run_query. On failure, it directs the user to call describe_table for schema errors, providing clear when-to-use and when-not-to-use guidance.

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/AkshaySwami14/pg-schema-scout'

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