Mermaid Lint MCP

Mermaid Lint MCP

A tool for validating Mermaid diagram syntax through CLI and MCP interfaces, providing real-time error checking and line-specific feedback. It enables AI assistants to self-validate and debug generated diagrams across all Mermaid types, ensuring valid visual documentation.

Category
Visit Server

README

Mermaid Lint MCP

δΈ­ζ–‡η‰ˆζœ¬ | English

A powerful tool for validating Mermaid diagrams with both CLI and MCP server capabilities. Perfect for developers, technical writers, and AI assistants who work with Mermaid diagrams.

πŸš€ Quick Start

Install and Use Immediately

# Validate a Mermaid file
npx mermaid-lint-mcp lint diagram.mmd

# Validate Mermaid code directly
npx mermaid-lint-mcp lint --code "graph TD; A-->B"

# Start MCP server for AI assistants
npx mermaid-lint-mcp server

# Get help
npx mermaid-lint-mcp --help

No installation required! The tool will be downloaded automatically on first use.

🎯 Use Cases

For Developers

  • Pre-commit validation: Ensure all Mermaid diagrams in your codebase are valid
  • CI/CD integration: Add diagram validation to your build pipeline
  • Documentation quality: Catch syntax errors before publishing docs

For Technical Writers

  • Content validation: Verify diagrams render correctly before publication
  • Error debugging: Get clear error messages for syntax issues

For AI Assistants

  • Real-time validation: Validate generated diagrams instantly
  • MCP integration: Seamless integration with Claude Code, Cursor, Trae, and other AI tools
  • Automated workflows: Enable AI to self-validate diagram outputs

πŸ“‹ Features

  • βœ… Fast Validation: Optimized for speed with browser reuse and local libraries
  • βœ… Multiple Formats: Support for all Mermaid diagram types
  • βœ… Dual Interface: Both CLI tool and MCP server in one package
  • βœ… Error Details: Clear error messages with line numbers and suggestions
  • βœ… Timeout Control: Configurable validation timeouts
  • βœ… Zero Config: Works out of the box

πŸ› οΈ Installation Options

Option 1: Use with npx (Recommended)

No installation needed - just use npx mermaid-lint-mcp directly.

Option 2: Global Installation

npm install -g mermaid-lint-mcp
# Then use: mermaid-lint-mcp

Option 3: Local Project Installation

npm install mermaid-lint-mcp
# Then use: npx mermaid-lint-mcp

πŸ“– Usage Guide

CLI Commands

Validate Diagrams

# Validate a file
npx mermaid-lint-mcp lint diagram.mmd
npx mermaid-lint-mcp diagram.mmd  # 'lint' is default

# Validate code string
npx mermaid-lint-mcp lint --code "graph TD; A-->B"

# With custom timeout (5 seconds)
npx mermaid-lint-mcp lint --timeout 5000 diagram.mmd

# Validate with file option
npx mermaid-lint-mcp lint --file diagram.mmd

Start MCP Server

# Start server for AI assistant integration
npx mermaid-lint-mcp server

Get Help

npx mermaid-lint-mcp --help     # Show all commands
npx mermaid-lint-mcp --version  # Show version

MCP Server Integration

For Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "mermaid-lint": {
      "command": "npx",
      "args": ["mermaid-lint-mcp", "server"]
    }
  }
}

For Other MCP Clients, the setup is similar to above, please refer to the official documentation

πŸ“Š Supported Diagram Types

Type Syntax Example
Flowchart flowchart TD Decision trees, processes
Sequence sequenceDiagram API interactions, workflows
Class classDiagram Object relationships
State stateDiagram-v2 State machines
ER erDiagram Database schemas
Gantt gantt Project timelines
Pie pie Data visualization
Journey journey User experiences
Git Graph gitgraph Version control flows
... ... ...

πŸ”§ Configuration

Validation Options

interface ValidationOptions {
  timeout?: number;  // Timeout in milliseconds (default: 5000)
}

Environment Variables

# Set default timeout
export MERMAID_TIMEOUT=10000

# Enable debug logging
export DEBUG=mermaid-lint-mcp

πŸ” Example Outputs

Valid Diagram

{
  "isValid": true,
  "error": null,
  "diagramType": "flowchart"
}

Invalid Diagram

{
  "isValid": false,
  "error": "Parse error on line 8: ...> C E --> F[End ---------------------^ Expecting 'SQE', 'DOUBLECIRCLEEND', 'PE', '-)', 'STADIUMEND', 'SUBROUTINEEND', 'PIPE', 'CYLINDEREND', 'DIAMOND_STOP', 'TAGEND', 'TRAPEND', 'INVTRAPEND', 'UNICODE_TEXT', 'TEXT', 'TAGSTART', got '1'",
  "diagramType": "flowchart"
}

CLI Output

$ npx mermaid-lint-mcp lint --code "graph TD; A-->B"
πŸ” Validating Mermaid diagram...
βœ… Diagram is valid!
πŸ“Š Diagram type: flowchart

🚨 Common Issues & Solutions

Issue: "Command not found"

Solution: Use npx mermaid-lint-mcp instead of mermaid-lint-mcp

Issue: Validation timeout

Solution: Increase timeout with --timeout 10000

Issue: Permission denied

Solution: Run with appropriate permissions or use npx

πŸ“ License

MIT License - see LICENSE file for details.

πŸ™‹β€β™‚οΈ Support

πŸ”— Related Tools

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured