MigrateSafe MCP
# MigrateSafe MCP (Lite Edition)
[](LICENSE)
[](https://modelcontextprotocol.io/)
[](https://python.org/)
**MigrateSafe MCP** is a zero-downtime database migration inspection and verification Model Context Protocol server for AI coding assistants (Claude Desktop, Cursor, LangGraph, CrewAI).
It analyzes DDL migration scripts before execution, flagging table-locking statements, destructive drops, and backward-incompatible schema changes that would otherwise cause production downtime or data loss.
---
## ๐ฏ The Problem
When autonomous AI agents write database migrations:
1. **Production Table Lockups:** A naive `ALTER TABLE ... ADD COLUMN ... NOT NULL` or unindexed column change acquires an `AccessExclusiveLock`, blocking all reads and writes and taking down user-facing services.
2. **Silent Breaking Changes:** Dropping or renaming columns without an Expand/Contract migration pattern breaks active application pods during rolling deployments.
3. **Write-Blocking Index Builds:** Running `CREATE INDEX` instead of `CREATE INDEX CONCURRENTLY` blocks INSERT and UPDATE traffic on critical transactional tables.
**MigrateSafe** catches these issues automatically inside your AI workflow before migration scripts ever reach production.
---
## โจ Features (Lite Edition)
- ๐ **Lock Contention Detection:** Identifies statements that acquire `AccessExclusiveLock` or `ShareLock`.
- โ ๏ธ **Destructive Statement Detection:** Flags `DROP TABLE`, `DROP COLUMN`, `RENAME COLUMN`, and incompatible column type rewrites.
- โฑ๏ธ **Lock Duration & Risk Estimator:** Estimates exclusive lock durations based on table row volume.
- ๐ ๏ธ **Full MCP Stdio Protocol:** Native integration with Claude Desktop, Cursor, and agent frameworks.
---
## ๐ Quickstart
### 1. Installation
```bash
git clone https://github.com/johannschiffer/migratesafe-mcp.git
cd migratesafe-mcp
pip install -e .
```
### 2. Configure in Claude Desktop or Cursor
Add to your `claude_desktop_config.json` or Cursor MCP configuration:
```json
{
"mcpServers": {
"migratesafe": {
"command": "migratesafe",
"args": ["run"]
}
}
}
```
### 3. CLI Inspection
```bash
# Analyze migration safety via CLI
migratesafe analyze path/to/migration.sql --dialect postgres
```
---
## ๐ ๏ธ MCP Tools Reference
| Tool | Parameters | Description |
|---|---|---|
| `analyze_migration_safety` | `sql`, `dialect` | Inspects migration for table locks and destructive patterns |
| `detect_table_locks` | `sql`, `dialect` | Maps lock levels (`AccessExclusiveLock`, etc.) per SQL statement |
| `generate_dry_run_plan` | `sql`, `sample_row_count` | Estimates exclusive lock time and production outage risk |
| `inspect_schema_diff` | `before_sql`, `after_sql` | Identifies breaking changes between DDL schemas |
---
## ๐ Upgrade to MigrateSafe Pro
Need production-grade rolling upgrade validation and automated safe refactoring?
The **MigrateSafe Pro Edition** adds:
- ๐ **Zero-Downtime Pattern Generator:** Automatically transforms dangerous DDL into safe 3-phase Expand/Contract migrations.
- โก **Live Shadow Traffic Simulation Harness:** Runs concurrent read/write transactions against a clone database while executing the migration to benchmark lock contention and latency spikes.
- โช **Automated Rollback Verifier:** Proves that `down.sql` completely restores original schema with 0 data loss.
- ๐ณ **Production Docker & Compose:** Ready-to-deploy CI/CD sidecar.
- ๐งช **100% Passing Pytest Suite.**
๐ **[Get MigrateSafe Pro on Gumroad ($14.99 USD)](https://johanld.gumroad.com/l/zkhrvy)**
---
## ๐ License
MIT ยฉ 2026 [Johann Schiffer](https://github.com/johannschiffer)
TDQS
Scored across 4 tools
Each tool has a distinct focus: safety analysis, lock detection, dry-run risk estimation, and schema diffing. analyze_migration_safety is somewhat umbrella-like and overlaps conceptually with the other three, but the descriptions still make tool boundaries understandable.
All four tools follow a consistent snake_case verb_noun pattern: analyze_migration_safety, detect_table_locks, generate_dry_run_plan, inspect_schema_diff. No mixed conventions or vague names.
Four tools is well-scoped for a focused SQL migration safety server. Each tool maps to a clear, non-redundant capability within that domain.
The surface covers core migration-safety workflows: broad analysis, lock mapping, outage-risk estimation, and schema diffing. Minor gaps exist around rollback planning or safe-rewrite suggestions, but agents can work around them.