I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

Validateur MCP-Merme
Un serveur de protocole de contexte modèle qui valide et rend les diagrammes de sirène.
3 years
Works with Finder
1
Github Watches
1
Github Forks
10
Github Stars
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"
]
}
}
}
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 SVG 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
validateMermaid
tool that accepts Mermaid diagram syntax - Uses the Mermaid CLI to validate and render diagrams
- Returns validation results and rendered SVG (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 an SVG if valid
- Output and errors are captured from stdout/stderr
-
Output:
- Success: Text confirmation + rendered SVG 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 SVG if valid
Parameters:
-
diagram
(string): The Mermaid diagram syntax to validate
Return Value:
- Success:
{ content: [ { type: "text", text: "Mermaid diagram is valid" }, { type: "image", data: string, // Base64-encoded PNG mimeType: "image/png" } ] }
- Failure:
{ content: [ { type: "text", text: "Mermaid diagram is invalid" }, { type: "text", text: string // Error message }, { type: "text", text: string // Detailed error output (if available) } ] }
Technical Decisions
-
MCP Integration: The project uses the Model Context Protocol to standardize the interface for AI tools, allowing seamless integration with compatible clients.
-
PNG Output Format: The implementation uses PNG as the default output format to ensure better compatibility with most MCP clients, particularly Cursor, which doesn't support SVG.
-
Child Process Approach: The implementation uses Node.js child processes to interact with the Mermaid CLI, which provides:
- Isolation between the main application and the rendering process
- Ability to capture detailed error information
- Proper handling of the rendering pipeline
-
Error Handling Strategy: The implementation uses a nested try-catch structure to:
- Distinguish between validation errors (invalid diagram syntax) and system errors
- Provide detailed error information to help users fix their diagrams
- Ensure the service remains stable even when processing invalid input
-
Simple Project Structure: The project uses a straightforward TypeScript project structure for:
- Easy maintenance and understanding
- Direct dependency management
- Simplified build process
Build and Execution
The application can be built and run using npm scripts:
# Install dependencies
npm install
# Build the application
npm run build
# Run locally (for development)
npx @modelcontextprotocol/inspector node dist/main.js
# Format code
npm run format
# Lint code
npm run lint
# Watch for changes (development)
npm run watch
The application runs as an MCP server that communicates via standard input/output, making it suitable for integration with MCP-compatible clients.
Release
To release a new version, the following steps in order:
-
npm run build
-
npm run bump
-
npm run changelog
-
npm publish --access public
相关推荐
Confidential guide on numerology and astrology, based of GG33 Public information
Advanced software engineer GPT that excels through nailing the basics.
A medical specialist offering assistance grounded in clinical guidelines. Disclaimer: This is intended for research and is NOT safe for clinical use!
A geek-themed horoscope generator blending Bitcoin prices, tech jargon, and astrological whimsy.
Découvrez la collection la plus complète et la plus à jour de serveurs MCP sur le marché. Ce référentiel sert de centre centralisé, offrant un vaste catalogue de serveurs MCP open-source et propriétaires, avec des fonctionnalités, des liens de documentation et des contributeurs.
Manipulation basée sur Micropython I2C de l'exposition GPIO de la série MCP, dérivée d'Adafruit_MCP230XX
Une passerelle API unifiée pour intégrer plusieurs API d'explorateur de blockchain de type étherscan avec la prise en charge du protocole de contexte modèle (MCP) pour les assistants d'IA.
Miroir dehttps: //github.com/suhail-ak-s/mcp-typeseense-server
本项目是一个钉钉 MCP (Protocole de connecteur de message) 服务 , 提供了与钉钉企业应用交互的 API 接口。项目基于 Go 语言开发 , 支持员工信息查询和消息发送等功能。
La communauté du curseur et de la planche à voile, recherchez des règles et des MCP
Reviews

user_WNKHhJKn
As a dedicated user of the mcp application, I find the mcp-mermaid-validator by rtuin to be an essential tool for ensuring the correctness of my Mermaid diagrams. The straightforward integration and robust validation process significantly streamline my workflow. If you're working with Mermaid, check out this tool on GitHub! It's a game-changer.