Skip to main content
Glama

mermaid-local-mcp

A local MCP (Model Context Protocol) server that renders Mermaid diagrams and returns PNG images. Designed for visual feedback loops in Claude Code -- render a diagram, inspect it visually, fix issues, re-render.

Why?

Cloud-based Mermaid rendering MCPs depend on external APIs that can go down (503 errors, rate limits). This server runs entirely locally using mermaid-cli (mmdc), so it's fast, free, and always available.

mermaid-local-mcp

Cloud MCP

Dependency

Local only

External API

Reliability

No 503s

Can go down

Offline

Works

Doesn't work

Speed

Fast (local render)

Network roundtrip

Cost

Free

Free (for now)

Related MCP server: vizcharter

Features

  • Renders Mermaid code to high-resolution PNG via Puppeteer/mmdc

  • Returns images directly to Claude for visual inspection

  • Generates mermaid.live preview links automatically

  • Reports syntax errors with actionable details

  • Supports themes: default, forest, dark, neutral

  • Configurable scale (1-5x), background color

Setup

1. Clone

git clone https://github.com/ryu1maniwa/mermaid-local-mcp.git
cd mermaid-local-mcp
npm install

2. Configure Claude Code

Add to your project's .mcp.json:

{
  "mcpServers": {
    "mermaid-local": {
      "command": "node",
      "args": ["/path/to/mermaid-local-mcp/index.mjs"]
    }
  }
}

Or add to your global ~/.claude/settings.json:

{
  "mcpServers": {
    "mermaid-local": {
      "command": "node",
      "args": ["/path/to/mermaid-local-mcp/index.mjs"]
    }
  }
}

3. Allow the tool (optional)

In .claude/settings.json, add to permissions:

{
  "permissions": {
    "allow": ["mcp__mermaid-local"]
  }
}

Tool: render_mermaid

Renders Mermaid diagram code to a PNG image.

Parameters

Parameter

Type

Default

Description

mermaidCode

string

(required)

Mermaid diagram code

theme

enum

"default"

"default" / "forest" / "dark" / "neutral"

backgroundColor

string

"white"

Background color ("white", "transparent", "#F0F0F0")

scale

number

2

Scale factor 1-5 for resolution

Returns

On success:

  • PNG image (base64-encoded, displayed inline by Claude)

  • mermaid.live preview/edit link

On error:

  • Syntax error details from mmdc stderr

  • mermaid.live link for debugging

Usage with the feedback loop skill

This MCP pairs with a Claude Code agent skill for autonomous Mermaid diagram improvement:

  1. Extract Mermaid blocks from markdown files

  2. Render each diagram via render_mermaid

  3. Visually inspect the returned PNG for issues (text overlap, layout problems, poor contrast)

  4. Fix the Mermaid code

  5. Re-render and verify

  6. Update the source markdown file

See SKILL.md for the complete skill definition.

Requirements

  • Node.js >= 18

  • npx (comes with npm)

  • @mermaid-js/mermaid-cli is invoked via npx automatically (no global install needed)

License

MIT

Available Tools

1 tool
render_mermaidA

Render Mermaid diagram code to PNG image locally using mmdc. Returns the rendered image for visual inspection. Use this for feedback loops: render -> inspect -> fix -> re-render.

Inputs: mermaidCode (required), scale, theme, backgroundColor.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 1 tool

    Disambiguation5/5

    There is only one tool, so there is no possibility of confusing it with another operation. Its purpose is clearly stated as rendering Mermaid code to PNG.

    Naming Consistency5/5

    The single tool follows a clear verb_noun pattern: render_mermaid. With only one name, there is no inconsistency to assess.

    Tool Count4/5

    A single render tool is well matched to this server's focused purpose, though the surface is slightly thin compared with broader multi-tool servers. It earns its place as the core operation.

    Completeness4/5

    The core rendering workflow is fully covered, including the render-inspect-fix loop. Minor optional gaps exist, such as explicit validation or additional output formats, but they are not essential for the stated purpose.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Enables AI assistants to generate and render Mermaid diagrams (flowcharts, sequence diagrams, etc.) as PNG/SVG images with local file saving and HTTP access URLs. Supports batch processing and intelligent caching for efficient diagram creation.
      1
      64 npm
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables Claude Code to create and edit presentation-grade visualizations such as cloud architecture diagrams, charts, KPI dashboards, and poster infographics, with auto-layout, themes, and export to SVG, PNG, JPG, and PDF.
      6
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables Claude to draw Mermaid diagrams as live, inline canvases in the reply instead of printing them as code blocks. The rendered diagram can be zoomed, panned, re-themed, expanded in height, and flipped to a highlighted, copyable source view.
      MIT