erdlens
Reads Drizzle ORM schema files to generate Entity-Relationship diagrams and detect drift between the schema and existing diagrams.
Reads Prisma schema files to generate Entity-Relationship diagrams and detect drift between the schema and existing diagrams.
Reads SQLAlchemy model definitions to generate Entity-Relationship diagrams and detect drift between the schema and existing diagrams.
Reads TypeORM entity definitions to generate Entity-Relationship diagrams and detect drift between the schema and existing diagrams.
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., "@erdlens generate ER diagram from prisma/schema.prisma and save to docs/schema.md"
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.
You ask Claude Code to document your database. It writes the doc, you generate an ER diagram in some other tool, then you copy-paste the diagram back in. Two tools, double work, and the moment someone runs a migration the diagram in the doc is quietly wrong.
erdlens is an MCP server that closes that loop. Claude Code reads your schema, turns it into a Mermaid ER diagram, and writes it into the document in one pass. No second tool, no copy-paste. And it can check later whether that diagram still matches the schema.
Why it's different
The existing diagram MCP servers render Mermaid you already wrote. erdlens starts a step earlier: it reads the schema for you, and a step later: it watches for drift.
render your Mermaid | read the schema | write into the doc | drift-check | |
mermaid-preview MCPs | ✅ | ❌ | partial | ❌ |
mermerd (CLI, not MCP) | ❌ | ✅ (DB only) | ❌ | ❌ |
erdlens | ✅ | ✅ (5 sources) | ✅ | ✅ |
Schema sources: SQL DDL, Prisma, Drizzle, TypeORM, SQLAlchemy — file or text, auto-detected.
Related MCP server: mermaid-live-mcp
Install (Claude Code)
claude mcp add erdlens -- npx -y github:ryanda9910/erdlensOr point at a local clone:
git clone https://github.com/ryanda9910/erdlens
claude mcp add erdlens -- node /abs/path/to/erdlens/bin/erdlens.jsThen just ask Claude Code: "document the database and put an ER diagram in docs/schema.md". It calls
render_erd and the diagram lands in the file.
Tools
tool | what it does |
| schema (path or text) → Mermaid |
| writes the ERD to disk: |
| compares an ERD already in a |
| a workflow spec (a tiny text DSL or JSON steps) → Mermaid |
| same as |
The drift check
This is the part that keeps docs honest. After a migration:
$ erdlens drift docs/schema.md db/schema.sql
Diagram is stale. It drifted from the current schema:
+ tables added since: audit_logs
~ posts: +published +slug
+ relations added: posts->users
Regenerate with render_erd to fix.Exit code is non-zero when stale, so it drops into a CI step or a pre-commit hook.
Workflows too
Not just data. Give it a workflow and it draws the flowchart — same "into your docs" path.
# publish.flow
start -> draft
draft -> review
review -> publish : approved
review -> draft : changes
publish -> doneerdlens flow publish.flowflowchart TD
start(["start"])
...
review -->|approved| publish
review -->|changes| draftAsk Claude Code "put the publish workflow in docs/flow.md" and it calls render_workflow.
Also a CLI
Without an MCP client:
erdlens erd db/schema.sql # print the Mermaid ERD
erdlens erd prisma/schema.prisma # auto-detects Prisma
erdlens flow pipeline.flow # print a Mermaid flowchart
erdlens drift docs/erd.mmd db/schema.sql # exit 1 if drifted
erdlens tune # run the self-check loop (below)Self-improving loop
erdlens tune is a maker → checker → reflect loop: it runs every parser on a fixture plus a drift
scenario (maker), an independent grader flags anything that passed before and fails now (checker),
and it persists per-source pass state to ~/.erdlens/memory.json (reflect). It's how the parsers stay
honest as new schema dialects get added — a regression surfaces instead of slipping through.
Tests
npm test # builds, then 57 assertions: 24 schema engine + 14 workflow + 19 MCP stdioThere's also an end-to-end script that drives the whole thing through a real Claude Code run
(bash test/e2e.sh, needs the claude CLI logged in).
How it's built
TypeScript, laid out MVVM:
Model (
src/model/) — pure logic: schema parsers, workflow parser, drift diff, types.ViewModel (
src/viewmodel/) — orchestration: the tool operations and the self-improving loop.View (
src/view/) — surfaces: the JSON-RPC MCP server, the CLI, and Mermaid/HTML rendering.
Zero runtime dependencies. The MCP server is a from-scratch JSON-RPC stdio implementation; the HTML preview loads Mermaid from a CDN only when you open it in a browser.
License
MIT
Available Tools
5 toolsdrift_checkA
Check whether an ERD embedded in a doc (a .mmd file or a markdown file with a ```mermaid erDiagram block) still matches the current schema. Reports tables/columns/relations added or removed since the diagram was written. Use this in CI or before shipping docs.
Inputs: doc_path (required), schema_path (required), schema_type.
render_erdB
Generate a Mermaid ERD from a schema and WRITE it to disk so it can be embedded directly in a document with no copy-paste. Writes out_path (.mmd), a sibling .md with the fenced block, and a self-contained .html preview.
Inputs: out_path (required), source_path, source_text, source_type.
render_workflowA
Generate a Mermaid flowchart from a workflow spec and WRITE it to disk (.mmd + embeddable .md + .html preview). Same as render_erd but for workflows/pipelines.
Inputs: out_path (required), direction, source_path, source_text, +1 more.
schema_to_erdA
Turn a database schema into a Mermaid erDiagram. Accepts SQL DDL, Prisma, Drizzle, TypeORM, or SQLAlchemy — pass a file path or the text directly. Returns the Mermaid source plus a ```mermaid fenced block you can paste straight into markdown.
Inputs: source_path, source_text, source_type.
workflow_to_diagramB
Turn a workflow spec into a Mermaid flowchart. Accepts a tiny text DSL (a -> b, a -> b : label, chains, ? decisions, start/end) or a JSON array of steps. Returns the Mermaid source + a ```mermaid fenced block.
Inputs: direction, source_path, source_text, source_type.
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 clear, distinct purpose: drift_check verifies consistency, schema_to_erd generates ERD source, render_erd writes ERD to disk, workflow_to_diagram generates workflow source, and render_workflow writes workflow to disk. No overlap or ambiguity.
All tool names follow a consistent verb_noun pattern with lowercase and underscores: drift_check, render_erd, render_workflow, schema_to_erd, workflow_to_diagram. No mixing of conventions.
Five tools is an ideal size for this specialized server—enough to cover core functionality without bloat. Each tool serves a necessary role in the diagram generation and verification workflow.
The tool set covers full lifecycle for both ERDs and workflows: generation (source and disk) and consistency checking. No obvious missing operations for the stated purpose.
Maintenance
Related MCP Connectors
Monitor MCP servers, API contracts and AI outputs for schema drift. Alerts on breaking changes.
Render, verify, describe, and safely edit Mermaid diagrams through MCP.
Hosted MCP server for AI-driven data ops. Create apps, manage schemas, and CRUD structured data.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables AI assistants to programmatically create and manage flowcharts, ERDs, and swimlane diagrams. It provides tools for manipulating diagram structures, performing auto-layouts, and exporting to Mermaid or Markdown formats.23 npmMIT
- FlicenseNot gradedqualityDmaintenanceMCP server that generates Mermaid diagrams with live browser preview, supports real-time rendering and SVG/PNG export.13-
- FlicenseAqualityDmaintenanceA local MCP server that renders a database schema as an interactive, dbdiagram.io-style ER diagram in your browser.2-
- AlicenseBqualityCmaintenanceMCP server for Sqemo, a web-based ERD tool with team naming standards. 34 tools: read/edit entities, attributes, and relationships; generate physical names from a shared glossary and naming rules; SQL (7 dialects) and DBML import/export; ERD lint, diff, and ALTER generation.36MIT