erdlens

erdlens

MCP server that reads your database schema from SQL DDL, Prisma, Drizzle, TypeORM, or SQLAlchemy, generates a Mermaid ER diagram, and writes it into your documentation, with drift detection to keep diagrams up-to-date.

Category
访问服务器

README

<p align="center"> <img src="assets/logo.svg" alt="erdlens" width="96" height="96" /> </p>

<h1 align="center">erdlens</h1>

<p align="center"><b>Your schema becomes an ER diagram, straight into your docs. And it tells you when the diagram goes stale.</b></p>

<p align="center"> 🇺🇸 English · <a href="README.id.md">🇮🇩 Bahasa Indonesia</a> · <a href="README.zh-CN.md">🇨🇳 简体中文</a> </p>

<p align="center"> <img alt="license" src="https://img.shields.io/badge/license-MIT-6C8EEF" /> <img alt="runtime deps" src="https://img.shields.io/badge/runtime%20deps-0-6C8EEF" /> <img alt="tests" src="https://img.shields.io/badge/tests-57%20passing-6C8EEF" /> <img alt="mcp" src="https://img.shields.io/badge/MCP-server-6C8EEF" /> <img alt="typescript" src="https://img.shields.io/badge/TypeScript-MVVM-6C8EEF" /> </p>

<p align="center"> <img src="assets/showcase.gif" alt="erdlens turning a schema into an ER diagram, a workflow into a flowchart, and catching drift after a migration" width="720" /> </p>


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.

Install (Claude Code)

claude mcp add erdlens -- npx -y github:ryanda9910/erdlens

Or point at a local clone:

git clone https://github.com/ryanda9910/erdlens
claude mcp add erdlens -- node /abs/path/to/erdlens/bin/erdlens.js

Then 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_to_erd schema (path or text) → Mermaid erDiagram + a ```mermaid fenced block to paste anywhere
render_erd writes the ERD to disk: .mmd source, an embeddable .md, and a self-contained .html preview — so it goes straight into a doc, no copy-paste
drift_check compares an ERD already in a .mmd/.md against the current schema, and reports every table, column, and relation added or removed since. Run it in CI so a stale diagram fails the build
workflow_to_diagram a workflow spec (a tiny text DSL or JSON steps) → Mermaid flowchart + fenced block. Document a process, pipeline, or state machine next to the ERD
render_workflow same as render_erd, for workflows — writes the flowchart to disk, embeddable

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 -> done
erdlens flow publish.flow
flowchart TD
  start(["start"])
  ...
  review -->|approved| publish
  review -->|changes| draft

Ask 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 stdio

There'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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选