Mermaid logo

Mermaid

Community
veelenga

MCP Server to previewing mermaid diagrams with live reload

Publisherveelenga
Repositoryclaude-mermaid
LanguageTypeScript
Forks
18
Stars
145
Available tools
0
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    Mermaid exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    145 stars and 18 forks from the linked repository.

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.

Demo

✨ 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_id to 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

Architecture Diagram

User Workflow Diagram

Dependencies Diagram

πŸš€ Quick Start

1. Install

Plugin Install (Recommended)

In Claude Code, add the marketplace and install the plugin:

bash
/plugin marketplace add veelenga/claude-mermaid
/plugin install claude-mermaid@claude-mermaid

Then restart Claude Code to activate the plugin.

From npm:

bash
npm install -g claude-mermaid

From source:

bash
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:

bash
/mcp

You should see mermaid in the MCP server list.

npm install: Configure the MCP server manually:

bash
claude mcp add --scope user mermaid claude-mermaid

Then verify:

bash
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:

Add to your Codex MCP settings file (~/.codex/mcp_settings.json):

json
{
  "mcpServers": {
    "mermaid": {
      "command": "claude-mermaid"
    }
  }
}

Or configure via Codex CLI:

bash
codex mcp add mermaid claude-mermaid

Add to your Cursor MCP config file (.cursor/mcp.json or settings):

json
{
  "mcpServers": {
    "mermaid": {
      "command": "claude-mermaid"
    }
  }
}

Or use Cursor's settings UI:

  1. Open Cursor Settings (Cmd/Ctrl + ,)
  2. Navigate to MCP Servers
  3. Add a new server with command: claude-mermaid

If using the Cline extension for VSCode:

  1. Open VSCode settings (Cmd/Ctrl + ,)
  2. Search for "Cline MCP"
  3. Add to MCP Settings JSON:
json
{
  "mcpServers": {
    "mermaid": {
      "command": "claude-mermaid"
    }
  }
}

Add to Windsurf's MCP configuration file:

json
{
  "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

Add to Gemini CLI's MCP configuration file (~/.gemini/mcp.json):

json
{
  "mcpServers": {
    "mermaid": {
      "command": "claude-mermaid"
    }
  }
}

Or use the Gemini CLI to configure:

bash
gemini config mcp add mermaid --command claude-mermaid

For any MCP-compatible client, use the standard configuration:

json
{
  "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) or where 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:

  1. mermaid_preview β€” render and open a live preview
  • diagram (string, required) β€” Mermaid diagram code
  • preview_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.
  1. 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 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.

🎯 How Live Reload Works

  1. First render: Opens diagram in browser at http://localhost:3737/{preview_id}
  2. Make changes: Edit the diagram through Claude Code
  3. Auto-refresh: Browser detects changes via WebSocket and reloads
  4. 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 svg format only; PNG/PDF are rendered without live reload.
  • For sequence diagrams, Mermaid does not support style directives inside sequenceDiagram.

πŸ–₯️ Standalone server

You can start the preview server without an AI agent using the --serve flag:

bash
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

bash
# 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:

  1. Install claude-mermaid globally:

    bash
    npm install -g claude-mermaid
  2. Reinstall the plugin in Claude Code:

    /plugin uninstall claude-mermaid
    /plugin install claude-mermaid@claude-mermaid

Server not connecting:

bash
# 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:

bash
# 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 rendering
  • web.log - HTTP/WebSocket connections and live reload

Enable debug logging in your MCP config:

json
{
  "mcpServers": {
    "mermaid": {
      "command": "claude-mermaid",
      "env": {
        "CLAUDE_MERMAID_LOG_LEVEL": "DEBUG"
      }
    }
  }
}

Then check the logs:

bash
# 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.

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "mermaid": {
      "command": "claude-mermaid",
      "args": []
    }
  }
}

Use Mermaid MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Mermaid is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Mermaid as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Mermaid MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "mermaid": {
      "command": "npx",
      "args": [
        "-y",
        "claude-mermaid"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Mermaid MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Mermaid MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Mermaid to help me with this task?
Mermaid
Sure. I read it.
Here is what I found using Mermaid.

Frequently asked questions

What is the Mermaid MCP server used for?

Mermaid is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Mermaid MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Mermaid with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Mermaid MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Mermaid connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Mermaid MCP to TypingMind?

Mermaid runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Mermaid MCP provide in TypingMind?

Mermaid exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Mermaid MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Mermaid requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter πŸ‘‡