Skip to content

MCP server that provides AI models with searchable access to Drizzle ORM documentation

Notifications You must be signed in to change notification settings

cdifulv/drizzle-orm-mcp

Repository files navigation

Drizzle Docs MCP Server

An MCP (Model Context Protocol) server that provides AI models with searchable access to Drizzle ORM documentation. On first run it crawls the official docs site and caches the results locally for fast subsequent startups.

Tools

Documentation

Tool Description
drizzle_search_docs Keyword search across all documentation pages
drizzle_get_page Retrieve the full content of a specific docs page
drizzle_list_topics List all available documentation topics by category

Code Generation

Tool Description
drizzle_generate_schema Convert SQL CREATE TABLE statements into Drizzle ORM TypeScript schema code
drizzle_sql_to_drizzle Convert SQL queries (SELECT, INSERT, UPDATE, DELETE) into Drizzle query builder code

Both code generation tools accept a dialect parameter ("postgresql", "mysql", or "sqlite") and produce output with correct imports.

drizzle_generate_schema

Parses one or more CREATE TABLE statements and produces the equivalent pgTable / mysqlTable / sqliteTable definitions with column types, constraints, and imports.

Parameters:

  • sql (string) — SQL CREATE TABLE statement(s)
  • dialect (enum, default "postgresql") — Target database dialect

Example input:

CREATE TABLE users (
  id SERIAL PRIMARY KEY,
  email VARCHAR(255) NOT NULL UNIQUE,
  created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

Example output (postgresql):

import { pgTable, serial, timestamp, varchar } from "drizzle-orm/pg-core";

export const users = pgTable("users", {
  id: serial("id").primaryKey(),
  email: varchar("email", { length: 255 }).notNull().unique(),
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().default(now()),
});

drizzle_sql_to_drizzle

Translates a SQL query into Drizzle ORM query builder calls, mapping operators to filter functions (eq, gt, like, and, or, etc.).

Parameters:

  • sql (string) — A SQL query to convert
  • dialect (enum, default "postgresql") — Target database dialect
  • schema_hint (string, optional) — Table/column context for more accurate output

Example input:

SELECT u.id, u.name, p.title
FROM users u
INNER JOIN posts p ON p.author_id = u.id
WHERE u.is_active = true
ORDER BY p.created_at DESC
LIMIT 10

Example output:

import { desc, eq } from "drizzle-orm";

db.select({ id: u.id, name: u.name, title: p.title })
  .from(users)
  .innerJoin(posts, eq(p.authorId, u.id))
  .where(eq(u.isActive, true))
  .orderBy(desc(p.createdAt))
  .limit(10);

Prerequisites

  • Node.js >= 18

Setup

npm install

Build

npm run build

This compiles TypeScript from src/ into dist/.

Run

Production (requires a build first):

npm start

Development (with hot reload via tsx):

npm run dev

The server communicates over stdio using the MCP protocol. On first launch it will crawl the Drizzle docs site and cache the pages to crawled_docs.json for faster subsequent starts.

Using with Claude Code

Add the server to your MCP configuration:

{
  "mcpServers": {
    "drizzle-docs": {
      "command": "node",
      "args": ["/absolute/path/to/drizzle-docs-mcp/dist/index.js"]
    }
  }
}

HTTP Transport Mode

The server can also run in HTTP mode, which is useful for Docker deployments or when you want to connect over the network.

# Start in HTTP mode on port 3000
node dist/index.js --http

# Use a custom port
PORT=8080 node dist/index.js --http

The MCP endpoint will be available at http://localhost:3000/mcp.

Docker

Build and run:

docker build -t drizzle-docs-mcp .
docker run -p 3000:3000 drizzle-docs-mcp

Using Docker Compose:

docker compose up

The MCP server will be available at http://localhost:3000/mcp. Other containers on the same Docker network can connect via http://drizzle-docs-mcp:3000/mcp.

Scripts

Script Command Description
build tsc Compile TypeScript
start node dist/index.js Run the compiled server
dev tsx watch src/index.ts Run in development mode with hot reload
clean rm -rf dist Remove build artifacts

About

MCP server that provides AI models with searchable access to Drizzle ORM documentation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published