mcp-schema-designer
v1.1.4
Published
MCP server for database schema design and SQL generation. Design schemas, validate them, generate migrations, produce typed outputs, and optimize queries.
Maintainers
Readme
Schema Designer
MCP server for database schema design and SQL generation. Design schemas from natural language, validate them for best practices, generate migrations, produce typed outputs (TypeScript/Zod/JSON Schema), and optimize queries -- all targeting PostgreSQL.
Pure logic -- no database connection needed. It generates SQL, it does not run it.
Pricing
| Plan | Price | Features | |
|------|-------|----------|---|
| Free trial | $0 | 3 calls total (shared across all tools), no credit card | npx -y mcp-schema-designer |
| Basic | $10/mo | design_schema, validate_schema, generate_types | Buy → |
| Pro | $20/mo | All Basic tools + migrate_schema, optimize_queries | Buy → |
License keys are delivered to your email immediately after checkout. More info: aivp-mcp.vercel.app
Installation
Note: the npm package is
mcp-schema-designer(the bare nameschema-designeris a different, unrelated package).
No install step needed — run straight from npm:
npx -y mcp-schema-designerOr install globally:
npm install -g mcp-schema-designerFree trial: 3 calls total (shared across all tools), no credit card. Buy a license at the links in Pricing — your key is emailed instantly. Activate it with the LICENSE_KEY environment variable.
Usage
stdio (default)
npx -y mcp-schema-designerSSE (HTTP)
npx -y mcp-schema-designer --sse
# Listening on http://localhost:3000Set a custom port:
PORT=8080 npx -y mcp-schema-designer --sseClaude Desktop Configuration
Add to your claude_desktop_config.json:
{
"mcpServers": {
"schema-designer": {
"command": "npx",
"args": ["-y", "mcp-schema-designer"],
"env": { "LICENSE_KEY": "<your license key — omit for free trial>" }
}
}
}Tools
design_schema
Design a database schema from a natural language description. Generates CREATE TABLE SQL (PostgreSQL), index recommendations, and a text-based ERD.
Input:
{
"description": "An e-commerce platform with products, orders, and user accounts"
}Or provide explicit table definitions to validate and enhance:
{
"description": "Custom blog schema",
"tables": [
{
"name": "posts",
"columns": [
{ "name": "id", "type": "SERIAL", "primary": true },
{ "name": "title", "type": "VARCHAR(255)" },
{ "name": "author_id", "type": "INTEGER", "references": "users.id" }
]
}
]
}validate_schema
Validate SQL CREATE TABLE statements for best practices.
Checks for:
- Missing primary keys
- Unnamed constraints
- Missing indexes on foreign keys
- Data type issues (e.g., TIMESTAMP vs TIMESTAMPTZ, FLOAT for money)
- Naming convention violations (snake_case, plural table names)
- N+1 query risks based on relationships
Input:
{
"sql": "CREATE TABLE User (id SERIAL PRIMARY KEY, firstName VARCHAR(255), orderTotal FLOAT);"
}migrate_schema
Generate migration SQL by diffing two schemas.
Input:
{
"from_sql": "CREATE TABLE users (id SERIAL PRIMARY KEY, name VARCHAR(255));",
"to_sql": "CREATE TABLE users (id SERIAL PRIMARY KEY, name VARCHAR(255), email VARCHAR(255) NOT NULL UNIQUE);"
}Output: UP migration (ALTER TABLE to add email column), DOWN migration (rollback), warnings for destructive changes.
generate_types
Generate typed code from SQL schema. Supports three output formats.
Input:
{
"sql": "CREATE TABLE users (id SERIAL PRIMARY KEY, email VARCHAR(255) NOT NULL UNIQUE, name VARCHAR(255), created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP);",
"format": "typescript"
}Formats:
| Format | Output |
|--------|--------|
| typescript | TypeScript interfaces with Create variants |
| zod | Zod validation schemas with inferred types |
| json-schema | JSON Schema (draft 2020-12) definitions |
optimize_queries
Analyze a SQL query against a schema and suggest performance improvements.
Input:
{
"query": "SELECT * FROM orders WHERE user_id = 123 AND status = 'active' ORDER BY created_at DESC OFFSET 500",
"schema_sql": "CREATE TABLE orders (id SERIAL PRIMARY KEY, user_id INTEGER REFERENCES users(id), status VARCHAR(50), created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP);"
}Identifies:
- Missing indexes (WHERE, JOIN, ORDER BY columns)
- Query rewrites (SELECT *, NOT IN, leading wildcards, large OFFSET)
- EXPLAIN plan interpretation hints
Development
npm install
npm run dev # Watch mode
npm run build # Production build
npm start # Run stdioLicense
MIT
