mermaider

mermaider

Validates Mermaid diagram syntax using a persistent browser for fast, reliable checks.

Category
Visit Server

README

The mermaider MCP server: fast, reliable Mermaid diagram syntax checker

<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --> Table of Contents

<!-- markdown-toc end -->

Overview

The mermaider is an MCP server that provides validate_syntax tool that checks all Mermaid diagram types for syntax errors.

For that, it uses puppeteer-core package and mermaid-js/mermaid API directly to efficiently use already installed Chrome-based or Firefox browser.

Efficiently means:

  • The browser (with a new page) is opened and kept running headless (by default) for as long as this MCP server process is active – to achieve low-latency tool calls.
  • Every validate_syntax tool call reuses the browser and the page.

Why using the browser at all?

Unfortunately, mermaid-js/mermaid relies on full browser context (DOM) for its functionality, even for parsing the diagrams. Packages like happy-dom or jsdom do not quite cut it.

The mermaider uses relatively light-weight puppeteer-core package (as opposed to full puppeteer) to access already installed browser.

The LLMs syntax problem

Modern LLMs typically are perfectly capable of generating Mermaid diagrams, however often lack ability to reliably check the generated syntax. This is where the mermaider MCP comes in.

What makes mermaider different?

There are other MCPs that can (sort of) validate Mermaid syntax, however, they typically work by launching mmdc command-line utility process every time respective tool is invoked (by the LLM).

That brings a few issues:

  • Speed: spawning mmdc process, which (then itself launches the browser) for every tool call is slow and expensive.

  • Non-determinism: mmdc's purpose really is to generate images, not validate syntax. As such, occasionally it exits with 0 code and generates an image (like one below) for diagrams with broken syntax as opposed to exiting with non-zero code and spitting out an error message to STDERR. In this case, MCP server that uses mmdc would have no idea the error occurred so you end up with a bunch of these images instead of your diagrams.

    Error image example

  • Side Effects: mmdc may install Chrome browser unbeknownst to you as that is the default puppeteer's behaviour, quote:

    When you install Puppeteer, it automatically downloads a recent version of Chrome for Testing (~170MB macOS, ~282MB Linux, ~280MB Windows) and a chrome-headless-shell binary (starting with Puppeteer v21.6.0) that is guaranteed to work with Puppeteer. The browser is downloaded to the $HOME/.cache/puppeteer folder by default (starting with Puppeteer v19.0.0). See configuration for configuration options and environmental variables to control the download behavior.

Installation

In general, below is the command that your MCP client should use:

npx -y @vtomilin/mermaider <config>

Where <config> is either an inline JSON string, or a config file path, e.g.

npx -y @vtomilin/mermaider '{"executablePath": "/Applications/FirefoxDeveloperEdition.app/Contents/MacOS/firefox", "browser": "firefox"}'

Or:

npx -y @vtomilin/mermaider /home/user/etc/Firefox.json

Where /home/user/etc/Firefox.json is a JSON file containing the configuration, for example, for Firefox browser:

{
  "executablePath": "/Applications/FirefoxDeveloperEdition.app/Contents/MacOS/firefox",
  "browser": "firefox"
}

Another config file example, using the Brave (Chrome-based) browser:

{
  "executablePath": "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
}

Complete list of available Browser configuration options defined in Puppeteer's Browser Launchoptions.

VSCode

Press Cmd-Shift-P (or Ctrl-Shift-P), then MCP: Add Server.... Select Command (stdio) Run a local command that implements the MCP protocol. Enter npx -y @vtomilin/mermaider /home/user/etc/Firefox.json (or whatever config method). Enter the server name (mermaider). And you should be all set.

Cursor/Windsuf/...

{
  "mcpServers": {
    "mermaider": {
      "command": "npx",
      "args": ["-y", "@vtomilin/mermaider", "/home/user/etc/Firefox.json"]
    }
  }
}

Bun

Even though this project is built with Bun the mermaider package can not be run directly with bunx at the moment. You would have to install the package globally with bun add -g @vtomilin/mermaider first. Then you can just use mermaider-bun executable to run the server:

{
  "mcpServers": {
    "mermaider": {
      "command": "mermaider-bun",
      "args": ["/home/user/etc/Firefox.json"]
    }
  }
}

Recommendations

Usage Examples

Example sessions using Github Copilot in VSCode:

  • Generating a diagram and checking its syntax with mermaider: Correct Syntax

  • Generating an intentionally broken diagram and checking its syntax with mermaider: Invalid Syntax

References

Other Mermaid related MCP servers

  • mcp-mermaid-validator: A Model Context Protocol server that validates and renders Mermaid diagrams.
  • mermaid-mcp-server: A Model Context Protocol (MCP) server providing tools for validating and rendering Mermaid diagrams.

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured