/ Directory / Playground / mcp-mermaid
● Community hustcc ⚡ Instant

mcp-mermaid

by hustcc · hustcc/mcp-mermaid

Generate validated Mermaid diagrams and charts — SVG, PNG, or hosted URL — right from chat. No separate renderer needed.

mcp-mermaid generates Mermaid diagrams dynamically and returns them as base64, SVG text, saved file, or hosted URL. Includes syntax validation and multi-round correction so malformed Mermaid gets fixed automatically. Also supports infographics (timeline, comparison, process).

Why use it

Key features

Live Demo

What it looks like in practice

mermaid.replay ▶ ready
0/0

Install

Pick your client

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "mermaid": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mermaid"
      ],
      "_inferred": true
    }
  }
}

Open Claude Desktop → Settings → Developer → Edit Config. Restart after saving.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "mermaid": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mermaid"
      ],
      "_inferred": true
    }
  }
}

Cursor uses the same mcpServers schema as Claude Desktop. Project config wins over global.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "mermaid": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mermaid"
      ],
      "_inferred": true
    }
  }
}

Click the MCP Servers icon in the Cline sidebar, then "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "mermaid": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mermaid"
      ],
      "_inferred": true
    }
  }
}

Same shape as Claude Desktop. Restart Windsurf to pick up changes.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "mermaid",
      "command": "npx",
      "args": [
        "-y",
        "mcp-mermaid"
      ]
    }
  ]
}

Continue uses an array of server objects rather than a map.

~/.config/zed/settings.json
{
  "context_servers": {
    "mermaid": {
      "command": {
        "path": "npx",
        "args": [
          "-y",
          "mcp-mermaid"
        ]
      }
    }
  }
}

Add to context_servers. Zed hot-reloads on save.

claude mcp add mermaid -- npx -y mcp-mermaid

One-liner. Verify with claude mcp list. Remove with claude mcp remove.

Use Cases

Real-world ways to use mcp-mermaid

Generate a system architecture diagram from prose

👤 Engineers writing design docs ⏱ ~10 min beginner

When to use: You've described an architecture in a doc and want a diagram without leaving chat.

Prerequisites
  • mcp-mermaid installed — npx -y mcp-mermaid in your MCP client config
Flow
  1. Describe the system
    Here's my architecture: Cloudflare → API (Node) → Postgres + Redis → Worker (Go). Generate a Mermaid flowchart showing this.✓ Copied
    → Valid Mermaid source rendered as SVG
  2. Iterate on styling
    Make Cloudflare blue, Postgres green, Redis red. Use dashed edges for async.✓ Copied
    → Revised diagram
  3. Save to file
    Output as PNG file at ./docs/arch.png with white background.✓ Copied
    → File on disk

Outcome: An architecture PNG you can drop into the design doc.

Pitfalls
  • Very complex diagrams hit Mermaid's layout limits — Break into multiple diagrams, or switch to subgraph grouping
  • Theme colors don't match your doc — Pass theme config explicitly rather than relying on defaults
Combine with: filesystem

Draft a sequence diagram in a bug report

👤 Engineers filing tricky race-condition bugs ⏱ ~5 min beginner

When to use: Prose description of who calls whom when is hard to read.

Flow
  1. Describe the sequence
    Client sends POST, API starts transaction, writes to DB, crashes before commit. Meanwhile a retry comes in from the client. Draw a sequence diagram.✓ Copied
    → Clear sequence with parallel lifelines
  2. Inline into issue
    Give me the Mermaid source so I can paste into a GitHub issue (which renders Mermaid natively).✓ Copied
    → Source ready to paste

Outcome: A bug report reviewers can grok in 10 seconds.

Combine with: github

Generate a project Gantt from a timeline

👤 Project leads who don't want to pay for gantt software for a one-off ⏱ ~5 min beginner

When to use: Ad-hoc timeline for a PRD or kickoff.

Flow
  1. List phases
    Phases: Discovery (2 weeks), Design (3 weeks), Implementation (6 weeks), QA (2 weeks overlap with impl last 2 weeks). Starting 2026-05-01. Make a gantt.✓ Copied
    → Valid Gantt source
  2. Output PNG
    Save as PNG and also give me the URL I can embed in the PRD.✓ Copied
    → PNG path + hosted URL

Outcome: A timeline graphic for your PRD in under a minute.

Combinations

Pair with other MCPs for X10 leverage

mermaid + filesystem

Save generated diagrams as versioned assets

Generate architecture diagram v2 as ./docs/arch-v2.png and update the reference in ./docs/README.md.✓ Copied
mermaid + github

Put Mermaid source in a PR description — GitHub renders it natively

Draft a PR description explaining the data flow change, include a Mermaid sequence diagram inline.✓ Copied

Tools

What this MCP exposes

ToolInputsWhen to callCost
generate_mermaid source: str (Mermaid DSL), output: base64|svg|mermaid|file|svgUrl|pngUrl, theme?, backgroundColor? Any diagram generation free (local render) or 1 API call for hosted URLs
validate_mermaid source: str Before generate if you're unsure about syntax free

Cost & Limits

What this costs to run

API quota
Local rendering is free; hosted URL output uses mermaid.ink which is free with reasonable use
Tokens per call
Small — diagram DSL is compact
Monetary
Free
Tip
Prefer 'mermaid' output for GitHub/docs that render natively; only go to PNG/SVG when rendering server-side is needed.

Security

Permissions, secrets, blast radius

Credential storage: None
Data egress: Local render for base64/svg; mermaid.ink for hosted URLs

Troubleshooting

Common errors and fixes

Mermaid parse error

The LLM emitted invalid DSL. Validate via validate_mermaid first; mcp-mermaid also self-corrects on second pass.

Verify: validate_mermaid on the source
PNG output fails in Docker

The image needs a headless browser; use the official Docker image which bundles it.

Verify: docker run hustcc/mcp-mermaid
Diagram too big, gets cut off

Break into subgraphs or split into multiple diagrams.

Alternatives

mcp-mermaid vs others

AlternativeWhen to use it insteadTradeoff
PlantUML MCPYou prefer PlantUML's deeper UML surfaceRequires Java runtime
antv-chart / mcp-server-chartYou need data charts more than diagramsDifferent shape of output
Raw Mermaid via the web editorYou're not in a chat workflowNo MCP integration

More

Resources

📖 Read the official README on GitHub

🐙 Browse open issues

🔍 Browse all 400+ MCP servers and Skills