Provides access to Mermaid diagram syntax documentation and validation tools, enabling search through official syntax docs for various diagram types (flowchart, sequence, class, C4, etc.) and validation of Mermaid diagram code before rendering.
Mermaid MCP Server
Model Context Protocol server that bundles the official Mermaid syntax docs and a syntax validator so agents can search, quote, and check diagrams before sending them to users.
What It Does
Serves Mermaid syntax Markdown as MCP resources (flowchart, sequence, class, C4, etc.) plus a
guideprompt for quick routing.search_mermaid_docsfinds sections in the bundled docs (mermaid/docs/syntax) with optional diagram filtering and snippet/full modes. Results come from a startup cache for speed.validate_mermaidrunsmermaid.parseto flag syntax issues; DOM-related errors are treated as pass-through so headless environments still work.
Architecture
Install & Run
Clone (includes Mermaid submodule):
git clone --recurse-submodules <repo-url>or, if already cloned:
git submodule update --init --recursive
Prereq: Node 18+
Install:
npm installBuild:
npm run buildStart (STDIO for MCP clients):
npm run start:stdioStart (HTTP for testing):
npm run start:http(health at/health, MCP endpoint at/mcp)
MCP Client Wiring (STDIO)
Agent Usage Tips
Always search first:
search_mermaid_docswith a single-term query (e.g.,flowchart,subgraph,arrow); usediagram_typeto narrow by file;mode: "full"returns entire docs.Always validate after editing:
validate_mermaidon the final diagram string.Use the
guideprompt for quick diagram-type routing and common pitfalls.
Tests
Run unit tests:
npm test
Project Layout
src/server.ts– MCP server, resources, tools, docs cachesrc/httpServer.ts– Express HTTP wrapper for/mcpguides/–guide.mdprompt and configmermaid/docs/syntax/– Bundled official Mermaid syntax Markdowndist/– Built JS output