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.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
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 |
MCP Tools Reference
Tool | Mutates | Description |
|
| Analyze SQL migration files or directories and classify |
|
| Rewrite blocking DDL statements into |
|
| Return lock mode matrix details and blocked query types for a specific PostgreSQL DDL statement. |
Editor and Agent Integration
Cursor (.cursor/mcp.json)
{
"mcpServers": {
"pg-lock-xray": {
"command": "npx",
"args": ["-y", "pg-lock-xray", "--mcp"]
}
}
}Claude Code CLI
claude mcp add pg-lock-xray -- npx -y pg-lock-xray --mcpProgrammatic Usage (JSR / TypeScript)
import * as bridge from "jsr:@kanchingyg/pg-lock-xray/bridge";Runtime Safety and Guardrails
Stdio frame isolation: When
--mcpis active,hijackStdoutForMcp()redirects accidentalconsole.logcalls tostderrso JSON-RPC 2.0 frames onstdoutnever corrupt.Read-only by default: Mutating tools (
mutates: true) are blocked in--dry-runmode and require explicit--allow-writeauthorization.Loop breaker: Repeated identical
(toolName, args)invocations are hashed with SHA-256 and halted after 3 consecutive repeats to prevent runaway agent loops.Context budget truncation: Tool outputs are middle-truncated (
60%head /40%tail) scaled to the probed local modeln_ctx(Ollama/api/show, llama.cpp/props, vLLM/v1/models).Secret redaction and path normalization: AWS keys (
AKIA*,ASIA*), bearer tokens, andsk-*keys are scrubbed before returning tool output, and Windows drive paths (C:\...) translate cleanly to/mnt/c/...when WSL mode is enabled.
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.615 npmMIT
- AlicenseAqualityDmaintenanceAn MCP server that catches dangerous SQL migrations by analyzing PostgreSQL statements for locking risks and providing safe rewrites.218 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.7611 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