High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph โ average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.
MCP server for Mermaid preview in Claude Code
This repo connects an agent to Mermaid rendering through MCP, then opens a browser preview that updates as the diagram changes. It supports saving to SVG, PNG, or PDF, and it can run as a standalone preview server too.

Builders who want their agent to create and refine Mermaid diagrams with a live browser preview.
You can iterate on diagrams without re-rendering by hand or leaving your agent workflow.
What it does
Live reload preview
Renders Mermaid diagrams in a browser and refreshes them as the source changes.
Multiple export formats
Saves diagrams as SVG, PNG, or PDF.
Theme and layout controls
Lets you set theme, width, height, scale, and background color.
Multiple concurrent previews
Uses `preview_id` so you can work on more than one diagram at a time.
Built-in Claude skill
Includes `skills/mermaid-diagrams` with guidance for creating diagrams.
Standalone preview server
Runs with `claude-mermaid --serve` to browse previously rendered diagrams outside an agent session.
How to get it
- 1In Claude Code, add the marketplace and install the plugin
/plugin marketplace add veelenga/claude-mermaid /plugin install claude-mermaid@claude-mermaid
- 2From npm
npm install -g claude-mermaid
- 3From source
git clone https://github.com/veelenga/claude-mermaid.git cd claude-mermaid npm install && npm run build && npm install -g .
- 4Plugin install: The MCP server is configured automatically. Just verify
/mcp
- 5npm install: Configure the MCP server manually
claude mcp add --scope user mermaid claude-mermaid
- 6Then verify
claude mcp list
README
Claude Mermaid MCP Server
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.

โจ Features
- ๐ Live Reload - Diagrams auto-refresh in your browser as you edit
- ๐จ Multiple Save Formats - Export to SVG, PNG, or PDF
- ๐ Themes - Choose from default, forest, dark, or neutral themes
- ๐ Customizable - Control dimensions, scale, and background colors
- ๐ช Interactive Preview - Pan diagrams by dragging, zoom with browser controls, reset position with one click
- โฌ๏ธ Browser Export - Download diagrams as SVG or PNG directly from the preview
- ๐๏ธ Multiple Previews - Use
preview_idto work on multiple diagrams simultaneously - ๐พ Persistent Working Files - Live previews are stored under
~/.config/claude-mermaid/live - ๐ค Built-in Skill - Includes a Claude skill with best practices and expert guidance for creating diagrams
Architecture
Project Architecture Diagram

User Workflow Diagram

Dependencies Diagram

๐ Quick Start
1. Install
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 .
2. Verify Installation
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
๐ Other MCP Client Configurations
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:
Codex
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
Cursor
Add to your Cursor MCP config file (.cursor/mcp.json or settings):
{
"mcpServers": {
"mermaid": {
"command": "claude-mermaid"
}
}
}
Or use Cursor's settings UI:
- Open Cursor Settings (Cmd/Ctrl + ,)
- Navigate to MCP Servers
- Add a new server with command:
claude-mermaid
VSCode with Cline Extension
If using the Cline extension for VSCode:
- Open VSCode settings (Cmd/Ctrl + ,)
- Search for "Cline MCP"
- Add to MCP Settings JSON:
{
"mcpServers": {
"mermaid": {
"command": "claude-mermaid"
}
}
}
Windsurf
Add to Windsurf's MCP configuration file:
{
"mcpServers": {
"mermaid": {
"command": "claude-mermaid"
}
}
}
Configuration location varies by platform:
- macOS:
~/Library/Application Support/Windsurf/mcp.json - Linux:
~/.config/windsurf/mcp.json - Windows:
%APPDATA%\Windsurf\mcp.json
Gemini CLI
Add 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
Other MCP Clients
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:
- Find the path:
which claude-mermaid(Unix/macOS) orwhere claude-mermaid(Windows) - Use absolute path in config:
"command": "/path/to/claude-mermaid"
๐ก Usage
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.
Basic Examples
"Create a Mermaid diagram showing the user authentication flow"
"Draw a sequence diagram for the payment process"
"Generate a flowchart for the deployment pipeline"
Advanced Examples
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!
Complete Example
"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.
๐ง Tools and Parameters
There are two tools exposed by the MCP server:
mermaid_previewโ render and open a live preview
diagram(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, defaultsvg) โ One ofsvg,png,pdf. Live preview is available only forsvg.theme(string, defaultdefault) โ One ofdefault,forest,dark,neutral.background(string, defaultwhite) โ Background color. Examples:transparent,white,#F0F0F0.width(number, default800) โ Diagram width in pixels.height(number, default600) โ Diagram height in pixels.scale(number, default2) โ Scale factor for higher quality output.
mermaid_saveโ save the current live diagram to a path
save_path(string, required) โ Destination path (e.g.,./docs/diagram.svg).preview_id(string, required) โ Must match thepreview_idused inmermaid_preview.format(string, defaultsvg) โ One ofsvg,png,pdf. If the live working file for this format doesnโt exist yet, it is rendered on demand before saving.
๐ฏ How Live Reload Works
- First render: Opens diagram in browser at
http://localhost:3737/{preview_id} - Make changes: Edit the diagram through Claude Code
- Auto-refresh: Browser detects changes via WebSocket and reloads
- Status indicator: Green dot = connected, Red dot = reconnecting
The live server uses ports 3737-3747 and automatically finds an available port.
Live Preview Controls
- Pan: Click and drag the diagram to move it around
- Zoom: Use browser zoom (Ctrl/Cmd + +/- or pinch-to-zoom on trackpad)
- Reset Position: Click the โ button in the status bar to recenter the diagram
- Export: Click the โฌ button to download as SVG or PNG
Notes
- Live preview is available for
svgformat only; PNG/PDF are rendered without live reload. - For sequence diagrams, Mermaid does not support
styledirectives insidesequenceDiagram.
๐ฅ๏ธ Standalone server
You can start the preview server without an AI agent using the --serve flag:
claude-mermaid --serve
This opens the diagram gallery in your browser with all previously rendered diagrams. Useful for browsing and exporting diagrams outside of a Claude Code session.
๐ ๏ธ Development
# 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
๐ Troubleshooting
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:
- The server uses ports 3737-3747
- It will automatically find an available port
- Check if another process is using these ports:
lsof -i :3737-3747
Diagrams 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 reload
Enable 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
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ License
MIT - see LICENSE file for details
๐ Links
๐ See Also
If you like this project, you might also be interested in
- preview-skills โ preview skills for visualizing files in the browser (markdown, csv, json, mermaid and more)
Hosted deployment
A hosted deployment is available on Fronteir AI.
Files in the repo
- .claude-plugin
- .github
- assets
- docs
- skills
- src
- test
- .gitignore
- .mcp.json
- .npmignore
- .prettierignore
- .prettierrc
- CHANGELOG.md
- LICENSE
- package-lock.json
- package.json
- README.md
- start-server.js
- tsconfig.json
- vitest.config.ts
Discussion (0)
Ask about usage, or say what you built with itSign in to join the discussion.
No comments yet. Be the first to say what this is good for.
More connectors

Universal provider proxy for OpenAI Codex & Claude Code โ use any LLM (Claude, Gemini, Grok, DeepSeek, Ollamaโฆ) with Codex CLI, App, SDK, and Claude Code
Git-native persistent memory for AI coding agents. Implements Google OKF v0.2 with sub-300ยตs in-memory BM25 search, embedded MCP server, and progressive disclosure. Slashes token bloat by 80% with zero external databases or dependencies. Built in pure Go.
Local-first code intelligence graph for MCP and CLI. Builds a persistent map of your codebase so AI coding tools read only what matters, with benchmarked context reductions on reviews and large-repo workflows.
Stop your AI from making things up โ it proposes, deterministic tools decide, every claim checked against ground truth with evidence. Grounded facts and context survive resets. Reverse engineering is the proving ground. MCP server + CLI.
20 MB lightweight cross-platform database client for 90+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | ่ฝป้็บง่ทจๅนณๅฐๆฐๆฎๅบ็ฎก็ๅทฅๅ ท๏ผๆฏๆ MySQLใPostgreSQLใSQLiteใRedisใMongoDBใ่พพๆขฆ็ญ 90+ ๆฐๆฎๅบ๏ผๆไพๆก้ข็ซฏใDockerใCLIใๅ ็ฝฎ AI ๅฉๆๅ MCP Serverใ