Skip to main content
Glama
pg-migration-guard

pg-migration-guard

Check a Postgres migration for lock and safety risks

analyze_migration
Read-only

Check PostgreSQL migration SQL before running or committing to flag table locks, table rewrites, and code-breaking statements, with a safer rewrite for each finding.

Instructions

Analyzes Postgres migration SQL and reports statements that lock tables, rewrite them, or break running code (CREATE INDEX without CONCURRENTLY, volatile defaults, SET NOT NULL, foreign keys without NOT VALID, renames, missing lock_timeout, ...). Call this before running or committing any migration. Each finding includes a safer rewrite.

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": {
      "sql": "<sql>"
    },
    "name": "analyze_migration"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesThe full migration SQL.
postgres_versionNoTarget Postgres major version (default 16).
assume_transactionNoTrue if the migration tool wraps each file in a transaction (Rails, Django, Prisma, Knex do by default).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.1/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false, and the description is consistent with a pure analysis tool. It adds value beyond the annotations by disclosing the output shape ('each finding includes a safer rewrite') and the breadth of checks performed, which an agent needs to decide whether to trust and surface the results.

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?

Three sentences, front-loaded with the core action, then the risk taxonomy, then the workflow instruction. The parenthetical enumeration is long but each item conveys a distinct detectable risk rather than padding.

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 adequately covers what comes back (findings plus safer rewrites) and the checks performed. A read-only, single-required-parameter tool needs little more; only a note on finding format/severity would improve it.

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 100%, so sql, postgres_version (default 16), and assume_transaction (with framework examples) are already fully documented in the schema. The description adds no further parameter meaning, so the baseline 3 applies.

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 (analyzes Postgres migration SQL) and enumerates the exact risk classes it detects (CREATE INDEX without CONCURRENTLY, volatile defaults, SET NOT NULL, FKs without NOT VALID, renames, missing lock_timeout). This is clearly distinguishable from a rules-listing sibling and tells an agent precisely what class of tool this is.

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?

Explicit timing guidance: 'Call this before running or committing any migration' tells the agent exactly where in the workflow this belongs. It does not name an alternative or exclusion condition, but the sibling (list_rules) is a different kind of tool, so the practical guidance is clear.

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