AM

andrewginns/mermaid-mcp-server

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

11 stars 2 forks 品質 56 トレンド 18

Python MCP Server abstracting the official mermaid-cli for ease of use

概要

A Model Context Protocol (MCP) server for validating Mermaid diagrams. Implements a minimal Python wrapper over https://github.com/mermaid-js/mermaid-cli for simpler out of the box use. Python MCP server for validating Mermaid diagrams and (optionally) rendering them as PNG images. It uses the Mermaid CLI tool to perform the validation and rendering. The server provides LLMs with structured validation results including: - (is_valid: true/false) indicating whether the Mermaid diagram syntax is correct - explaining exactly what went wrong if validation fails (e.g., syntax errors, unsupported diagram types, malformed nodes) - of successfully rendered diagrams for visual verification This enables LLMs to programmatically validate Mermaid diagram syntax, understand specific errors to provide helpful corrections, and optionally receive visual confirmation of the rendered output. Also provides a simple Pydantic-AI MCP Client to invoke the MCP server using a Gemini model for testing.

README

以下は原文 README の抜粋です。原文を見る。

Mermaid MCP Server

A Model Context Protocol (MCP) server for validating Mermaid diagrams.

Implements a minimal Python wrapper over https://github.com/mermaid-js/mermaid-cli for simpler out of the box use.

Overview

Python MCP server for validating Mermaid diagrams and (optionally) rendering them as PNG images. It uses the Mermaid CLI tool to perform the validation and rendering.

The server provides LLMs with structured validation results including:

  • Boolean validation status (is_valid: true/false) indicating whether the Mermaid diagram syntax is correct
  • Detailed error messages explaining exactly what went wrong if validation fails (e.g., syntax errors, unsupported diagram types, malformed nodes)
  • Optional base64-encoded PNG images of successfully rendered diagrams for visual verification

This enables LLMs to programmatically validate Mermaid diagram syntax, understand specific errors to provide helpful corrections, and optionally receive visual confirmation of the rendered output.

Also provides a simple Pydantic-AI MCP Client to invoke the MCP server using a Gemini model for testing.

Prerequisites

Important: This MCP server requires Node.js to be installed on your system, even if you’re only using the server component (not the client). The server internally calls npx @mermaid-js/mermaid-cli as a subprocess to perform diagram validation and rendering.

Required Dependencies

  • Node.js with npm (required for all usage)
  • Mermaid CLI: Install with npm install -g @mermaid-js/mermaid-cli
  • Python with uv (for running the MCP server)

Quick Dependency Setup

# Install Mermaid CLI globally
npm install -g @mermaid-js/mermaid-cli

# Verify installation
npx @mermaid-js/mermaid-cli --version

Quickstart

To use this server with an MCP client (like Claude Desktop), add the following configuration to your MCP settings:

Note: Make sure you have Node.js and Mermaid CLI installed (see Prerequisites above) before configuring the MCP server.

Configuration Format

  1. Clone this repository

  2. Add this to your MCP client configuration file (e.g., claude_desktop_config.json):

{
  "mcpServers": {
    "mermaid-validator": {
      "command": "uv",
      "args": ["run", "/path/to/mermaid_mcp_server.py"],
    }
  }
}

Configuration Options

  • command: Use uv to run the server
  • args: Run the server script with uv run
  • cwd: Set to the absolute path of your cloned repository
  • env: Environment variables for the server
    • MCP_TRANSPORT: Set to "stdio" for standard input/output communication

Example Extended Configuration

{
  "mcpServers": {
    "mermaid-validator": {
      "command": "uv", 
      "args": ["run", "/path/to/mermaid_mcp_server.py"],
      "env": {
        "MCP_TRANSPORT": "stdio",
      }
    }
  }
}

Abstractions Over Mermaid-CLI

GitHub で README 全文を見る

インストール

npx @mermaid-js/mermaid-cli --version
MCP 初心者?mcpskill.org のガイドから始めましょう →

設定

{ "mcpServers": { "mermaid-validator": { "command": "uv", "args": ["run", "/path/to/mermaid_mcp_server.py"], } } }