Drizzle MCP Server
Provides database operations and schema management using Drizzle ORM, including migration generation, migration execution, schema introspection, and raw SQL query execution.
Planned support for MySQL databases (not yet implemented).
Supports PostgreSQL databases via pg or postgres drivers, enabling raw queries, schema introspection, and migration operations.
Supports SQLite databases via the better-sqlite3 driver, enabling raw queries, schema introspection, and migration operations.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Drizzle MCP Server Show me the database schema"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Drizzle MCP Server
A Model Context Protocol (MCP) server that provides access to Drizzle ORM database operations and drizzle-kit CLI tools.
Features
Database Schema Management: Generate and run migrations using drizzle-kit
Query Execution: Execute raw SQL queries with parameter support
Schema Introspection: Explore database tables and schema information
Database Resources: Browse tables and schema through MCP resources
Cross-Project Compatibility: Works with any existing Drizzle project
Multi-Database Support: SQLite and PostgreSQL with automatic driver detection
Environment Variable Support: Automatic .env file loading for database credentials
Flexible Installation: Install globally, run with npx/bunx, or use as a linked package
Related MCP server: SQLx MCP Server
Installation
Option 1: Install globally from GitHub
npm install -g github:defrex/drizzle-mcpOption 2: Run directly with npx/bunx (no installation required)
npx github:defrex/drizzle-mcp --help
bunx github:defrex/drizzle-mcp --helpOption 3: Link for development (if working on the package)
# In the drizzle-mcp directory
bun link
# In your project directory
bun link drizzle-mcpUsage
Basic Usage
Run the server with your Drizzle config file:
drizzle-mcp ./drizzle.config.tsOr use the config option:
drizzle-mcp --config ./drizzle.config.tsClaude Desktop Integration
Add to your Claude Desktop configuration:
{
"mcpServers": {
"drizzle": {
"command": "npx",
"args": ["github:defrex/drizzle-mcp", "./drizzle.config.ts"]
}
}
}Or with bunx:
{
"mcpServers": {
"drizzle": {
"command": "bunx",
"args": ["github:defrex/drizzle-mcp", "./drizzle.config.ts"]
}
}
}Command Line Options
drizzle-mcp [options] [config]
Arguments:
config Path to drizzle config file
Options:
-V, --version output the version number
-c, --config <path> Path to drizzle config file
-d, --cwd <path> Working directory (default: current directory)
-v, --verbose Enable verbose logging
-h, --help display help for commandConfiguration
The server automatically detects your Drizzle configuration from:
Command line argument:
drizzle-mcp ./my-config.tsCurrent directory:
drizzle.config.ts,drizzle.config.js, ordrizzle.config.mjs
Your Drizzle config should be a standard drizzle-kit configuration file.
Environment Variables
The server automatically loads environment variables from .env.local and .env files in your project directory. This is useful for database credentials:
# .env.local
DATABASE_URL=postgresql://username:password@localhost:5432/databaseThe server will detect and use DATABASE_URL from your environment variables, so you can use it in your drizzle config:
export default defineConfig({
dialect: 'postgresql',
dbCredentials: {
url: process.env.DATABASE_URL!,
},
// ...
});Available Tools
drizzle_generate_migration - Generate new migration files
drizzle_run_migrations - Apply pending migrations
drizzle_introspect_schema - Introspect existing database schema
execute_query - Execute raw SQL queries
initialize_database - Initialize database connection
Available Resources
database://tables - List all database tables
database://schema - Complete database schema information
Note: Resources are database-agnostic and work with both SQLite and PostgreSQL
Requirements
Node.js 18 or higher
An existing Drizzle project with:
drizzle-orm>= 0.40.0drizzle-kit>= 0.30.0For SQLite:
better-sqlite3>= 9.0.0For PostgreSQL:
pg>= 8.0.0 ORpostgres>= 3.4.0
Note: The server automatically detects which database driver you have installed and uses the appropriate one.
Example Configuration
SQLite Configuration
import { defineConfig } from "drizzle-kit";
export default defineConfig({
out: "./migrations",
schema: "./src/schema.ts",
dialect: "sqlite",
dbCredentials: {
url: "./database.db",
},
});PostgreSQL Configuration
import { defineConfig } from "drizzle-kit";
export default defineConfig({
out: "./migrations",
schema: "./src/schema.ts",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL!,
// Or use individual credentials:
// host: "localhost",
// port: 5432,
// user: "username",
// password: "password",
// database: "database",
},
});Note: The server supports both pg (node-postgres) and postgres (postgres-js) drivers. It will automatically detect which one you have installed and use the appropriate one.
Supported Databases
Currently supports:
SQLite - Via
better-sqlite3PostgreSQL - Via
pg(node-postgres) orpostgres(postgres-js)
The server automatically detects which database drivers you have installed and uses the appropriate ones. For PostgreSQL, it will try postgres first, then fall back to pg.
Support for MySQL is planned for future releases.
Development
The server is built with:
Node.js - JavaScript runtime
TypeScript - Type-safe development
Drizzle ORM - Database ORM and query builder
Commander.js - CLI argument parsing
MCP SDK - Model Context Protocol implementation
dotenv - Environment variable loading
Building from Source
git clone https://github.com/defrex/drizzle-mcp.git
cd drizzle-mcp
bun install
bun run buildKey Features
Automatic Module Resolution: Resolves database drivers and drizzle-orm from your project's dependencies
Environment Variable Loading: Automatically loads
.env.localand.envfiles from your projectCross-Platform: Works with npm, bun, and various package managers
Comprehensive Error Handling: Detailed error messages with context for easier debugging
Security: Input validation and sanitization for all user inputs
License
MIT
Available Tools
5 toolsdrizzle_generate_migrationB
Generate a new migration file using drizzle-kit
Inputs: name (required), config.
drizzle_introspect_schemaB
Introspect database schema using drizzle-kit
Inputs: config.
drizzle_run_migrationsA
Run pending migrations using drizzle-kit
Inputs: config.
execute_queryB
Execute a raw SQL query on the database
Inputs: query (required), params.
initialize_databaseC
Initialize database connection
Inputs: config.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a clearly distinct purpose: generating migrations, running migrations, introspecting schema, executing raw SQL, and initializing the connection. There is no overlap or ambiguity among them.
The three drizzle-kit related tools use the 'drizzle_' prefix (e.g., drizzle_generate_migration) while the other two tools (execute_query, initialize_database) do not follow this prefix pattern. This creates a minor inconsistency, though all names are still snake_case and readable.
With only 5 tools, the server is well-scoped for its purpose of handling Drizzle migrations and database interactions. Each tool is essential and the count is neither too sparse nor overwhelming.
The server covers the core lifecycle of Drizzle migrations (generate, run, introspect) and provides raw query access for additional operations. A minor gap is the lack of a dedicated migration rollback or status tool, but raw SQL and introspection can compensate.
Maintenance
Related MCP Connectors
Build, verify and deploy full-stack apps: Postgres, sign-in, workflows, realtime, AI, rollback.
Build and deploy backends: auth, Postgres/MySQL/vector databases, storage, functions, hosting, CDN
Supabase-compatible Postgres for agents: projects, branches, SQL, auth, storage, email.
Backend for AI-built apps: database, auth, files, email, AI, payments, deploy, realtime. 170+ tools.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables secure database interactions with MySQL, PostgreSQL, and SQLite through granular permissions, multi-database support, and cloud-ready SSL/TLS connections. Supports read-only modes, schema-specific permissions, and transaction management for safe database operations.10 npm1MIT
- AlicenseNot gradedqualityDmaintenanceProvides comprehensive database management tools for PostgreSQL, MySQL, and SQLite databases. Enables querying table structures, executing read-only and write queries, exporting DDL statements, and managing database metadata through natural language.9 npmMIT
- AlicenseNot gradedqualityDmaintenanceProvides secure access to Supabase databases via PostgREST API and management tools for projects, schemas, branches, logs, and code generation.MIT
- AlicenseNot gradedqualityDmaintenanceProvides tools for interacting with relational databases (PostgreSQL, MySQL, SQLite), enabling SQL queries, schema inspection, and migration execution.MIT