Skip to main content
Glama

Sequence exhaustion

pg_sequences_health
Read-onlyIdempotent

Detect PostgreSQL sequences nearing exhaustion: report consumed range, remaining values, cycling status, and whether a smaller serial or identity column will overflow first.

Instructions

Find sequences that are running out of numbers: how much of the usable range each one has consumed, how many values are left, and whether the column it feeds (serial or identity) is a smaller integer type than the sequence, which makes the column overflow first.

Only sequences at or above threshold_percent of their range are listed (default 50). Sequences that cycle wrap around instead of failing and are flagged. A smallint or integer key that is close to its limit needs an ALTER COLUMN ... TYPE bigint long before the sequence ends.

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

Input Schema

NameRequiredDescriptionDefault
limitNo
connectionNo
threshold_percentNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/5.0
Behavior4/5

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

Annotations already declare this a read-only, idempotent, non-destructive operation, so the safety profile needs no repetition. The description adds real behavioral value: the threshold filter is a result-shaping rule, cycling sequences are flagged rather than treated as failures, and it explains why column type matters. It omits how the 'limit' parameter bounds results and what the returned rows look like.

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 purpose is front-loaded in the first clause of a long but well-structured sentence, followed by the filtering rule and the remediation note in descending order of importance. Every sentence contributes, though the first sentence is dense enough that a bulleted split would read faster.

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 diagnostic with no output schema, the description covers what is measured, what is filtered, what is flagged, and what the operator should do about a narrow key column. With annotations handling safety and no return-value contract required, nothing an agent needs to call it correctly is missing beyond minor parameter detail.

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 description coverage is 0%, so the description must carry the load. It fully explains threshold_percent (range-percent cutoff, default 50), but 'limit' (default 50) and 'connection' are never mentioned, and their identical defaults make the distinction between the two numeric parameters easy to confuse.

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?

The description opens with a specific verb and resource ('Find sequences that are running out of numbers') and then names exactly what it reports: consumed range, remaining values, and whether the fed column is a narrower integer type. No sibling tool covers sequences, so an agent can tell this apart from the catalog/inspection tools 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 Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It states the selection condition clearly ('Only sequences at or above threshold_percent of their range are listed') and hints at the follow-up action for narrow key types. However, it never states when NOT to use it or points to a related alternative (e.g. pg_health_check for a general sweep), leaving usage context implied rather than explicit.

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