Mermaid MCP Server
The Mermaid MCP Server is a Model Context Protocol server that converts Mermaid diagram code into various image formats, validates syntax, and provides diagram examples for AI clients.
Core Capabilities:
Convert Mermaid to Images - Transform Mermaid code into PNG, JPG, SVG, or PDF formats with customizable themes (default, dark, neutral, forest), background colors, and dimensions. Returns base64-encoded image data with metadata.
Validate Mermaid Syntax - Check the correctness of Mermaid diagram code before conversion with detailed error messages and validation feedback.
Get Supported Options - Retrieve available themes and output formats supported by the converter.
Access Diagram Examples - Use resource URIs to get sample code for various diagram types.
Supported Diagram Types: Flowcharts, Sequence Diagrams, Gantt Charts, Pie Charts, Git Graphs, Mind Maps, and Class Diagrams.
Integration: Designed for AI clients like Cursor, Claude Desktop, Cherry Studio, and Continue.dev via STDIO (recommended for desktop) or SSE (for network connections) communication modes. Utilizes the mermaid.ink API for rendering diagrams.
Supports generating Git graphs to visualize repository history and branch structures through Mermaid diagrams
Converts Mermaid diagram code into various image formats (PNG, JPG, SVG, PDF) with support for multiple themes and customization options
Supports rendering Mermaid diagrams as SVG format, which can be used for vector-based graphics representation
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., "@Mermaid MCP Serverconvert this flowchart to PNG with dark theme: flowchart TD A[Start] --> B[Process] --> C[End]"
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.
Mermaid MCP Server
A Mermaid diagram conversion server based on the Model Context Protocol (MCP), providing powerful diagram generation capabilities for AI clients
Project Introduction
Mermaid MCP Server is a professional Mermaid diagram conversion server based on the Model Context Protocol (MCP), providing powerful diagram generation capabilities for AI clients. This project converts Mermaid diagram code into image files in multiple formats (PNG, JPG, SVG, PDF), allowing users to easily generate high-quality diagrams in various AI clients that support the MCP protocol.
Core Features
Multi-format Output: Supports multiple image formats including PNG, JPG, SVG, and PDF
Theme Customization: Built-in four beautiful themes: default, dark, neutral, and forest
Custom Options: Supports customization of parameters such as background color and image dimensions
Syntax Validation: Provides real-time Mermaid syntax validation
Example Resources: Built-in rich diagram type example code
Error Handling: Comprehensive error handling mechanism with friendly error messages
STDIO/SSE Dual Mode: Supports both STDIO and SSE communication modes
uv Package Management: Uses the ultra-fast uv package manager
Related MCP server: mcp-mermaid-validator
Feature List
Feature Name | Description | Tech Stack | Status |
Diagram Conversion | Mermaid code to image | mermaid.ink API | ✅ Stable |
Multi-format Output | PNG/JPG/SVG/PDF | requests + base64 | ✅ Stable |
Theme Customization | 4 built-in themes | mermaid.ink | ✅ Stable |
Syntax Validation | Real-time syntax checking | mermaid-cli | ✅ Stable |
Example Resources | Rich diagram examples | Static resources | ✅ Stable |
Error Handling | Comprehensive error messages | Python exception handling | ✅ Stable |
MCP Protocol | Model Context Protocol | mcp[cli] | ✅ Stable |
SSE Mode | Server-Sent Events | FastAPI + Uvicorn | ✅ Stable |
Technical Architecture
Technology | Version | Purpose |
Python | 3.12+ | Primary development language |
MCP | 1.9+ | Model Context Protocol |
FastAPI | 0.104+ | Web framework (SSE mode) |
Uvicorn | 0.24+ | ASGI server |
requests | 2.31+ | HTTP client |
uv | latest | Python package manager |
Communication Architecture
┌─────────────────────────────────────────────────────────────────────────────────┐
│ 通信架构图 │
├─────────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────┐ ┌─────────────────────────┐ ┌─────────────┐ │
│ │ AI 客户端 │ ◄────► │ Mermaid MCP Server │ ◄────► │ Mermaid API │ │
│ │ (Cursor/Claude) │ │ STDIO/SSE │ │ mermaid.ink│ │
│ └──────────────────┘ └─────────────────────────┘ └─────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ AI 对话界面 MCP 协议通信 图表渲染转换 │
│ 生成图表请求 双向数据传输 返回图像数据 │
│ │
└─────────────────────────────────────────────────────────────────────────────────┘Installation Instructions
Environment Requirements
Python 3.12+
uv package manager (recommended)
Installing Dependencies
Method 1: Install with uv (recommended)
# 克隆仓库
git clone https://github.com/wwwzhouhui/mermaid_mcp_server.git
cd mermaid_mcp_server
# 安装依赖
uv syncMethod 2: Install with pip
pip install -r requirements.txtUsage Instructions
Client Configuration
Cursor Configuration
Add the following configuration to the ~/.cursor/mcp.json file:
STDIO mode (recommended):
{
"mcpServers": {
"mermaid-mcp-server-png-pdf-jpg-svg": {
"command": "uvx",
"args": [
"mermaid-mcp-server-png-pdf-jpg-svg"
]
}
}
}SSE mode:
{
"mcpServers": {
"mermaid-mcp-server-png-pdf-jpg-svg": {
"url": "http://127.0.0.1:8003/sse"
}
}
}Cherry Studio Configuration
Open Cherry Studio
Go to Settings → MCP Servers → Add Server
Configure the parameters:
Name:
mermaid-mcp-server-png-pdf-jpg-svgDescription:
Mermaid diagram generation serviceType:
STDIOCommand:
uvxArguments:
mermaid-mcp-server-png-pdf-jpg-svg
Click Save and enable

Claude Desktop Configuration
Add the following to the claude_desktop_config.json file:
{
"mcpServers": {
"mermaid-mcp-server-png-pdf-jpg-svg": {
"command": "uvx",
"args": [
"mermaid-mcp-server-png-pdf-jpg-svg"
]
}
}
}Continue.dev Configuration
Add the following to the config.json file:
{
"mcpServers": {
"mermaid-mcp-server-png-pdf-jpg-svg": {
"command": "uvx",
"args": [
"mermaid-mcp-server-png-pdf-jpg-svg"
]
}
}
}Starting the Service
STDIO mode (recommended for desktop clients)
uv run python main.pySSE mode (for network connections)
uv run python main.py --sseConfiguration Instructions
Environment Variable Configuration
Variable Name | Description | Default Value |
| Server address |
|
| Server port |
|
| Log level |
|
| Mermaid API address |
|
| Request timeout (seconds) |
|
| Debug mode |
|
| Development mode |
|
Available Tools
1. convert_mermaid_to_image
Converts Mermaid diagram code into image files in multiple formats
Parameters:
mermaid_code(string): Mermaid diagram codeoutput_format(string, optional): Output format, supports png, jpg, svg, pdf; default "png"theme(string, optional): Theme style, supports default, dark, neutral, forest; default "default"background_color(string, optional): Background color, hexadecimal codewidth(number, optional): Image width (pixels)height(number, optional): Image height (pixels)
Supported output formats: PNG, JPG, SVG, PDF
2. validate_mermaid_syntax
Validates the syntax correctness of Mermaid diagram code
Parameters:
mermaid_code(string): Mermaid diagram code to validate
Return results:
valid(boolean): Whether validation passederror_message(string): Error message (if validation fails)
3. get_supported_options
Gets the options supported by the converter
Return results:
themes(array): List of supported themesformats(array): List of supported formats
Supported Diagram Types
Flowchart: Used to represent processes and algorithms
Sequence Diagram: Used to represent interactions between objects
Gantt Chart: Used for project schedule management
Pie Chart: Used to represent data proportions
Git Graph: Used to represent Git commit history
Mind Map: Used to represent knowledge structures
Class Diagram: Used to represent class structures
Usage Examples
Flowchart Example
请使用 convert_mermaid_to_image 工具生成一个流程图:
flowchart TD
A[开始] --> B{判断条件}
B -->|是 | C[执行动作 1]
B -->|否 | D[执行动作 2]
C --> E[结束]
D --> ESequence Diagram Example
请使用 convert_mermaid_to_image 工具生成一个时序图,使用深色主题:
sequenceDiagram
participant 用户
participant 系统
participant 数据库
用户->>系统:登录请求
系统->>数据库:验证用户
数据库-->>系统:返回结果
系统-->>用户:登录成功Syntax Validation Example
首先使用 validate_mermaid_syntax 验证语法,然后使用 convert_mermaid_to_image 生成图表Resource Examples
Getting Diagram Examples
You can retrieve different types of diagram examples through the following resource URIs:
mermaid://examples/flowchart- Flowchart examplemermaid://examples/sequence- Sequence diagram examplemermaid://examples/gantt- Gantt chart examplemermaid://examples/pie- Pie chart examplemermaid://examples/gitgraph- Git graph examplemermaid://examples/mindmap- Mind map examplemermaid://examples/class- Class diagram example
Project Structure
mermaid_mcp_server/
├── mermaid_mcp_server/ # 核心模块
│ ├── __init__.py
│ └── main.py # 主程序入口
├── requirements.txt # 依赖列表(pip)
├── pyproject.toml # 项目配置(uv)
├── .env.example # 环境变量示例
├── README.md # 项目文档
└── .vscode/ # VSCode 配置
└── settings.jsonDevelopment Guide
Local Development
# 克隆仓库
git clone https://github.com/wwwzhouhui/mermaid_mcp_server.git
cd mermaid_mcp_server
# 安装依赖
uv sync
# 配置环境变量
cp .env.example .env
# 启动服务(STDIO 模式)
uv run python main.py
# 启动服务(SSE 模式)
uv run python main.py --sseDebug Mode
Enable verbose logging output:
export LOG_LEVEL=DEBUG
uv run python main.pyFrequently Asked Questions
A:
Check network connection and firewall settings
Confirm the mermaid.ink API is accessible
Check proxy settings
A:
Use the validate_mermaid_syntax tool to check syntax
Refer to the official Mermaid documentation
Use the code from the example resources
A:
Simplify the diagram content
Split it into multiple smaller diagrams
Adjust the image dimension parameters
A:
Install the uv package manager:
curl -LsSf https://astral.sh/uv/install.sh | shOr install the package globally with pip
Check the PATH environment variable
A:
Confirm the service has been started in SSE mode
Check whether port 8003 is occupied
Confirm the URL configuration is correct
A:
Increase the image dimension parameters
Choose an appropriate theme
Optimize the Mermaid code structure
A:
Check the network connection speed
Increase the REQUEST_TIMEOUT environment variable
Simplify the diagram complexity
A:
Confirm the theme name is spelled correctly
Check whether the theme is supported
Try using a different theme name
A:
Use the background_color parameter
The format is a hexadecimal color code (e.g., #FFFFFF)
Only supported for some output formats
Technical Community Group
Welcome to join the technical community group to share your usage experience and feedback:

Author Contact
WeChat: laohaibao2025
Email: 75271002@qq.com

Donations
If this project has been helpful to you, feel free to buy me a coffee ☕
WeChat Pay

Star History
If you like the project, feel free to give it a Star ⭐
License
MIT License
Changelog
v0.1.0 (Current version)
✅ Initial version released
✅ Supports multi-format output for PNG, JPG, SVG, PDF
✅ Integrates four theme styles (default, dark, neutral, forest)
✅ Provides syntax validation and example resource features
✅ Supports STDIO and SSE dual-mode communication
v0.0.3 (2025-07-21)
✅ Initial version released
✅ Supports multi-format diagram conversion
✅ Syntax validation feature
✅ Example resource feature
Contribution Guide
Welcome to submit Issues and Pull Requests to improve this project!
Fork this repository
Create a feature branch:
git checkout -b feature/amazing-featureCommit your changes:
git commit -m 'Add amazing feature'Push to the branch:
git push origin feature/amazing-featureSubmit a Pull Request
Notes
Diagram generation may take a few seconds, please be patient
Ensure the network connection is normal; the service depends on the mermaid.ink online API
Generated image data is returned in base64 format
Complex diagrams may require longer generation time
Enjoy creating beautiful diagrams with Mermaid! 🎨✨
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 Servers
- AlicenseBqualityCmaintenanceA Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.1360233MIT
- AlicenseBqualityBmaintenanceA Model Context Protocol server that validates and renders Mermaid diagrams.178856MIT
- -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 Model Context Protocol server that converts SVG code to PNG images, offering two conversion methods (CairoSVG and Inkscape) with support for custom working directories.3
Related MCP Connectors
A Model Context Protocol server for Wix AI tools
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Generate dynamic Mermaid diagrams and charts with AI assistance. Customize styles and export diagr…
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/wwwzhouhui/mermaid_mcp_server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server