pg-lock-xray
Integrates with a local Ollama model to rewrite SQL migrations for zero-downtime changes through the rewrite_zero_downtime MCP tool, using a configurable model and base URL.
Analyzes PostgreSQL migration SQL files for ACCESS EXCLUSIVE lock hazards such as non-concurrent index creation, unsafe foreign keys, and volatile defaults, and provides zero-downtime rewrite guidance.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@pg-lock-xrayScan ./migrations for ACCESS EXCLUSIVE locks and rewrite unsafe SQL"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
pg-lock-xray
One line: npx pg-lock-xray prisma/migrations (or bunx pg-lock-xray prisma/migrations): catch ACCESS EXCLUSIVE PostgreSQL migration lock hazards before production.
+-------------------------------------------------------------+
| migration.sql --> lock classifier --> severity report |
| | | |
| +---- --fix --> CONCURRENTLY / NOT VALID rewrites |
+-------------------------------------------------------------+Install
bunx pg-lock-xray ./migrations
npx pg-lock-xray ./migrations
# or install in your project / globally
bun add -d pg-lock-xray
npm i -D pg-lock-xrayJSR:
bunx jsr add @kanchingyg/pg-lock-xray
npx jsr add @kanchingyg/pg-lock-xraycargo install --git https://github.com/kanchingyg/pg-lock-xrayThe core engine is Rust (src/lib.rs, src/main.rs, src/mcp.rs): static lock rules, zero-downtime rewrite hints, and sqlOrPath containment under migrations/, prisma/, supabase/, or sql/. TypeScript under src/*.ts is included for npx / bunx / JSR usage and MCP bridge helpers.
Related MCP server: locksmith
Quick start
npx pg-lock-xray ./migrations
bunx pg-lock-xray ./migrations
npx pg-lock-xray --fix ./sql/0001_init.sql --dry-run
npx pg-lock-xray --fix ./sql/0001_init.sql --allow-write
npx pg-lock-xray --mcpWhat it catches
Pattern | Risk |
|
|
| pgvector blocking index build |
| Long table validation lock |
Volatile | Full table rewrite |
MCP & Ollama
Add to .cursor/mcp.json:
{
"mcpServers": {
"pg-lock-xray": {
"command": "npx",
"args": ["-y", "pg-lock-xray", "--mcp"]
}
}
}Call MCP tool rewrite_zero_downtime with { "sqlOrPath": "...", "model": "llama3.2", "baseUrl": "http://127.0.0.1:11434" }.
Flags
Flag | Purpose |
| Enable |
| Show diff / run tools without writing |
| JSON-RPC MCP server on stdio |
| Normalize paths for WSL agents |
License
This server cannot be deployed
Maintenance
Related MCP Connectors
Detects database migration table locks, terraform cost leaks, and OWASP API flaws.
Scans schema metadata to classify PHI, score HIPAA readiness, and generate compliant migrations.
Paid remote MCP for schema drift checks, approvals, receipts, and release audit logs.
Code review for diffs: rule-based checks for leaked secrets, unsafe migrations and more.
Related MCP Servers
- AlicenseAqualityDmaintenanceAnalyzes database migrations for risks like lock contention and data loss before they run. Supports Flyway and Liquibase formats, providing risk scores and rollback generation.69 npmMIT
- AlicenseAqualityDmaintenanceAn MCP server that catches dangerous SQL migrations by analyzing PostgreSQL statements for locking risks and providing safe rewrites.215 npmMIT
- AlicenseAqualityAmaintenanceBlocks unsafe PostgreSQL migrations before an AI agent writes or runs them. check_before_apply returns a pass/fail gate; reads the real Postgres parser, classifies the lock each statement takes, checks 112 safety rules. Runs offline, no database required.7438 npm9MIT
- AlicenseNot gradedqualityAmaintenanceEnables checking Postgres migration SQL against a table-size estate snapshot and safety policy before apply, returning approve/block verdicts with lock details and remediation guidance, plus tools to explain locks and list policy rules.1MIT