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 "Install 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., "@erdlensgenerate 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.
| Name | Required | Description | Default |
|---|---|---|---|
| doc_path | Yes | The .mmd or .md file that contains the current diagram. | |
| schema_path | Yes | The current schema source to compare against. | |
| schema_type | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Describes output as reporting added/removed tables/columns/relations. Does not specify output format or permissions, but implies read-only behavior. Lacks explicit side-effect disclosure (safe).
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences: first defines functionality and inputs, second gives usage advice. No redundant words, highly efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Covers input types, output type (additions/removals), and usage scenario. Lacks output format details and error handling, but sufficient for its simplicity.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema covers 67% of params with descriptions. Description adds context for doc_path and schema_path (file containing diagram vs schema source). Schema_type enum values not described, but enum limits choices. Adequate but not enhanced.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Clearly states the tool checks ERD drift between a doc and current schema, specifying file types (.mmd, .md with mermaid) and reporting additions/removals. Distinguishes from sibling tools (render, convert) by focusing on verification.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Provides explicit usage context: 'Use this in CI or before shipping docs.' Implicitly guides away from render/convert tasks. Could be improved by stating when not to use (e.g., for non-ERD content).
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| out_path | Yes | Where to write the .mmd file, e.g. docs/erd.mmd | |
| source_path | No | ||
| source_text | No | ||
| source_type | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the burden. It discloses the three output files and the write action, but does not mention side effects like overwrite behavior or error handling. The mutation is clear, but additional details would improve transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence that conveys key information efficiently. It is front-loaded with the core action, and every part adds value. Could be slightly more structured by listing outputs separately, but overall concise.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given 4 parameters, no output schema, and no annotations, the description is incomplete. It focuses on the output files but fails to explain how to specify the input schema (source_path, source_text, source_type) or expected return values, leaving significant gaps.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is only 25% (only out_path described). The description does not explain other parameters (source_path, source_text, source_type) nor the enum options, failing to compensate for the schema gaps.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'Generate a Mermaid ERD' and the resource 'from a schema', and specifies the write-to-disk action. It distinguishes from siblings by emphasizing the file output side effect, but does not explicitly differentiate from the sibling 'schema_to_erd' which might just return text.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides context by noting the output is for embedding without copy-paste, implying a specific use case. However, it does not mention when to avoid this tool or suggest alternatives like siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| out_path | Yes | Where to write the .mmd, e.g. docs/workflow.mmd | |
| direction | No | ||
| source_path | No | ||
| source_text | No | ||
| source_type | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description bears full burden. It discloses that multiple files (.mmd, .md, .html) are written to disk, but does not detail side effects (e.g., overwriting), idempotency, or permission requirements.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence that conveys essential information without fluff. It could be improved by adding a brief note on parameter usage, but it is appropriately sized.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given 5 parameters, low schema coverage, and no output schema, the description lacks completeness. It does not explain how source parameters interact, the purpose of direction, or what the generated .md and .html files contain.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is only 20%, yet the description adds no additional meaning to parameters beyond what the schema provides. It does not explain direction, source_path, source_text, or source_type, failing to compensate for the low coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb (generate and write) and resource (Mermaid flowchart from workflow spec). It explicitly distinguishes from sibling tool render_erd by noting it is for workflows/pipelines.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides a clear sibling reference ('Same as render_erd but for workflows/pipelines'), indicating when to use this tool vs an alternative. However, it lacks explicit when-not-to-use or prerequisite guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| source_path | No | Path to a schema file (.sql, schema.prisma, *.ts, models.py). | |
| source_text | No | Schema source as text (alternative to source_path). | |
| source_type | No | Defaults to auto-detect. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description fully carries the transparency burden. It clearly states the tool is read-only (converts input to output) and details the output format. It does not cover error handling or limitations, but for a simple conversion tool, the level of disclosure is adequate.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, zero waste. The first sentence states the purpose, the second covers input options and output format. Information is front-loaded and efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with 3 parameters and no output schema, the description covers the core purpose, input formats, and output. Missing details like behavior when both source_path and source_text are provided, or error handling for invalid schemas, but overall it's sufficient for typical usage.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, setting baseline to 3. The description adds value by explaining the relationship between source_path and source_text as alternative inputs, and listing the supported schema formats, which goes beyond the schema's individual parameter descriptions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool converts a database schema to a Mermaid erDiagram, with specific input formats. However, it does not explicitly differentiate from sibling tools like render_erd, which might have overlapping functionality.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage (when you have a schema and need an ERD diagram) but provides no explicit guidance on when to use this tool versus siblings like render_erd or drift_check, and no when-not-to-use or alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| direction | No | ||
| source_path | No | ||
| source_text | No | ||
| source_type | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description discloses the output format but does not mention side effects, error handling, input size limits, or permissions needed. With no annotations, more detail on behavioral traits (e.g., pure conversion, no side effects) would improve transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise (two sentences), front-loads the purpose, and covers essential input/output without any fluff. Every sentence adds value.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with 4 parameters and no output schema, the description explains the return value well but omits explanation of source_path vs source_text and direction. It is slightly incomplete given the parameter count, though the tool's simplicity partially mitigates this.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, so the description must compensate. It explains that the tool accepts DSL or JSON but does not map these to parameters (source_text vs source_path, source_type). Direction and source_path are not explained. The description adds partial meaning but insufficiently clarifies all four parameters.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it converts a workflow spec into a Mermaid flowchart and specifies input formats (DSL or JSON) and output (Mermaid source with fenced block). It distinguishes from sibling tools through specific input/output details, though explicit differentiation from 'render_workflow' is missing.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this tool vs alternatives (e.g., render_workflow) or when not to use it. The description lacks context about prerequisites or trade-offs, leaving the agent to infer usage without direction.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
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
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
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.
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.12MIT
- FlicenseNot gradedqualityDmaintenanceMCP server that generates Mermaid diagrams with live browser preview, supports real-time rendering and SVG/PNG export.12
- FlicenseAqualityCmaintenanceA local MCP server that renders a database schema as an interactive, dbdiagram.io-style ER diagram in your browser.2
- AlicenseBqualityBmaintenanceMCP 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
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ryanda9910/erdlens'
If you have feedback or need assistance with the MCP directory API, please join our Discord server