mcp-mermaid-validator
The MCP Mermaid Validator server validates and renders Mermaid diagrams, integrating with MCP-compatible clients.
Validate Mermaid Syntax: Accepts Mermaid diagram syntax as input and validates its correctness.
Render Diagrams: Returns a rendered PNG image in base64-encoded format for valid diagrams.
Error Handling: Provides detailed error messages for invalid diagrams or system errors.
Validation Status: Returns the validation result (valid or invalid).
Integration with MCP: Uses the Model Context Protocol to standardize interactions with compatible clients.
Usage in AI Tools: Enables LLMs to validate and render Mermaid diagrams seamlessly.
Validates and renders Mermaid diagrams, returning validation results and rendered SVG/PNG output when valid, enabling LLMs to create and verify diagram syntax.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-mermaid-validatorvalidate this flowchart: graph TD; A-->B; B-->C;"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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"
]
}
}
}Related MCP server: Mermaid MCP Server
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 documentationComponent 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 syntaxUses 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:
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 watchThe 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 buildnpm run bumpnpm run changelognpm publish --access public
Troubleshooting
WSL/Windows stdin: Earlier versions invoked Mermaid CLI with
/dev/stdin, which can fail on WSL withENXIO. This server now uses-for stdin/stdout (-i -/-o -) to be portable across Linux/macOS/WSL/Windows.Inspector working dir: When launching via the MCP Inspector, ensure the server path resolves (e.g.
npx @modelcontextprotocol/inspector npx -y @rtuin/mcp-mermaid-validator@latestor use an absolute path todist/main.js).
Available Tools
1 toolvalidateMermaidC
Validates a Mermaid diagram and returns the rendered image (PNG or SVG) if valid
| Name | Required | Description | Default |
|---|---|---|---|
| diagram | Yes | ||
| format | No | png |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations; description fails to disclose what happens on invalid input (e.g., error messages), side effects, or rate limits. Minimal behavioral context.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Single sentence, no fluff. Efficient for its brevity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
No output schema; description mentions 'rendered image' but not format details (binary vs base64) or validation success/failure behavior. Lacks completeness for a validation tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%; tool description does not explain parameters beyond schema fields. 'diagram' and 'format' remain underdocumented.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Clear verb-resource: 'Validates a Mermaid diagram' and specifies output ('rendered image'). Lacks sibling differentiation but no siblings exist.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use or when not to, no alternatives mentioned. Implied usage only.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
1 tool update
v0.7.0- Changed
validateMermaid1 field changed- added
Input schema / properties / formatAdded value: +{ + "default": "png", + "enum": [ + "svg", + "png" + ], + "type": "string" +}
1 tool update
v1.0.0- First observed
validateMermaid
TDQS
With only one tool, there is no possibility for confusion. The tool's purpose is clear and distinct.
A single tool cannot be inconsistent. The name 'validateMermaid' follows a clear verb_noun pattern.
A single validation tool perfectly matches the server's focused purpose. Adding more tools would be unnecessary.
The tool fully covers the domain: it validates Mermaid diagrams and returns the rendered image. No obvious gaps exist.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Render, verify, describe, and safely edit Mermaid diagrams through MCP.
A Model Context Protocol server for Wix AI tools
Model Context Protocol server for Studex tools, notifications, and profile integrations
A Model Context Protocol (MCP) server for Selise Blocks Cloud integration
Related MCP Servers
- AlicenseBqualityCmaintenanceA Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.1266234MIT
- -licenseNot gradedqualityNot gradedmaintenanceA server that implements the Model Context Protocol (MCP), providing an interface for LLM applications to generate mermaid.js visualizations and diagrams.-
- FlicenseNot gradedqualityDmaintenanceA powerful Model Context Protocol server that automatically generates Mermaid diagrams from code and provides SVG beautification features.1-
- AlicenseAqualityBmaintenanceA Model Context Protocol server that converts Mermaid diagram code into various image formats (PNG, JPG, SVG, PDF) with theme customization options for AI clients.39MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/rtuin/mcp-mermaid-validator'
If you have feedback or need assistance with the MCP directory API, please join our Discord server