AI coding assistants are great at generating migrations. They are worse at spotting the breaking changes hiding inside them. The SchemaLens MCP server closes that gap.
Large language models can write ALTER TABLE statements in seconds, but they still miss the second-order risks: a dropped column used by legacy code, a NOT NULL constraint added to a table that still contains null rows, a type change that truncates existing data. Those mistakes slip into production because no one gave the agent a structured way to compare the before-and-after schema.
SchemaLens now exposes its schema diff engine as an MCP server. Any agent that speaks the Model Context Protocol โ Claude Desktop, Cursor, VS Code, Cline, Windsurf โ can call SchemaLens tools to diff schemas, detect breaking changes, and generate migration and rollback SQL. The agent does not guess. It measures.
What MCP adds: instead of asking an agent "is this migration safe?", you give it three tools โ schemalens_diff_schemas, schemalens_detect_breaking_changes, and schemalens_generate_migration โ and let it answer with structured data, risk scores, and ready-to-run SQL.
Most agent workflows today are text-in, text-out. You paste a migration and ask the agent to review it. The result is a paragraph of opinion. It might be right, but it is hard to verify and easy to ignore.
A tool-based review is different. The agent receives a structured diff result โ tables added, columns removed, indexes modified, risk score, breaking-change list โ and can reason about it the same way a senior engineer would. It can then:
The agent becomes a specialized migration reviewer that works in the chat, in the IDE, or in CI.
Each tool accepts raw SQL strings as arguments, so the agent can read schema files from disk, extract SQL from a PR diff, or compare schemas fetched from two branches. There is no database connection, no cloud upload, and no API key.
Add the server to your MCP client config. The only requirement is a local copy of the SchemaLens repo and Node.js.
// Claude Desktop โ ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"schemalens": {
"command": "node",
"args": ["/path/to/race-kimi/mcp-server.js"]
}
}
}
If you are unsure which config format your editor needs, use the MCP Config Generator to generate the exact JSON for Claude, Cursor, VS Code, Cline, or Windsurf.
Once the server is configured, you can ask your agent to review a migration PR in plain English:
Review the schema change in this PR. The old schema is in
migrations/001_initial.sql and the new schema is in
migrations/002_add_orders.sql. Tell me if it is safe to deploy
and generate the PostgreSQL migration and rollback SQL.
The agent will call schemalens_diff_schemas, receive a structured result, and respond with something like:
Risk score: 2/10 โ Low risk.
1 table added (orders), 1 column added (users.email_verified_at), 1 index added. No dropped columns, no type changes, no removed constraints. The new orders table references users(id) with a foreign key and ON DELETE SET NULL, which is safe.
If you then ask for the migration SQL, the agent calls schemalens_generate_migration and returns the exact ALTER TABLE and CREATE TABLE statements needed to apply the change, plus the rollback script to reverse it.
The same review logic can run unattended. The SchemaLens GitHub Action posts schema diff summaries, risk scores, and breaking-change checks on every PR. A team can combine the two layers:
The agent is the fast feedback loop. CI is the enforcement layer. Both use the same engine, so they never disagree.
The MCP server loads SchemaLens's client-side diff engine from the local repo. Your schemas are parsed and compared on the same machine the agent runs on. They are never sent to a SchemaLens server or to a third-party API. This matters for production schemas, regulated environments, and any team that treats schema files as sensitive.
You can get a working AI agent migration reviewer in about two minutes:
Generate the exact MCP config for Claude, Cursor, VS Code, Cline, or Windsurf.
Open MCP Config GeneratorSchemaLens is a browser-based SQL schema diff tool with a free GitHub Action, GitLab/CircleCI/Jenkins/Bitbucket/Azure DevOps support, an MCP server for AI agents, 80+ micro-tools, and a Team plan for shared workspaces. Built in public.