
peng-shawn/mermaid-mcp-server 是从 https://github.com/peng-shawn/mermaid-mcp-server. 导入的 MCP 服务器候选。
概览
peng-shawn/mermaid-mcp-server 是从 https://github.com/peng-shawn/mermaid-mcp-server. 导入的 MCP 服务器候选。
概述(AI 翻译)
一个模型上下文协议(MCP)服务器,将美人鱼图转换为PNG图像或SVG文件。该服务器允许AI助手和其他应用利用美人鱼标记语法从文本描述生成视觉图。
特色
- 将美人鱼图代码转换为PNG图像或SVG文件
- 支持多种图示主题(默认、森林、暗、中性)
- 可自定义背景颜色
- 使用 Puppeteer 进行高质量无头浏览器渲染
- 实现MCP协议,实现与AI助手的无缝集成
- 灵活输出选项:直接返回图片/SVG 或保存到磁盘
- 错误处理,包含详细的错误信息
工作原理
服务器使用 Puppeteer 启动无头浏览器,将美人鱼图渲染为 SVG,并可选地截图渲染图。该过程包括:
- 启动无头浏览器实例
- 用美人鱼代码创建HTML模板
- 加载Mermaid.js库
- 将图示渲染为SVG
- 直接保存SVG或截图为PNG
- 直接返回图片/SVG 或保存到磁盘
建造
用途
与 Claude 桌面版的使用
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Mermaid MCP Server
A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images or SVG files. This server allows AI assistants and other applications to generate visual diagrams from textual descriptions using the Mermaid markdown syntax.
Features
- Converts Mermaid diagram code to PNG images or SVG files
- Supports multiple diagram themes (default, forest, dark, neutral)
- Customizable background colors
- Uses Puppeteer for high-quality headless browser rendering
- Implements the MCP protocol for seamless integration with AI assistants
- Flexible output options: return images/SVG directly or save to disk
- Error handling with detailed error messages
How It Works
The server uses Puppeteer to launch a headless browser, render the Mermaid diagram to SVG, and optionally capture a screenshot of the rendered diagram. The process involves:
- Launching a headless browser instance
- Creating an HTML template with the Mermaid code
- Loading the Mermaid.js library
- Rendering the diagram to SVG
- Either saving the SVG directly or taking a screenshot as PNG
- Either returning the image/SVG directly or saving it to disk
Requirements
- Node.js 22.12.0 or later
Security notice: versions before 0.3.0 depend on Puppeteer and Mermaid releases with known vulnerabilities. Please upgrade to 0.3.0 or later. The configurations below use
@latestsonpxpicks up new releases.
Build
npx tsc
Usage
Use with Claude desktop
{
"mcpServers": {
"mermaid": {
"command": "npx",
"args": ["-y", "@peng-shawn/mermaid-mcp-server@latest"]
}
}
}
Use with Cursor and Cline
env CONTENT_IMAGE_SUPPORTED=false npx -y @peng-shawn/mermaid-mcp-server@latest
You can find a list of mermaid diagrams under ./diagrams, they are created using Cursor agent with prompt: “generate mermaid diagrams and save them in a separate diagrams folder explaining how renderMermaidPng work”
Run with inspector
Run the server with inspector for testing and debugging:
npx @modelcontextprotocol/inspector node dist/index.js
The server will start and listen on stdio for MCP protocol messages.
Learn more about inspector here.
Installing via Smithery
To install Mermaid Diagram Generator for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @peng-shawn/mermaid-mcp-server --client claude
Docker and Smithery Environments
When running in Docker containers (including via Smithery), you may need to handle Chrome dependencies:
-
The server now attempts to use Puppeteer’s bundled browser by default
-
If you encounter browser-related errors, you have two options:
Option 1: During Docker image build:
- Set
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=truewhen installing Puppeteer
- Set
安装
npx -y @peng-shawn/mermaid-mcp-server@latest配置
{
"mcpServers": {
"mermaid": {
"command": "npx",
"args": ["-y", "@peng-shawn/mermaid-mcp-server@latest"]
}
}
}