Skip to main content
Glama

zerolock-mcp — PostgreSQL & MySQL Zero-Downtime DDL Migration Lock Auditor (MCP Server + CLI + GitHub Action)

z121245017-ai/zerolock-mcp MCP server

Zero-dependency, 100% offline Model Context Protocol (MCP) Server, CLI, and node20 GitHub Action enabling AI coding agents (Claude Desktop, Cursor, Windsurf, Antigravity) and pull-request CI pipelines to catch catastrophic PostgreSQL (14–17) and MySQL (8.0 / 8.4) ACCESS EXCLUSIVE lock queues, full table rewrites, non-concurrent index builds, unvalidated foreign keys, and missing lock_timeout guards before deployment.

Why Production Migrations Fail in Seconds

  1. FIFO ACCESS EXCLUSIVE Lock Queue Pileups: Even a 5ms ALTER TABLE without SET LOCAL lock_timeout = '2s' waiting behind one active slow query forms a lock queue that blocks 100% of subsequent SELECT and INSERT queries, exhausting connection pools immediately.

  2. ORM Default Migrations Block Writes or Abort at Runtime: Prisma, Drizzle, Flyway, and Alembic frequently emit synchronous CREATE INDEX (without CONCURRENTLY), wrap CONCURRENTLY inside BEGIN...COMMIT, add volatile defaults (DEFAULT gen_random_uuid()), rewrite 20M+ rows on ALTER COLUMN TYPE, scan full tables under SET NOT NULL, or omit MySQL ALGORITHM=INPLACE, LOCK=NONE.

Related MCP server: terrabase

MCP Tools Exposed (stdio — NDJSON & Content-Length)

Tool

Purpose

Safety Annotations

audit_sql_migration_locks

Audits PostgreSQL 14–17 & MySQL 8.0 DDL statements across 16 deterministic lock-queue and table-rewrite rules while honoring fast-path metadata exceptions (PG 11+ constant defaults, varchar -> text widening, pre-validated CHECK before SET NOT NULL).

readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false

generate_zero_downtime_ddl

Rewrites hazardous SQL migrations into multi-phase Phase 1 (Expand / CONCURRENTLY / NOT VALID / ALGORITHM=INSTANT), Phase 2 (VALIDATE CONSTRAINT / Contract), and Emergency Rollback scripts.

readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false

estimate_ddl_blast_radius

Estimates lock duration in seconds, connection-pool exhaustion risk, and blocked SELECT / WRITE query counts given row count and production QPS.

readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false

audit_migration_directory

Recursively scans Prisma (prisma/migrations), Drizzle (drizzle), Flyway (sql), or raw .sql migration directories for deployment hazards.

readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false

Quick Start (MCP Client & Local CLI)

# Start MCP server over stdio (supports both NDJSON and LSP Content-Length framing)
npx -y github:z121245017-ai/zerolock-mcp

# List MCP tool schemas
npx -y github:z121245017-ai/zerolock-mcp --list

# Scan a Prisma or Flyway migration directory directly from terminal
npx -y github:z121245017-ai/zerolock-mcp --scan ./prisma/migrations

# Generate a zero-downtime Expand/Contract rewrite from CLI
npx -y github:z121245017-ai/zerolock-mcp --cli generate_zero_downtime_ddl '{"sql":"CREATE INDEX idx_orders_user ON orders (user_id);"}'

Claude Desktop / Cursor / Windsurf / Antigravity Config

{
  "mcpServers": {
    "zerolock": {
      "command": "npx",
      "args": ["-y", "github:z121245017-ai/zerolock-mcp"]
    }
  }
}

Docker (node:22-alpine, non-root USER node)

docker build -t zerolock-mcp .
docker run -i --rm zerolock-mcp

GitHub Action (z121245017-ai/zerolock-mcp@v1)

Block CRITICAL database lock-queue and table-rewrite hazards in pull requests with inline ::error annotations on exact SQL lines plus a Markdown Step Summary:

name: ZeroLock SQL Migration Gate

on:
  pull_request:
    paths:
      - 'prisma/migrations/**'
      - 'drizzle/**'
      - 'migrations/**'
      - '**/*.sql'

permissions:
  contents: read

jobs:
  sql-lock-audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Audit SQL migrations for production lockouts
        uses: z121245017-ai/zerolock-mcp@v1
        with:
          paths: 'prisma/migrations'
          dialect: 'pg'
          table-rows: '15000000'
          qps: '1200'
          fail-on-critical: 'true'
          fail-on-high: 'false'

Action Inputs & Outputs

Name

Kind

Default

Description

paths

Input

.

Newline- or comma-separated .sql files or migration directories to scan.

dialect

Input

auto

SQL dialect override (auto, pg, or mysql).

table-rows

Input

10000000

Assumed production row count for lock duration simulation.

qps

Input

800

Assumed peak production QPS for blocked query simulation.

fail-on-critical

Input

true

Exit 1 and emit ::error annotations when CRITICAL lock/rewrite hazards are found.

fail-on-high

Input

false

Also exit 1 when HIGH hazards (such as missing lock_timeout) are found.

ignore

Input

node_modules,.git,dist,build,coverage,vendor,test,tests

Comma-separated directory names skipped during recursive workspace scan.

scanned-files

Output

—

Number of .sql migration files audited.

critical-hazards

Output

—

Total CRITICAL lock or table-rewrite findings.

high-hazards

Output

—

Total HIGH findings.

worst-safety-score

Output

—

Lowest 0–100 safety score across scanned migrations.

status

Output

—

Gate verdict (PASS or BLOCKED).

report-json

Output

—

Structured JSON summary of findings and blast-radius metrics.

Verification

npm test

License

MIT License — 0 external npm dependencies, 0 network calls, 100% local execution.

Available Tools

4 tools
audit_migration_directoryB
Read-onlyIdempotent

Recursively scans Prisma, Drizzle, Flyway, or raw .sql migration directories for CRITICAL and HIGH deployment lock-queue and full-table-rewrite hazards.

Inputs: directoryPath (required), qps, strict, dialect, +2 more.

audit_sql_migration_locksA
Read-onlyIdempotent

Audits PostgreSQL 14-17 and MySQL 8.0/8.4 DDL statements for ACCESS EXCLUSIVE lock queues, full table rewrites, non-concurrent index builds, unvalidated foreign keys, and missing lock_timeout guards.

Inputs: sql (required), qps, dialect, tableRows.

estimate_ddl_blast_radiusA
Read-onlyIdempotent

Estimates lock duration in seconds, connection-pool exhaustion risk, and blocked read/write query counts given SQL DDL statements, target table row count, and production QPS.

Inputs: qps (required), sql (required), tableRows (required), dialect, +2 more.

generate_zero_downtime_ddlA
Read-onlyIdempotent

Rewrites hazardous SQL migrations into multi-phase Expand/Contract runbooks using CREATE INDEX CONCURRENTLY, NOT VALID + VALIDATE CONSTRAINT, lock_timeout, ALGORITHM=INSTANT, and emergency Rollback scripts.

Inputs: sql (required), qps, dialect, tableRows.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool targets a distinct input/action pair: auditing raw DDL statements, generating a zero-downtime rewrite, estimating runtime blast radius from row counts/QPS, and recursively scanning a migration directory. The two 'audit' tools are separated cleanly by input type (inline SQL vs. a directory path), so misselection risk is minimal.

    Naming Consistency5/5

    All four names follow a verb_noun snake_case pattern (audit_/generate_/estimate_ + domain object) and use the same vocabulary (ddl, migration, lock) as the descriptions. No mixed casing or verb-style drift.

    Tool Count5/5

    Four tools is a tight, purposeful surface for a migration-safety domain: analyze, rewrite, quantify risk, and batch-scan. Nothing is redundant and each tool maps to a distinct stage of the workflow.

    Completeness4/5

    The surface covers the core lifecycle — detect hazard, rewrite safely, estimate impact, and sweep a directory — with rollback generation folded into the rewrite tool. Minor gaps remain, such as validating or re-checking an already-applied migration and no explicit support beyond PostgreSQL/MySQL, but these are workable around existing tools.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      LLM-assisted, safety-gated Postgres migrations exposed as an MCP server, using a deterministic rule engine over Postgres's own parser AST for safety enforcement, with two-phase approval and append-only audit ledger.
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Governed PostgreSQL DBA operations — slow-query, bloat, and blocking-lock RCA, index management, vacuum/analyze, and replication lag, with unbypassable audit logging (MCP + CLI), budget/runaway guards, dry-run, and undo/rollback.
      35
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Governed MySQL + MariaDB DBA operations — slow-query, lock-wait/deadlock, replication, and fragmentation RCA, with unbypassable audit logging (MCP + CLI), budget/runaway guards, dry-run, and undo/rollback.
      35
      MIT