schemaforge-mcp
v0.1.0
Published
MCP server for database schema inspection and migration generation
Downloads
120
Readme
Universal database migrations for AI coding agents. Inspect, diff, migrate, and manage schemas across PostgreSQL, MySQL, and SQLite — through one MCP interface.
Quick Start · Tools · Pro Features · Security · Architecture
See it in action
Agent "Show me the schema for the users table"
SchemaForge schema_inspect({ connection_string: "postgresql://...", table: "users" })
Result:
Column Type Nullable Default
id serial NO nextval('users_id_seq')
email varchar NO
name text YES
created_at timestamp NO now()
updated_at timestamp NO now()
4 columns inspected in 23ms Agent "Generate a migration to add a posts table"
SchemaForge generate_migration({
connection_string: "postgresql://...",
changes: [{
type: "create_table",
table: "posts",
columns: [
{ name: "id", type: "serial", primary: true },
{ name: "title", type: "varchar(255)", nullable: false },
{ name: "author_id", type: "integer", references: "users(id)" },
{ name: "published_at", type: "timestamp" }
]
}]
})
Generated SQL:
CREATE TABLE posts (
id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
author_id INTEGER REFERENCES users(id),
published_at TIMESTAMP
);Architecture
graph LR
A["AI Agent<br/>(Claude, Cursor, Windsurf)"] -->|MCP Protocol| B["SchemaForge MCP"]
B --> C[("PostgreSQL")]
B --> D[("MySQL")]
B --> E[("SQLite")]
B --> F["Migration Files"]
B --> G["ORM Models"]
style A fill:#1f2937,stroke:#58a6ff,color:#f0f6fc
style B fill:#0d1117,stroke:#58a6ff,stroke-width:2px,color:#58a6ff
style C fill:#161b22,stroke:#336791,color:#f0f6fc
style D fill:#161b22,stroke:#00758f,color:#f0f6fc
style E fill:#161b22,stroke:#003b57,color:#f0f6fc
style F fill:#161b22,stroke:#30363d,color:#8b949e
style G fill:#161b22,stroke:#30363d,color:#8b949eQuick Start
npx schemaforge-mcpAdd to your claude_desktop_config.json:
- macOS / Linux:
~/.config/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"schemaforge": {
"command": "npx",
"args": ["schemaforge-mcp"]
}
}
}Add to .cursor/rules/mcp_servers.json in your project root:
{
"mcpServers": {
"schemaforge": {
"command": "npx",
"args": ["schemaforge-mcp"]
}
}
}Open settings (Cmd+Shift+P / Ctrl+Shift+P then search "MCP") and add:
{
"mcpServers": {
"schemaforge": {
"command": "npx",
"args": ["schemaforge-mcp"]
}
}
}Set the PRO_LICENSE environment variable to unlock premium tools:
{
"mcpServers": {
"schemaforge": {
"command": "npx",
"args": ["schemaforge-mcp"],
"env": {
"PRO_LICENSE": "your-license-key"
}
}
}
}Or from the command line:
PRO_LICENSE=your-license-key npx schemaforge-mcpTools
Free Tools (7)
| Tool | Description |
|:-----|:------------|
| schema_inspect | Inspect database schema — all tables and columns, or a single table with full column details |
| schema_diff | Compare two database schemas and return a structured diff of added, removed, and modified objects |
| generate_migration | Generate migration SQL (or Knex / Sequelize format) from a list of schema changes — without touching the database |
| migration_status | Report applied migrations and detect third-party trackers (Prisma, Knex, Sequelize, Rails) |
| validate_migration | Validate DDL migration SQL. PostgreSQL runs a full dry-run in a rolled-back transaction |
| suggest_indexes | Suggest missing indexes based on table heuristics or a specific query's execution plan |
| scan_from_url | Clone a GitHub repo and scan for SQL migration files and SQLite databases |
Pro Features (6)
| Tool | Description |
|:-----|:------------|
| apply_migration | Execute migrations against a live database with automatic schema snapshots and tracking |
| rollback_migration | Roll back the last N applied migrations using their recorded rollback SQL |
| detect_dead_schema | Find database tables not referenced in your codebase |
| generate_seed | Generate realistic INSERT statements based on live schema column types |
| schema_to_orm | Convert database schema to ORM models — Prisma, Drizzle, Knex, or Sequelize |
| multi_env_sync | Compare schemas across environments and generate a pairwise drift report |
Feature Comparison
Database Support
Connection Strings
# PostgreSQL
postgresql://user:password@localhost:5432/mydb
# MySQL
mysql://user:password@localhost:3306/mydb
# SQLite
sqlite:///path/to/database.db
sqlite://:memory:Security
SchemaForge MCP is read-only by default. Write operations require an explicit Pro license.
| Principle | Details |
|:----------|:--------|
| Read-only by default | Free tools only inspect and generate — they never modify your database |
| Your credentials, your control | Connection strings are passed per-call. Nothing is stored or transmitted externally |
| Least privilege | Use database roles with minimal permissions for inspection tools |
| Audit trail | All applied migrations are tracked in schemaforge_migrations for compliance and rollback |
| No telemetry | Zero analytics, zero phone-home. Your schema data stays local |
Best Practices
# Use environment variables — never hardcode credentials
DATABASE_URL=postgresql://user:pass@localhost/db npx schemaforge-mcp
# Use a read-only role for inspection
postgresql://readonly_user:pass@localhost:5432/production
# Always test migrations in staging before production
PRO_LICENSE=key npx schemaforge-mcp # Connect to staging firstMigration Tracker Interop
SchemaForge detects and respects existing migration systems in your database:
| Tracker | Detection Table | Status |
|:--------|:---------------|:-------|
| Prisma | _prisma_migrations | ✅ Full support |
| Knex | knex_migrations | ✅ Full support |
| Sequelize | SequelizeMeta | ✅ Full support |
| Rails | schema_migrations | ✅ Full support |
SchemaForge works alongside these tools without conflicts. Use migration_status to see a unified view of all migration systems in your database.
Pro License
Unlock apply, rollback, dead schema detection, seed generation, ORM export, and multi-environment sync.
Get your license:
# Activate
export PRO_LICENSE=your-license-key
npx schemaforge-mcp
# Or inline
PRO_LICENSE=your-license-key npx schemaforge-mcpBuilt by Craftpipe — AI-powered developer tools
MIT License © 2025 Craftpipe
