NestJS Drizzle MCP server for AI agents
Run the NestJS Drizzle MCP server with npx so Claude Code, Cursor or Copilot can read the package docs, and add the AGENT.md rules file to your repo.
The NestJS Drizzle MCP server ships inside @avytrix/nestjs-drizzle-crud: run npx -p @avytrix/nestjs-drizzle-crud nestjs-drizzle-crud-mcp and any MCP client (Claude Code, Cursor, Copilot, Codex, Gemini CLI and others) can list, read and search the package docs while it writes code. The package also ships a rules file, AGENT.md, with templates that load it into the file your agent reads. Neither adds a dependency to your app.
Read-only by design
The server only reads the markdown files inside its own installed package. It never connects to your database and never writes anything.
What are the server's stable facts?
| Fact | Value |
|---|---|
| Package version | 3.8.3 |
| Command (bin) | nestjs-drizzle-crud-mcp |
| Transport | stdio: JSON-RPC 2.0, one message per line |
| Runtime dependencies | zero; the server is plain Node with no MCP SDK |
| Node.js | 20 or later, like the package |
| Tools | list_docs, get_doc, search_docs |
| Documents | agent-guide (AGENT.md), readme (README.md), changelog (CHANGELOG.md) |
The server reports the installed package version in its initialize reply, so it always serves the docs for the version you run.
How do I run the MCP server?
pnpm --package=@avytrix/nestjs-drizzle-crud dlx nestjs-drizzle-crud-mcpIt starts and waits for JSON-RPC messages on stdin. You do not run it by hand day to day: your agent starts it from the config below.
How do I add it to my agent?
Register it once per project. Claude Code, Cursor, Windsurf, Gemini CLI and Cline use the same mcpServers shape:
{
"mcpServers": {
"nestjs-drizzle-crud": {
"command": "npx",
"args": ["-y", "-p", "@avytrix/nestjs-drizzle-crud", "nestjs-drizzle-crud-mcp"]
}
}
}Or add it from the CLI:
claude mcp add nestjs-drizzle-crud -- npx -y -p @avytrix/nestjs-drizzle-crud nestjs-drizzle-crud-mcpWindsurf, Gemini CLI and Cline take the same mcpServers block as Claude Code in their own MCP settings file. Zed uses a context_servers entry in its settings.json with the same command and arguments.
Which tools does the server expose?
Three, defined in src/mcp/server.ts:
| Tool | Arguments | Returns |
|---|---|---|
list_docs | none | Each document with its top-level headings. Start here. |
get_doc | doc, optional section | A whole document, or every section whose heading contains section (case-insensitive). |
search_docs | query, optional limit (default 5, max 20) | The best-matching sections across all three documents, best first, each cut to 1,500 characters. |
doc is one of agent-guide, readme or changelog. A typical agent turn is search_docs({ query: "has-many eager loading" }), then get_doc({ doc: "agent-guide", section: "Relations" }).
A tool failure, such as an unknown tool name, comes back as a result with isError: true, so the client shows it to the model instead of dropping the turn.
Which rules file does my agent read?
Copy the template that matches your tool into your project root:
cp node_modules/@avytrix/nestjs-drizzle-crud/AGENTS.template.md ./AGENTS.md # most tools
cp node_modules/@avytrix/nestjs-drizzle-crud/CLAUDE.template.md ./CLAUDE.md # Claude Code| Agent | File in your project root |
|---|---|
| OpenAI Codex, Cursor, GitHub Copilot, Zed, Cline, Windsurf, Jules | AGENTS.md |
| Claude Code | CLAUDE.md |
| Gemini CLI | GEMINI.md |
| Aider | CONVENTIONS.md, then aider --read CONVENTIONS.md |
Each template is a pointer, not a copy. Besides comments, it holds one line:
@node_modules/@avytrix/nestjs-drizzle-crud/AGENT.mdAGENT.md ships inside the package and stays the single source of truth, so an upgrade updates the rules with it. If your agent does not resolve @ imports, paste the contents of AGENT.md in place of that line, or run the MCP server so the agent fetches the guidance itself.
Using several agents on one repo? Copy the template to each filename, or keep AGENTS.md and make the others a one-line pointer to it.
What is in the rules file?
AGENT.md is written for an agent about to add an endpoint. It covers the facts agents most often get wrong:
- A service is normally an empty subclass of
SqlBaseCrudService, and the table goes inforFeature, not in the service. - Filters are objects, such as
{ age: { gte: 18 } }, andfindAllreturns{ data, total, page, limit }. - Which exception maps to which HTTP status code, and how allowlists, scope and soft delete work.
- A definition of done, so the agent stops when the endpoint is complete.
It exists to prevent the two most common mistakes: hand-writing repository code the base service already has, and injecting the database into a service.
Common questions
No. It is a bin inside nestjs-drizzle-crud with zero runtime dependencies, so installing the package is all it needs.
No. It only reads AGENT.md, README.md and CHANGELOG.md from its own installed package and answers over stdio.
stdio, with one JSON-RPC 2.0 message per line. Your MCP client starts the process and talks to it directly.
No, either works alone. The rules file loads the guidance up front; the server lets the agent look things up as it goes.
Next steps
For AI agents
The package facts condensed for code generation.
Defining services
What the agent is meant to produce.
Need a team?
Avytrix Technologies maintains this library and builds MCP servers and AI features for clients.
Test a NestJS Drizzle CRUD service
Test a NestJS Drizzle CRUD service against real SQL in memory with PGlite, or unit test it with TestCrudFactory and a Jest mock database.
nestjs-drizzle-crud vs @nestjsx/crud
nestjs-drizzle-crud vs @nestjsx/crud compared. One builds CRUD on Drizzle ORM, the other on TypeORM, with a different query syntax and release history.