RM

rtuin/mcp-mermaid-validator

Developer tools

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

57 stars 16 forks Качество 68 Тренд 0MIT

rtuin/mcp-mermaid-validator - кандидат на сервер MCP, импортированный из https://github.com/rtuin/mcp-mermaid-validator.

Обзор

rtuin/mcp-mermaid-validator - кандидат на сервер MCP, импортированный из https://github.com/rtuin/mcp-mermaid-validator.

Обзор (машинный перевод)

Сервер Model Context Protocol, который проверяет и отображает диаграммы Русалки. Этот сервер позволяет LLM проверять и отображать диаграммы Русалки.

Использование

###Быстрый старт

Вы можете настроить свой MCP-клиент для использования Mermaid Validator, добавив его в файл сервера mcp:

Архитектура

Архитектура высокого уровня

Этот проект структурирован как простое приложение TypeScript Node.js, которое:

  1. ** Основное приложение **: служба Node.js, которая проверяет диаграммы Русалки и возвращает вывод PNG
  2. MCP Integration: использует протокол Model Context Protocol SDK для предоставления функциональности MCP-совместимым клиентам
  3. Mermaid CLI Integration: использует инструмент Mermaid CLI для проверки диаграмм и рендеринга

Структура кода

Функциональные компоненты

Сервер MCP (основной компонент)

Функционал ядра реализован в src/main.ts. Этот компонент:

  1. Создает экземпляр MCP-сервера
  2. регистрирует инструмент validateMermaid, который принимает синтаксис диаграммы Русалки
  3. Использует CLI Русалки для проверки и визуализации диаграмм
  4. Возвращает результаты валидации и отображается PNG (если это действительно)
  5. Обработка случаев ошибок с помощью соответствующих сообщений об ошибках

###Поток данных

Эта страница переведена автоматически. Технические детали смотрите в оригинале.

README

Показан фрагмент оригинального README. Открыть оригинал.

MCP Server: Mermaid Validator

A Model Context Protocol server that validates and renders Mermaid diagrams. This server enables LLMs to validate and render Mermaid diagrams.

Usage

Quick Start

You can configure your MCP client to use the Mermaid Validator by adding it to your mcp servers file:

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

Architecture

High-Level Architecture

This project is structured as a simple TypeScript Node.js application that:

  1. Main Application: A Node.js service that validates Mermaid diagrams and returns rendered PNG output
  2. MCP Integration: Uses the Model Context Protocol SDK to expose functionality to MCP-compatible clients
  3. Mermaid CLI Integration: Leverages the Mermaid CLI tool to perform diagram validation and rendering

Code Structure

mcp-mermaid-validator/
├── dist/                   # Compiled JavaScript output
│   └── main.js             # Compiled main application
├── src/                    # TypeScript source code
│   └── main.ts             # Main application entry point
├── node_modules/           # Dependencies
├── package.json            # Project dependencies and scripts
├── package-lock.json       # Dependency lock file
├── tsconfig.json           # TypeScript configuration
├── eslint.config.js        # ESLint configuration
├── .prettierrc             # Prettier configuration
└── README.md               # Project documentation

Component Functionality

MCP Server (Main Component)

The core functionality is implemented in src/main.ts. This component:

  1. Creates an MCP server instance
  2. Registers a validateMermaid tool that accepts Mermaid diagram syntax
  3. Uses the Mermaid CLI to validate and render diagrams
  4. Returns validation results and rendered PNG (if valid)
  5. Handles error cases with appropriate error messages

Data Flow

  1. Input: Mermaid diagram syntax as a string
  2. Processing:
    • The diagram is passed to the Mermaid CLI via stdin
    • The CLI validates the syntax and renders a PNG if valid
    • Output and errors are captured from stdout/stderr
  3. Output:
    • Success: Text confirmation + rendered PNG as base64-encoded image
    • Failure: Error message with details about the validation failure

Dependencies

External Libraries

  • @modelcontextprotocol/sdk: SDK for implementing Model Context Protocol
  • @mermaid-js/mermaid-cli: CLI tool for validating and rendering Mermaid diagrams
  • zod: Schema validation library for TypeScript

Development Dependencies

  • typescript: TypeScript compiler
  • eslint: Linting utility
  • prettier: Code formatting

API Specification

validateMermaid Tool

Purpose: Validates a Mermaid diagram and returns the rendered PNG if valid

Parameters:

Открыть полный README на GitHub

Установка

npx -y @rtuin/mcp-mermaid-validator@latest
Новичок в MCP? Начните с руководства на mcpskill.org →

Конфигурация

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