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"], } } }