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

MCPg - Production-grade PostgreSQL MCP Server

Audit sequences

audit_sequences
Read-only

Detect PostgreSQL sequences nearing their max_value and flag warning or critical overflow risk before nextval() fails, using configurable percentage thresholds.

Instructions

Flag sequences nearing their ceiling — serial / identity / explicit sequences whose last_value / max_value exceeds warning_pct (default 80) or critical_pct (default 95). Sequence overflow is catastrophic and silent until the next nextval() raises 'reached maximum value' — the int4 serial ceiling (2^31-1) is hit far more often than expected. Pure read; available=false on PG < 10 (no pg_sequences). Returns an object with available, total_examined, warning_pct, critical_pct, detail, and sequences (at-risk only, sorted by used_pct desc — each with schema, sequence, last_value, max_value, used_pct, remaining, status).

Example: audit_sequences(warning_pct=80, critical_pct=95)

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

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.
warning_pctNo
critical_pctNo

Output Schema

NameRequiredDescriptionDefault
detailNo
availableYes
sequencesYes
warning_pctYes
critical_pctYes
total_examinedYes

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

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

Annotations already cover readOnlyHint, but the description goes further: it declares the PG-10-and-up requirement, the availability flag, the sort order of returned rows, and that only at-risk sequences are returned. This is meaningful behavior beyond what the annotation block provides; it only lacks guidance on cost/side effects for very large catalogs.

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 rationale, then preconditions, then return shape, then an example. Dense but every sentence carries information; the return-field enumeration partly duplicates the output schema and could be trimmed.

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 an output schema exists, the description covers what the agent still needs: the triggering condition, defaults, the PG-version limitation, and the meaning of `available`. Only the `database` parameter semantics are left uncovered by both description and schema coverage.

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% and two parameters (warning_pct, critical_pct) have no schema descriptions, so the description earns credit for explaining that these are thresholds on last_value/max_value with defaults 80 and 95, and for the worked example. However it says nothing about the `database` parameter (secondary read-only targeting), leaving a real gap.

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 ('Flag sequences nearing their ceiling') plus the exact predicate (last_value/max_value exceeding warning_pct or critical_pct). It also implicitly distinguishes itself from list_sequences by being a threshold-based audit rather than an enumeration, so an agent can pick between them without opening a 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?

Explains the use case and the motivating failure mode ('nextval() raises reached maximum value'), and gives a runtime precondition (available=false on PG < 10). It stops short of naming an explicit alternative or saying when not to bother running this audit.

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