drizzle-mcp
Provides tools for inspecting and working with a Drizzle ORM schema, including table metadata, TypeScript and SQL names, relations, filters, browsing, counting, query plans, drift checks, and migration status.
Connects to PostgreSQL databases to inspect schemas, browse rows, count data, run read-only SQL, explain queries, and compare schema drift and migrations.
Connects to SQLite databases to inspect schemas, browse rows, count data, run read-only SQL, explain queries, and check drift and migration status.
Connects to Turso/libSQL databases through the libSQL client to inspect schemas, browse rows, run read-only SQL, explain queries, and compare schema drift and migrations.
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 show me the posts table schema and its relations"
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
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.
For migrations, use Drizzle's own drizzle-kit mcp (drizzle-kit 1.0): it generates, pushes and checks them. drizzle-mcp reads what's in the database, read-only by default, so the two work side by side.
If it's useful to you, a star on GitHub helps other people find it. Questions, bug reports and ideas are welcome in the issues, and so are pull requests.
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.postIdSet up
Run it from the folder with drizzle.config.ts.
Claude Code
claude mcp add drizzle -- npx -y drizzle-mcpCursor (.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.
Related MCP server: mcp-data-gateway
Tools
Tool | What it does |
| Lists the tables. With a table name, it describes the columns (TypeScript key and SQL name, type, nullability, default), the keys, indexes, checks and relations. |
| Reads rows the way Drizzle Studio shows them: pick columns, filter, sort and page, and include related rows through your |
| Counts rows, overall or per value with |
| Runs one SQL statement read-only and returns up to 100 rows. |
| Shows the query plan, to check that an index is used. On Postgres, |
| Compares the schema with the live database: missing or extra tables and columns, and changed types or nullability. |
| Lists drizzle-kit's migrations as applied or pending. It also flags any migration edited after it was applied. |
| Changes data. Only available when the server is started with |
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 usersis refused before it reaches the database. The Postgres drivers andbetter-sqlite3would 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,secretorapiKeyare shown as[redacted].Writes are opt-in.
--allow-writesadds theexecutetool.querystays read-only either way.
Requirements
Database | Drivers |
PostgreSQL |
|
SQLite |
|
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, now in release candidates, 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 columnsHow it works
It loads
drizzle.config.tsand 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.It reads tables, columns and relations from drizzle-orm's own metadata. This is the same information
drizzle-kitand relational queries use. That's where the TypeScript names and relations come from.It connects with your project's driver.
browseandcountbuild relational queries with your schema objects.queryruns plain SQL through the safeguards above.
Development
pnpm install
pnpm check # types, lint and 145 testsThe 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.
Pull requests are welcome. Run pnpm check before opening one, and for anything large, open an issue first so we can agree on the approach.
License
MIT
Available Tools
7 toolsbrowseBrowse rowsARead-only
Reads rows from a table, like Drizzle Studio: pick columns, filter, sort, page, and include related rows through the schema's relations. Returns rows keyed by TypeScript property, plus the total matching.
Inputs: table (required), with, limit, where, +3 more.
countCount rowsARead-only
Counts the rows in a table that match a filter. With groupBy, counts per distinct value, largest groups first: a quick way to see how data is distributed.
Inputs: table (required), where, groupBy.
driftCompare schema and databaseARead-only
Compares the Drizzle schema with the live database: tables and columns on one side only, and columns whose type or nullability differ. Use it when queries fail on columns the code expects, or after changing the schema.
Inputs: no named parameters.
explainExplain a queryARead-only
Shows the plan the database would use for a query, to check that indexes are used. With analyze on Postgres, runs the query (read-only) and reports real timings.
Inputs: sql (required), params, analyze.
migrationsMigration statusARead-only
Lists the migrations drizzle-kit generated, and whether each has been applied to the database, is pending, or was edited after it was applied.
Inputs: no named parameters.
queryRun SQLARead-only
Runs one SQL statement in a read-only transaction and returns up to 100 rows. Use $1, $2 (Postgres) or ? (SQLite) with params for values. SQL uses table and column SQL names, not TypeScript keys.
Inputs: sql (required), limit, params.
schemaDrizzle schemaARead-only
Lists the tables in the Drizzle schema with their TypeScript and SQL names, or with table, describes one: columns with types, nullability and defaults, keys, indexes, checks and relations.
Inputs: table.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool has a distinct primary role: schema introspection, row browsing, counting, raw SQL, query plans, migration status, and schema drift. There is some overlap between browse and query for reading data, and between schema and drift for schema information, but the descriptions make the intended use cases clear.
All tool names are single lowercase words with no camelCase/snake_case mixing, so the set is visually consistent. However, the names mix verbs (browse, count, query, explain) and nouns (schema, migrations, drift), so the convention is readable but not perfectly uniform.
Seven tools is well-scoped for a database/schema inspection server. Each tool covers a distinct inspection workflow without obvious redundancy.
The surface covers schema inspection, data browsing, counting, raw querying, query planning, migration status, and drift detection, which is strong for a read-only inspection server. Minor gaps might include applying migrations or richer migration details, but those may be intentionally out of scope.
Maintenance
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Explore, query, and inspect SQLite databases with ease. List tables, preview results, and view det…
Work with your database from AI tools: ask, export, approved changes, and scheduled jobs.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to query and explore databases including SQLite, PostgreSQL, MySQL, and SQL Server through a secure, read-only workflow. It provides tools for listing connections, inspecting table schemas, and executing SELECT statements directly within VS Code.1-
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to query a PostgreSQL database through a small set of controlled, read-only tools for schema inspection, row lookup, and aggregate statistics.1MIT
- AlicenseNot gradedqualityCmaintenanceEnables database governance for Drizzle ORM projects by inspecting schemas, linting migrations for unsafe operations, detecting schema drift, and explaining query plans with performance checks.MIT
- AlicenseAqualityBmaintenanceEnables AI agents and developers to introspect SQLite schemas, run sandboxed read-only queries with pagination, inspect query plans, and generate token-dense database summaries for LLM context. All operations enforce multi-layer read-only safety so databases can be explored without risk of mutation.5MIT