Skip to main content
Glama

Integrity check

pg_integrity_check
Read-onlyIdempotent

Detect PostgreSQL integrity issues: invalid indexes, missing primary keys, disabled triggers, orphaned sequences, checksum failures; optionally verify b-tree indexes and report fixes without writes.

Instructions

Look for data integrity problems: invalid indexes, constraints added NOT VALID, tables without a primary key, forgotten prepared transactions, disabled triggers (including foreign key enforcement), collation versions that changed under the server, data checksums off or failing, and sequences that no column owns.

schema limits the object checks to one schema. With index (the name of a b-tree index) and the amcheck extension (PostgreSQL 10+) it also verifies that index's structure with bt_index_check, which needs a superuser and reads the whole index. Nothing is changed; each problem comes with a fix to apply yourself.

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_integrity_check"
  }
}

Input Schema

NameRequiredDescriptionDefault
indexNo
schemaNo
connectionNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.7/5.0
Behavior4/5

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

Annotations already cover the safety profile (readOnly, idempotent, non-destructive), and the description still adds meaningful behavior: bt_index_check requires a superuser and reads the whole index (a real cost), and each reported problem comes with a fix to apply manually. It does not describe scan cost when neither `schema` nor `index` is supplied, which is the one remaining blind spot.

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 findings list, then parameters and caveats in a second paragraph. The enumeration is long but each item is a distinct check that earns its place; the only redundancy is restating that nothing is changed, which annotations already declare.

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?

With no output schema, the description does useful work by saying each problem comes with a suggested fix, and it covers the amcheck privilege and read-cost caveats. Gaps are the unmentioned `connection` parameter and the default behavior/cost when no scope arguments are given.

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 parameters. It explains `schema` (limits object checks to one schema) and `index` (a b-tree index name paired with amcheck on PostgreSQL 10+), but the third parameter, `connection`, is never mentioned and its semantics remain undocumented anywhere.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific verb ('Look for') and enumerates exactly what is inspected: invalid indexes, NOT VALID constraints, missing primary keys, prepared transactions, disabled triggers, collation versions, checksums, and unowned sequences. That enumeration makes the scope clearly distinct from siblings like pg_health_check or pg_bloat without needing to name them, though no sibling is explicitly referenced.

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?

Usage is implied by the check list and by the conditional statement that supplying `index` plus amcheck triggers bt_index_check, but there is no explicit when-to-use guidance, no statement of when this tool is the wrong choice, and no routing to alternatives.

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