RM

rtuin/mcp-mermaid-validator

Developer tools

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

57 stars 15 forks 品質 68 トレンド 0MIT

rtuin/mcp-mermaid-validatorは[https://github.com/rtuin/mcp-mermaid-validator.からインポートされたMCPサーバー候補です

概要

rtuin/mcp-mermaid-validatorは[https://github.com/rtuin/mcp-mermaid-validator.からインポートされたMCPサーバー候補です

概要(AI 翻訳)

マーメイド図を検証してレンダリングするモデルコンテキストプロトコルサーバー。 このサーバーはLMSがマーメイドのダイアグラムを検証し、レンダリングすることを可能にします。

使用法

クイックスタート

MCP クライアントは、Mermaid Validator を mcp サーバファイルに追加することで使用できます。

アーキテクチャ

###ハイレベルアーキテクチャ

このプロジェクトは、単純なTypeScript Node.jsアプリケーションとして構成されています。

1.メインアプリケーション: マーメイド図を検証し、レンダリングされたPNG出力を返すNode.jsサービス 2.MCPインテグレーション:モデルコンテキストプロトコルSDKを使用して、MCP互換クライアントに機能を公開 3。Mermaid CLIインテグレーション: マーメイドCLIツールを活用して、図検証とレンダリングを実行します。

コード構造

コンポーネントの機能

MCP サーバー(メインコンポーネント)

[src/main.tsでコア機能が実装されています。 このコンポーネント:

  1. MCP サーバーインスタンスを作成する
  2. [validateMermaid をマーメイドの図構文を受け入れるツールに登録する 3。 Mermaid CLIを使用して、図を検証およびレンダリングします
  3. 検証結果とレンダリングされた PNG を返す (有効な場合)
  4. 適切なエラーメッセージでエラーケースを処理する

データフロー

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

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:

GitHub で README 全文を見る

インストール

npx -y @rtuin/mcp-mermaid-validator@latest
MCP 初心者?mcpskill.org のガイドから始めましょう →

設定

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