
rtuin/mcp-mermaid-validator
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
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でコア機能が実装されています。 このコンポーネント:
- MCP サーバーインスタンスを作成する
- [
validateMermaidをマーメイドの図構文を受け入れるツールに登録する 3。 Mermaid CLIを使用して、図を検証およびレンダリングします - 検証結果とレンダリングされた PNG を返す (有効な場合)
- 適切なエラーメッセージでエラーケースを処理する
データフロー
このページは 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:
- 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"
]
}
}
}