Audit sequences
audit_sequencesDetect 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
| Name | Required | Description | Default |
|---|---|---|---|
| database | No | 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. | |
| warning_pct | No | ||
| critical_pct | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| detail | No | ||
| available | Yes | ||
| sequences | Yes | ||
| warning_pct | Yes | ||
| critical_pct | Yes | ||
| total_examined | Yes |