Skip to main content
Glama
sparta2025

Postgres MCP Pro

by sparta2025

explain_query

Obtain a PostgreSQL execution plan for any SQL statement to pinpoint performance issues. Use ANALYZE for real execution timing, while noting that writes like INSERT/UPDATE/DELETE will actually run.

Instructions

Get query execution plan.

Args:
    sql: SQL statement to explain.
    analyze: If true, actually executes the query for real timing data
        (default: value of EXPLAIN_ANALYZE in .env, normally false).
        WARNING: true really runs the query, including any
        INSERT/UPDATE/DELETE it contains — use with care.
    database_url: Database URL (optional, uses DATABASE_URL from .env if omitted).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes
analyzeNo
database_urlNo

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv0.4.2

TDQS

A4/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does well by disclosing that analyze=true really runs the query and can execute DML, plus the default from EXPLAIN_ANALYZE in .env. It does not describe other potential behaviors like error handling or whether the plan is returned as text/JSON, but the critical side-effect risk is clearly communicated.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a one-line summary followed by a clearly formatted Args block. The analyze warning is verbose but necessary. Every line contributes useful information, though the docstring could be slightly tightened without losing meaning.

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?

Given no output schema and no annotations, the description covers what an agent needs to invoke the tool safely: required sql, optional analyze with its side-effect warning, and optional database_url. It does not specify the return format of the execution plan, but 'Get query execution plan' gives enough context for most agents.

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 fully explain parameters. It covers all three: sql, analyze (including default behavior and a warning), and database_url (including the .env fallback). This adds substantial meaning beyond the raw schema.

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?

The description opens with 'Get query execution plan,' which names a specific verb and resource clearly. It implicitly differentiates from siblings like execute_sql by focusing on plans rather than query execution, but it does not explicitly name any sibling contrast.

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 description gives strong parameter-level usage guidance, especially the WARNING about analyze=true actually executing INSERT/UPDATE/DELETE. However, it does not explicitly state when to prefer this tool over execute_sql or other database analysis siblings, leaving selection partly to inference.

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

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/sparta2025/postgres-mcp'

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