mcpField
D
Drizzle MCP

Drizzle MCP

Local
github.com/fredobummaOther0Updated 1d ago

About Drizzle MCP

Drizzle MCP is a database-browsing MCP server for coding agents, exposing a database through the Drizzle schema used by a project. It is read-only by default and includes TypeScript names, relations, migration status, and SQL safeguards.

Key features

  1. 01Inspect tables, columns, keys, indexes, and relations
  2. 02Browse and count rows with filters
  3. 03Run bounded read-only SQL queries
  4. 04Review query plans and schema drift
  5. 05Check migrations and flag edited applied migrations
  6. 06Enable writes only by explicit option

Use cases

  1. 01Write Drizzle queries that match the project schema
  2. 02Inspect real database contents and distributions
  3. 03Find differences between schema and live database
  4. 04Check whether a query plan uses an index

MCP support

It exposes schema inspection, data browsing, counting, querying, query-plan analysis, and drift-check tools to MCP clients. It is read-only by default; writes are available only when started with `--allow-writes`.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"fredobumma-drizzle": {
"command": "npx",
"args": [
"-y",
"drizzle-mcp"
]
}
}
}
Run commandnpx -y drizzle-mcp

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npmdrizzle-mcp0.1.1

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

drizzle-mcp

Drizzle Studio for agents. An MCP server that lets Claude Code, Cursor and other coding agents see your database through your Drizzle schema.

A generic database MCP sees tables and columns. This one reads the schema your code uses: TypeScript names next to SQL names, relations, enums and defaults. An agent can then answer "what's actually in the database?" and write Drizzle code that matches it.

Here is what an agent gets back when it asks about a posts table:

## posts

SQL table `posts`, exported as `posts` from `src/db/schema.ts`.

| column (TS key, SQL name) | type                     | nullable | default | notes                          |
| ------------------------- | ------------------------ | -------- | ------- | ------------------------------ |
| id                        | serial                   | no       |         | primary key                    |
| authorId (author_id)      | integer                  | no       |         | → users.id, on delete cascade  |
| published                 | boolean                  | no       | false   |                                |
| createdAt (created_at)    | timestamp with time zone | no       | now()   |                                |

Relations (for `browse` with `with`, or `db.query` in code):
- author: one users on posts.authorId = users.id
- comments: many comments on posts.id = comments.postId

Set up

Run it from the folder with drizzle.config.ts.

Claude Code

claude mcp add drizzle -- npx -y drizzle-mcp

Cursor (.cursor/mcp.json) and VS Code (.vscode/mcp.json, with "servers" instead of "mcpServers"):

{
  "mcpServers": {
    "drizzle": { "command": "npx", "args": ["-y", "drizzle-mcp"] }
  }
}

For clients that don't start servers in your project folder, such as Claude Desktop, add "--config", "/path/to/drizzle.config.ts" to args.

drizzle-mcp loads your config the way drizzle-kit does, including your .env. It connects with the database driver and the drizzle-orm version your project already has installed.

Tools

ToolWhat it does
schemaLists the tables. With a table name, it describes the columns (TypeScript key and SQL name, type, nullability, default), the keys, indexes, checks and relations.
browseReads rows the way Drizzle Studio shows them: pick columns, filter, sort and page, and include related rows through your relations(). Rows are keyed by TypeScript property, as db.query returns them.
countCounts rows, overall or per value with groupBy, to see how data is distributed.
queryRuns one SQL statement read-only and returns up to 100 rows.
explainShows the query plan, to check that an index is used. On Postgres, analyze runs the query for real timings.
driftCompares the schema with the live database: missing or extra tables and columns, and changed types or nullability.
migrationsLists drizzle-kit's migrations as applied or pending. It also flags any migration edited after it was applied.
executeChanges data. Only available when the server is started with --allow-writes.

Filters are JSON, so values are always bound as parameters, never pasted into SQL:

{ "published": true, "createdAt": { "gte": "2026-01-01" }, "or": [{ "title": { "ilike": "%drizzle%" } }, { "rating": { "gte": 4.5 } }] }

If you edit the schema, the server picks up the change on the next call; no restart needed.

Safe by default

An agent shouldn't be able to wreck a database by accident, or because something it read told it to.

  • Read-only. Every statement runs in a read-only transaction. SQLite reads use a read-only connection.
  • One statement at a time. select 1; commit; drop table users is refused before it reaches the database. The Postgres drivers and better-sqlite3 would refuse it again on their own; libsql would silently drop everything after the first statement.
  • Bounded. Statements time out after 15 seconds. Results are capped at 100 rows and fetched through a cursor, so a large table is never pulled into memory. Long values are cut short.
  • Secrets hidden. Values in columns named like password, token, secret or apiKey are shown as [redacted].
  • Writes are opt-in. --allow-writes adds the execute tool. query stays read-only either way.

Requirements

DatabaseDrivers
PostgreSQLpg, postgres (postgres.js), PGlite
SQLitebetter-sqlite3, @libsql/client (including Turso)

MySQL isn't supported yet.

drizzle-mcp needs Node.js 22 or newer. It's tested with drizzle-orm 0.45, the current stable release. Drizzle 1.0, still in beta, defines relations differently and isn't supported yet.

Options

--config <path>     The Drizzle config (default: drizzle.config.ts in the current folder)
--url <url>         Connect here instead of the config's dbCredentials
--driver <name>     pg, postgres, pglite, better-sqlite3 or libsql (default: the one installed)
--allow-writes      Add the execute tool
--max-rows <n>      The most rows a tool returns (default: 100)
--timeout <ms>      Statement time limit (default: 15000)
--max-text <n>      Cut strings longer than this (default: 500)
--redact <regex>    Hide columns whose names match (default: password, secret, token…)
--show-secrets      Don't hide any columns

How it works

  1. It loads drizzle.config.ts and your .env, then imports the schema files the config points to (a file, a folder or a glob). Imports go through jiti, so TypeScript works without a build step.
  2. It reads tables, columns and relations from drizzle-orm's own metadata. This is the same information drizzle-kit and relational queries use. That's where the TypeScript names and relations come from.
  3. It connects with your project's driver. browse and count build relational queries with your schema objects. query runs plain SQL through the safeguards above.

Development

pnpm install
pnpm check   # types, lint and 145 tests

The tests run every tool against every driver. Postgres runs as PGlite, which is real Postgres compiled to WebAssembly. pg and postgres.js reach it over the Postgres wire protocol, so no Docker is needed.

License

MIT

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.