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

MCPg - Production-grade PostgreSQL MCP Server

Recommend skip scan indexes

recommend_skip_scan_indexes
Read-only

Identifies composite B-tree indexes whose low-NDV leading column unlocks PG 19 skip-scan, flagging now-redundant single-column indexes on trailing columns as candidates for removal.

Instructions

Find composite B-tree indexes whose leading column has low NDV — these are the ones PG 19's skip-scan optimisation unlocks. Each candidate's trailing columns can now be served by the composite index alone, so any dedicated single-column indexes on those trailing columns become review candidates for recommend_index_drops. Returns an empty list on PG ≤ 18 or driver failure — pair with get_skip_scan_status for the diagnostic. max_leading_ndv (default 1000) caps the leading-column NDV that's considered low enough for skip-scan to be profitable. Returns a list of objects with schema, table, index_name, leading_column, trailing_columns (list of strings), estimated_leading_ndv (int), and rationale (human-readable explanation).

Example: recommend_skip_scan_indexes()

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "recommend_skip_scan_indexes"
  }
}

Input Schema

NameRequiredDescriptionDefault
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.
max_leading_ndvNo

Output Schema

NameRequiredDescriptionDefault
resultYes

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

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

Annotations already declare readOnlyHint=true and openWorldHint=false, so the safety profile is covered. The description adds genuinely new behavior: a PG 19 version dependency, an empty-list return on driver failure (rather than an error), and the default-cap semantics — these are the kinds of traits annotations cannot express.

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 core definition, then version caveat, then parameter meaning, then return shape — a sensible ordering. The trailing `Example: recommend_skip_scan_indexes()` line carries zero information and is dead weight in an otherwise dense paragraph.

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?

Covers the definition, version prerequisites, failure behavior, follow-up tool, parameter default, and the return fields even though an output schema exists. For a two-parameter read-only advisory tool, nothing an agent needs in order to call it or interpret an empty result is missing.

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%: `database` is documented in the schema but `max_leading_ndv` has no description there. The description fills that gap by defining it as the NDV cap below which skip-scan is considered profitable, plus its default of 1000, which is exactly the compensating detail needed.

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 — find composite B-tree indexes whose leading column has low NDV — and anchors it to the PG 19 skip-scan feature. It also names the sibling it feeds into (`recommend_index_drops`), so an agent can place it in the index-recommendation family without opening the 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 concrete selection conditions: the candidates are the trailing-column indexes that become redundant, and failure conditions (PG ≤ 18, driver error) return an empty list with `get_skip_scan_status` as the diagnostic companion. It stops short of explicitly contrasting with `recommend_indexes`, but the use context is clear enough to act on.

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