Skip to main content
Glama
db-conn-mcp

db-conn-mcp

check_sequences

Read-onlyIdempotent

Detect database sequences lagging behind their column’s max value after migrations or bulk copies; fix them with setval() before they hand out duplicate IDs.

Instructions

Find sequences lagging behind their column's max value (stale after migrations).

A behind: true sequence would hand out an id that already exists — fix with setval(). Run this after any bulk copy or logical-replication migration. By default only the problem sequences are listed, with total_sequences reporting how many were checked and skipped listing the ones that could not be probed — so behind_count: 0 means "all clear" only when skipped_count is 0. A skipped entry's reason is no_privilege (grant USAGE on the schema and SELECT on the sequence and its table) or probe_failed (the owning column is not numeric or the sequence could not be read). Pass behind_only=false for the full census; on a large schema that is one row per sequence (hundreds), so ask for it only when you need every sequence's state.

Returns meta, database, sequences, behind_count, total_sequences, skipped and skipped_count.

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": {
      "database": "<database>"
    },
    "name": "check_sequences"
  }
}

Input Schema

NameRequiredDescriptionDefault
databaseYesName of a configured database, exactly as list_databases returns it (case-sensitive). Not a DSN, host or server-side database name. An unknown name is an error that lists the configured names.
behind_onlyNotrue (default): list only sequences that are behind. false: every sequence's state.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.8.1
    • addedInput schema / properties / behind_only / description
      Added value: +"true (default): list only sequences that are behind. false: every sequence's state."
    • addedInput schema / properties / database / description
      Added value: +"Name of a configured database, exactly as list_databases returns it (case-sensitive). Not a DSN, host or server-side database name. An unknown name is an error that lists the configured names."
  2. First observed

TDQS

A4.6/5.0
Behavior5/5

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

The annotations already cover the safety profile (readOnly, idempotent, non-destructive), yet the description adds substantive behavior: the meaning of behind_count: 0 depends on skipped_count being 0, the two skip reasons (no_privilege, probe_failed) with the grants needed to avoid them, and the performance shape of the full census. That is exactly the context 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-loads the core purpose and the actionable remedy in the first two sentences, then layers caveats. The closing enumeration of return keys partially repeats fields already explained inline (total_sequences, skipped), which is mild redundancy, but it is defensible given no output schema exists.

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?

With no output schema, the description carries the full return-value burden and does so: it enumerates the response envelope, explains the ambiguity between behind_count and skipped_count, and documents per-item failure reasons with remediation. An agent has everything needed to call this and interpret the result correctly.

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 100%, so the baseline is 3, but the description adds real meaning the schema lacks: what "behind" means operationally, that the default hides healthy sequences, and that behind_only=false scales to one row per sequence on large schemas. The database parameter is left entirely to the schema, which is acceptable given its detailed own description.

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?

Opens with a specific verb and resource: "Find sequences lagging behind their column's max value," and immediately explains the failure mode ("would hand out an id that already exists"). No sibling tool in the list does sequence auditing, and the description makes the distinction obvious without requiring schema inspection.

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 a concrete trigger — "Run this after any bulk copy or logical-replication migration" — and an explicit constraint on the expensive path ("ask for it only when you need every sequence's state"). It also names the remedy (setval()), which implicitly signals there is no separate fix tool, though it never explicitly contrasts with any named alternative.

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