Get the FREE Ultimate OpenClaw Setup Guide →

mcp-mermaid-validator

A Model Context Protocol server that validates and renders Mermaid diagrams.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio rtuin-mcp-mermaid-validator npx -y @rtuin/mcp-mermaid-validator@latest

How to use

The Mermaid Validator MCP server provides a dedicated tool to validate and render Mermaid diagrams. It exposes a validateMermaid capability via the MCP SDK: you supply Mermaid diagram syntax as input, and the tool returns either a confirmation that the diagram is valid along with a base64-encoded PNG rendering, or detailed error information if the diagram is invalid. This makes it suitable for integration with LLM workflows where you want to verify diagram syntax before rendering visuals. To use it, configure your MCP client to point at this server (for example under the mermaid-validator key). Once connected, you can pass the Mermaid diagram text to the validateMermaid tool and receive either a successful rendering or helpful error messages that include validation details and any available output from the Mermaid CLI.

How to install

Prerequisites:

  • Node.js and npm installed on your system
  • Access to the internet to download dependencies

Step-by-step:

  1. Copy the quick-start server configuration into your MCP clients file (see mcp_config):
{
  "mcpServers": {
    "mermaid-validator": {
      "command": "npx",
      "args": [
        "-y",
        "@rtuin/mcp-mermaid-validator@latest"
      ]
    }
  }
}
  1. Install dependencies and build (local development):
npm install
npm run build
  1. Run locally (for development) using the inspector if needed:
npx @modelcontextprotocol/inspector node dist/main.js

Note: In production or containerized environments, you typically use the mcp_config entry above to let the MCP client install the validator on demand via npx.

  1. Validate the setup by invoking the validateMermaid tool with a Mermaid diagram string through your MCP client.

Additional notes

Tips and notes:

  • The server uses the Mermaid CLI under the hood to validate syntax and render PNG output. The PNG is returned as a base64-encoded string to maximize compatibility with various MCP clients. -stdin/stdout handling is implemented to be portable across Linux, macOS, WSL, and Windows. If you encounter stdin issues, ensure the Mermaid CLI receives input via the appropriate piping method as described in the Troubleshooting section of the README. -Common issues: invalid Mermaid syntax will yield structured error messages with details from the Mermaid CLI; ensure your diagram follows Mermaid syntax and supported diagram types. -If you need to adjust output format or path handling, check the build and runtime configuration in the source, particularly around how the Mermaid CLI is invoked and how outputs are captured.

Related MCP Servers

Sponsor this space

Reach thousands of developers