Skip to main content
Glama
MCPg - Production-grade PostgreSQL MCP Server

MCPg - Production-grade PostgreSQL MCP Server

Analyze MPP query plan

analyze_mpp_query_plan
Read-only

Run EXPLAIN (ANALYZE, FORMAT JSON) on SQL to surface MPP slice counts, motion nodes, sender/receiver rows, and flag non-co-located joins.

Instructions

Run EXPLAIN (ANALYZE, FORMAT JSON) on sql and roll up MPP-specific facts: slice count, motion nodes (Redistribute Motion / Broadcast Motion / Gather Motion), and per-motion metadata (senders, receivers, estimated rows). Uses the same safety pre-flight as analyze_query_plan(io=True) — writes / DDL stay rejected. redistribute_count flags 'data is not co-located with the join key'. On vanilla PG returns available=false.

Example: analyze_mpp_query_plan(sql='SELECT * FROM big JOIN small ON big.k = small.k')

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": "analyze_mpp_query_plan"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYes
databaseNoOptional: a database id from list_databases, to target a configured secondary (read-only) database; omit for the primary. Database names that are not configured ids are rejected.

Output Schema

NameRequiredDescriptionDefault
detailYes
motionsYes
availableYes
slice_countYes
gather_countYes
motion_countYes
broadcast_countYes
redistribute_countYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.8.4
    • changedInput schema / properties / database / description
      Previous value: -"Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids."New value: +"Optional: a database id from list_databases, to target a configured secondary (read-only) database; omit for the primary. Database names that are not configured ids are rejected."
  2. First observedv0.6.8

TDQS

A4.3/5.0
Behavior4/5

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

Beyond readOnlyHint/openWorldHint, the description discloses that writes and DDL are rejected by the same pre-flight as analyze_query_plan, that the result degrades gracefully to available=false off MPP, and what redistribute_count means. One notable behavior is left implicit: EXPLAIN ANALYZE actually executes the statement, so cost/latency implications of running it are not stated.

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?

Front-loaded with the action and output shape, then safety, then degradation behavior, then an example. Each clause carries information, though the parenthetical 'Redistribute Motion / Broadcast Motion / Gather Motion' enumeration is slightly heavy and the trailing example is arguably optional.

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, and the description still helpfully names the key rollup fields; annotations cover the read-only profile. Completeness is high for a 2-parameter tool, with the only real omission being the execution cost of running EXPLAIN ANALYZE on a live query.

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 50%: the database parameter is fully documented in the schema, while sql is not. The description compensates by defining sql as the statement handed to EXPLAIN ANALYZE and giving a concrete example invocation, which is enough meaning to call it correctly, though it does not state constraints on the SQL (e.g. SELECT-only) beyond the write/DDL rejection.

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 ('Run EXPLAIN (ANALYZE, FORMAT JSON) on sql') and immediately narrows scope to MPP-specific rollups: slice count, motion nodes, per-motion metadata. It is clearly differentiated from the sibling analyze_query_plan by its MPP focus and its 'available=false on vanilla PG' caveat.

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?

It establishes context (MPP databases) and signals when the tool is inapplicable ('On vanilla PG returns available=false'), plus relates itself to analyze_query_plan(io=True) for the safety model. It stops short of an explicit 'use analyze_query_plan instead when not on an MPP cluster' routing sentence, leaving that inference to the agent.

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