
rtuin/mcp-mermaid-validator
Developer toolsЭта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал
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, которое:
- ** Основное приложение **: служба Node.js, которая проверяет диаграммы Русалки и возвращает вывод PNG
- MCP Integration: использует протокол Model Context Protocol SDK для предоставления функциональности MCP-совместимым клиентам
- Mermaid CLI Integration: использует инструмент Mermaid CLI для проверки диаграмм и рендеринга
Структура кода
Функциональные компоненты
Сервер MCP (основной компонент)
Функционал ядра реализован в src/main.ts. Этот компонент:
- Создает экземпляр MCP-сервера
- регистрирует инструмент
validateMermaid, который принимает синтаксис диаграммы Русалки - Использует CLI Русалки для проверки и визуализации диаграмм
- Возвращает результаты валидации и отображается PNG (если это действительно)
- Обработка случаев ошибок с помощью соответствующих сообщений об ошибках
###Поток данных
Эта страница переведена автоматически. Технические детали смотрите в оригинале.
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:
- Main Application: A Node.js service that validates Mermaid diagrams and returns rendered PNG output
- MCP Integration: Uses the Model Context Protocol SDK to expose functionality to MCP-compatible clients
- 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:
- Creates an MCP server instance
- Registers a
validateMermaidtool that accepts Mermaid diagram syntax - Uses the Mermaid CLI to validate and render diagrams
- Returns validation results and rendered PNG (if valid)
- Handles error cases with appropriate error messages
Data Flow
- Input: Mermaid diagram syntax as a string
- 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
- 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:
Установка
npx -y @rtuin/mcp-mermaid-validator@latestКонфигурация
{
"mcpServers": {
"mermaid-validator": {
"command": "npx",
"args": [
"-y",
"@rtuin/mcp-mermaid-validator@latest"
]
}
}
}