by veelenga
Render and preview Mermaid diagrams with live‑reload, multiple export formats, theme support, and an integrated Claude skill for expert diagram guidance.
Claude Mermaid provides a Model Context Protocol (MCP) server that renders Mermaid diagram code, opens a live preview in a browser, and automatically refreshes the view as the source changes. It also offers one‑click export to SVG, PNG, or PDF and includes a built‑in Claude skill that suggests best‑practice diagram structures.
/plugin marketplace add veelenga/claude-mermaid
/plugin install claude-mermaid@claude-mermaid
npm install -g claude-mermaid
git clone https://github.com/veelenga/claude-mermaid.git
cd claude-mermaid
npm install && npm run build && npm install -g .
/mcp # should list "mermaid"
If installed via npm, register manually:
claude mcp add --scope user mermaid claude-mermaid
claude mcp list
mermaid_preview)
{
"tool": "mermaid_preview",
"diagram": "graph LR; A-->B",
"preview_id": "example",
"format": "svg",
"theme": "dark"
}
The browser opens at http://localhost:3737/example and updates automatically when the diagram changes.mermaid_save)
{
"tool": "mermaid_save",
"save_path": "./docs/diagram.svg",
"preview_id": "example",
"format": "svg"
}
preview_ids.~/.config/claude-mermaid/live.Q: "Cannot find package 'puppeteer'"
A: Re‑install the CLI globally (npm install -g claude-mermaid) or reinstall the Claude Code plugin.
Q: "Server not connecting"
A: Verify the binary is available (claude-mermaid -v). Re‑register the server with claude mcp add --scope user mermaid claude-mermaid and check claude mcp list.
Q: "Port already in use"
A: The server scans ports 3737‑3747 and picks a free one. Use lsof -i :3737-3747 to identify conflicting processes.
Q: "Live reload not working" A: Enable debug logging in the MCP config:
{
"mcpServers": {
"mermaid": {
"command": "claude-mermaid",
"env": { "CLAUDE_MERMAID_LOG_LEVEL": "DEBUG" }
}
}
}
Then monitor ~/.config/claude-mermaid/logs/web.log.
Q: "Permission denied on the binary"
A: Ensure the executable flag is set: chmod +x $(which claude-mermaid).
MCP server for rendering Mermaid diagrams in Claude Code with live reload functionality and a built-in skill for expert guidance.
Automatically renders diagrams in your browser with real-time updates as you refine them. Perfect for iterative diagram development and documentation workflows.

preview_id to work on multiple diagrams simultaneously~/.config/claude-mermaid/live


Plugin Install (Recommended)
In Claude Code, add the marketplace and install the plugin:
/plugin marketplace add veelenga/claude-mermaid
/plugin install claude-mermaid@claude-mermaid
Then restart Claude Code to activate the plugin.
From npm:
npm install -g claude-mermaid
From source:
git clone https://github.com/veelenga/claude-mermaid.git
cd claude-mermaid
npm install && npm run build && npm install -g .
Plugin install: The MCP server is configured automatically. Just verify:
/mcp
You should see mermaid in the MCP server list.
npm install: Configure the MCP server manually:
claude mcp add --scope user mermaid claude-mermaid
Then verify:
claude mcp list
You should see mermaid: claude-mermaid - ✓ Connected
While this server is optimized for Claude Code, it can work with any MCP-compatible client. Here's how to configure it for other popular tools:
Add to your Codex MCP settings file (~/.codex/mcp_settings.json):
{
"mcpServers": {
"mermaid": {
"command": "claude-mermaid"
}
}
}
Or configure via Codex CLI:
codex mcp add mermaid claude-mermaid
Add to your Cursor MCP config file (.cursor/mcp.json or settings):
{
"mcpServers": {
"mermaid": {
"command": "claude-mermaid"
}
}
}
Or use Cursor's settings UI:
claude-mermaidIf using the Cline extension for VSCode:
{
"mcpServers": {
"mermaid": {
"command": "claude-mermaid"
}
}
}
Add to Windsurf's MCP configuration file:
{
"mcpServers": {
"mermaid": {
"command": "claude-mermaid"
}
}
}
Configuration location varies by platform:
~/Library/Application Support/Windsurf/mcp.json~/.config/windsurf/mcp.json%APPDATA%\Windsurf\mcp.jsonAdd to Gemini CLI's MCP configuration file (~/.gemini/mcp.json):
{
"mcpServers": {
"mermaid": {
"command": "claude-mermaid"
}
}
}
Or use the Gemini CLI to configure:
gemini config mcp add mermaid --command claude-mermaid
For any MCP-compatible client, use the standard configuration:
{
"mcpServers": {
"mermaid": {
"command": "claude-mermaid"
}
}
}
The command claude-mermaid should be available in your PATH after installation.
Note: Some clients may require the full path to the executable:
which claude-mermaid (Unix/macOS) or where claude-mermaid (Windows)"command": "/path/to/claude-mermaid"Simply ask Claude Code to create Mermaid diagrams naturally. When installed as a plugin, the built-in mermaid-diagrams skill provides expert guidance, best practices, and automatic workflow management.
"Create a Mermaid diagram showing the user authentication flow"
"Draw a sequence diagram for the payment process"
"Generate a flowchart for the deployment pipeline"
With custom formatting:
"Create a dark theme architecture diagram with transparent background"
"Generate a forest theme flowchart and save to ./docs/flow.svg"
With specific output format:
"Create an ER diagram and save as PDF to ./docs/schema.pdf"
"Save the flowchart as PNG to ./docs/flow.png"
Note: Browser always shows SVG for live preview, while saving to your chosen format.
Iterative refinement:
"Create a class diagram for the User module"
// Browser opens with live preview
"Add the Address and Order classes with relationships"
// Diagram updates automatically in browser!
"Create a flowchart and save to ./docs/auth-flow.svg:
graph LR
A[User Login] --> B{Valid Credentials?}
B -->|Yes| C[Access Granted]
B -->|No| D[Access Denied]
C --> E[Dashboard]
D --> F[Try Again]
style A fill:#e1f5ff
style C fill:#d4edda
style D fill:#f8d7da
"
The diagram will be saved to ./docs/auth-flow.svg and opened in your browser with live reload enabled.
There are two tools exposed by the MCP server:
mermaid_preview — render and open a live previewdiagram (string, required) — Mermaid diagram codepreview_id (string, required) — Identifier for this preview session. Use different IDs for multiple concurrent diagrams (e.g., architecture, flow).format (string, default svg) — One of svg, png, pdf. Live preview is available only for svg.theme (string, default default) — One of default, forest, dark, neutral.background (string, default white) — Background color. Examples: transparent, white, #F0F0F0.width (number, default 800) — Diagram width in pixels.height (number, default 600) — Diagram height in pixels.scale (number, default 2) — Scale factor for higher quality output.mermaid_save — save the current live diagram to a pathsave_path (string, required) — Destination path (e.g., ./docs/diagram.svg).preview_id (string, required) — Must match the preview_id used in mermaid_preview.format (string, default svg) — One of svg, png, pdf. If the live working file for this format doesn’t exist yet, it is rendered on demand before saving.http://localhost:3737/{preview_id}The live server uses ports 3737-3747 and automatically finds an available port.
svg format only; PNG/PDF are rendered without live reload.style directives inside sequenceDiagram.# Install dependencies
npm install
# Build the project
npm run build
# Run tests
npm test
# Watch mode for development
npm run dev
# Start the MCP server directly
npm start
Error: Cannot find package 'puppeteer':
This is a rare environment-specific issue. Try these solutions:
Install claude-mermaid globally:
npm install -g claude-mermaid
Reinstall the plugin in Claude Code:
/plugin uninstall claude-mermaid
/plugin install claude-mermaid@claude-mermaid
Server not connecting:
# Check if server is installed
claude-mermaid -v
# Reinstall if needed
npm install -g claude-mermaid
# Verify MCP configuration
claude mcp list
Permission denied error:
# Make sure the binary is executable
chmod +x $(which claude-mermaid)
Port already in use:
lsof -i :3737-3747Diagrams not rendering or live reload not working:
The server logs to ~/.config/claude-mermaid/logs/:
mcp.log - Tool requests and diagram renderingweb.log - HTTP/WebSocket connections and live reloadEnable debug logging in your MCP config:
{
"mcpServers": {
"mermaid": {
"command": "claude-mermaid",
"env": {
"CLAUDE_MERMAID_LOG_LEVEL": "DEBUG"
}
}
}
}
Then check the logs:
# View MCP operations
tail -f ~/.config/claude-mermaid/logs/mcp.log
# View WebSocket connections
tail -f ~/.config/claude-mermaid/logs/web.log
Available log levels: DEBUG, INFO (default), WARN, ERROR, OFF
Contributions are welcome! Please feel free to submit a Pull Request.
MIT - see LICENSE file for details
Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by modelcontextprotocol
A Model Context Protocol server for Git repository interaction and automation.
by zed-industries
A high‑performance, multiplayer code editor designed for speed and collaboration.
by modelcontextprotocol
Model Context Protocol Servers
by modelcontextprotocol
A Model Context Protocol server that provides time and timezone conversion capabilities.
by cline
An autonomous coding assistant that can create and edit files, execute terminal commands, and interact with a browser directly from your IDE, operating step‑by‑step with explicit user permission.
by upstash
Provides up-to-date, version‑specific library documentation and code examples directly inside LLM prompts, eliminating outdated information and hallucinated APIs.
by daytonaio
Provides a secure, elastic infrastructure that creates isolated sandboxes for running AI‑generated code with sub‑90 ms startup, unlimited persistence, and OCI/Docker compatibility.
by continuedev
Enables faster shipping of code by integrating continuous AI agents across IDEs, terminals, and CI pipelines, offering chat, edit, autocomplete, and customizable agent workflows.
by github
Connects AI tools directly to GitHub, enabling natural‑language interactions for repository browsing, issue and pull‑request management, CI/CD monitoring, code‑security analysis, and team collaboration.
{
"mcpServers": {
"mermaid": {
"command": "npx",
"args": [
"-y",
"claude-mermaid"
],
"env": {}
}
}
}claude mcp add mermaid npx -y claude-mermaid