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

MCPg - Production-grade PostgreSQL MCP Server

Recommend redistribute

recommend_redistribute
Read-only

Analyze hash-distribution skew and recommend a higher-cardinality distribution key, returning ranked candidates and suggested DDL for review without executing changes.

Instructions

Distribution-skew advisor for a hash-distributed table. Reads pg_stats.n_distinct for every column on the table and suggests a better hash key when the current one is low-cardinality. Pure catalog read — no per-segment scans. Returns ranked candidates, optional recommendation, and ready-to-review suggested_ddl (ALTER TABLE … SET WITH (REORGANIZE=TRUE) DISTRIBUTED BY (col)). Diagnosis-only — never executes. On vanilla PG returns available=false.

Example: recommend_redistribute(schema='public', table='fact_sales')

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": {
      "schema": "<schema>",
      "table": "<table>"
    },
    "name": "recommend_redistribute"
  }
}

Input Schema

NameRequiredDescriptionDefault
tableYes
schemaYes
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
tableYes
detailYes
schemaYes
availableYes
candidatesYes
suggested_ddlYes
current_methodYes
recommendationYes
current_columnsYes

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.2/5.0
Behavior4/5

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

Beyond readOnlyHint, the description discloses that it reads only pg_stats and does no per-segment scans, that it is diagnosis-only and never executes, and that it degrades to available=false on vanilla PG. The suggested_ddl is flagged as "ready-to-review," which correctly signals it is output, not execution. Missing only details like whether it requires MPP server type detection or cost of reading wide tables.

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 purpose, then mechanism, safety profile, return shape, and a usage example — each sentence carries information. The level of density is high but appropriate for a multi-output advisor; nothing is filler beyond the somewhat redundant restatement of return fields that the output schema already covers.

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?

For a read-only advisor with an output schema, the description covers mechanism, safety, failure mode, and output shape, which is more than enough to call it correctly. The one remaining gap — the optional database targeting a secondary — is documented in the schema itself.

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

Parameters3/5

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

Schema coverage is only 33% — the database parameter is the sole one documented in the schema. The description compensates partly by giving a concrete call example with schema and table, and by implying table must be hash-distributed, but it never explains the database parameter's targeting of a read-only secondary, nor any validation of schema/table names.

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?

"Distribution-skew advisor for a hash-distributed table" names a specific analysis verb and resource, and the follow-on sentences state the exact mechanism (pg_stats.n_distinct per column) and outcome (suggest a better hash key). It is clearly distinguishable from catalog-listing siblings such as list_distribution_policies or describe_table.

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?

The trigger condition is explicit: use it when the current hash key is low-cardinality, and the note that vanilla PG returns available=false tells the agent when the call will be a no-op. It stops short of naming sibling alternatives (e.g. list_distribution_policies) or saying what to do when available=false.

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