Mermaid Validator MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add mermaid-validator -- npx -y mermaid-validator-mcp
README.md

An MCP server that validates Mermaid diagram syntax.

Mermaid Validator MCP

A Model Context Protocol (MCP) server built with Bun and TypeScript that validates Mermaid diagram syntax.

Quick Start

This package is published on npm. You can run it directly with npx:

npx -y mermaid-validator-mcp

MCP Client Configuration

Add the server to your MCP client (e.g. Claude Desktop) configuration:

Using npx (recommended)

{
  "mcpServers": {
    "mermaid-validator": {
      "command": "npx",
      "args": ["-y", "mermaid-validator-mcp"]
    }
  }
}

Using local source

{
  "mcpServers": {
    "mermaid-validator": {
      "command": "bun",
      "args": [
        "/path/to/mermaid-validator-mcp/index.ts"
      ]
    }
  }
}

Or if you have it installed globally:

{
  "mcpServers": {
    "mermaid-validator": {
      "command": "mermaid-validator-mcp"
    }
  }
}

Features

  • Single tool – validate_mermaid: Pass any Mermaid diagram text and receive either a success response with the detected diagram type, or a detailed parse-error message.
  • Supports all major Mermaid diagram types: flowchart, sequence, class, pie, gantt, state, ER, gitGraph, mindmap, timeline, and more.
  • No dependency on mermaid-cli or any external rendering process.
  • Uses JSDOM to provide the minimal DOM environment required by Mermaid.

Requirements

Getting Started

# Install dependencies
bun install

# Start the MCP server (stdio mode)
bun start

Tool: `validate_mermaid`

Input

Field Type Description
diagram string The Mermaid diagram text to validate

Output (JSON text)

Valid diagram

{ "valid": true, "diagramType": "flowchart-v2" }

Invalid diagram

{
  "valid": false,
  "error": "Parse error on line 2:\n...TD\n  --> B\n-------^\nExpecting 'SEMI', ..."
}

Development

# Run with auto-reload
bun dev

# Build
bun run build

Tools (1)

validate_mermaidValidates Mermaid diagram text and returns the diagram type or a detailed parse-error message.

Configuration

claude_desktop_config.json
{"mcpServers": {"mermaid-validator": {"command": "npx", "args": ["-y", "mermaid-validator-mcp"]}}}

Try it

Validate this Mermaid flowchart syntax: graph TD; A-->B;
Check if this sequence diagram is valid: sequenceDiagram; Alice->>John: Hello John, how are you?
Can you validate this ER diagram code for me?
Identify the diagram type and check for syntax errors in this Mermaid string.

Frequently Asked Questions

What are the key features of Mermaid Validator?

Validates Mermaid diagram syntax without external rendering. Supports all major diagram types including flowchart, sequence, class, and gantt. Provides detailed parse-error messages for invalid diagrams. Detects and returns the specific diagram type for valid inputs.

What can I use Mermaid Validator for?

Ensuring diagram code is syntactically correct before adding it to documentation. Automating the validation of Mermaid diagrams generated by AI models. Debugging complex Mermaid diagrams by identifying specific line-based parse errors.

How do I install Mermaid Validator?

Install Mermaid Validator by running: npx -y mermaid-validator-mcp

What MCP clients work with Mermaid Validator?

Mermaid Validator works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Mermaid Validator docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare