The Mermaid MCP Server converts Mermaid diagram code into PNG images or SVG files. This tool enables AI assistants and applications to generate visual diagrams from textual descriptions using Mermaid markdown syntax, with support for multiple themes and customizable backgrounds.
npm install @peng-shawn/mermaid-mcp-server
For Claude Desktop, you can automatically install using Smithery:
npx -y @smithery/cli install @peng-shawn/mermaid-mcp-server --client claude
Add the following to your Claude Desktop configuration:
{
"mcpServers": {
"mermaid": {
"command": "npx",
"args": ["-y", "@peng-shawn/mermaid-mcp-server"]
}
}
}
When using with Cursor or Cline, run:
env CONTENT_IMAGE_SUPPORTED=false npx -y @peng-shawn/mermaid-mcp-server
npx @modelcontextprotocol/inspector node dist/index.js
CONTENT_IMAGE_SUPPORTED
: Controls image handling
true
(default): Images are returned directly in the responsefalse
: Images are saved to disk (requires name
and folder
parameters){
"code": "flowchart TD\n A[Start] --> B{Is it?}\n B -->|Yes| C[OK]\n B -->|No| D[End]"
}
{
"code": "sequenceDiagram\n Alice->>John: Hello John, how are you?\n John-->>Alice: Great!",
"theme": "forest",
"backgroundColor": "#F0F0F0"
}
{
"code": "classDiagram\n Class01 <|-- AveryLongClass\n Class03 *-- Class04\n Class05 o-- Class06",
"theme": "dark",
"name": "class_diagram",
"folder": "/path/to/diagrams"
}
{
"code": "stateDiagram-v2\n [*] --> Still\n Still --> [*]\n Still --> Moving\n Moving --> Still\n Moving --> Crash\n Crash --> [*]",
"outputFormat": "svg",
"name": "state_diagram",
"folder": "/path/to/diagrams"
}
The server provides a single tool:
Converts Mermaid diagram code to a PNG image or SVG file
Parameters:
code
: The Mermaid diagram code to rendertheme
: (optional) Diagram theme - "default", "forest", "dark", or "neutral"backgroundColor
: (optional) Background color (e.g., 'white', 'transparent', '#F0F0F0')outputFormat
: (optional) "png" or "svg" (defaults to "png")name
: Filename for the generated file (required when CONTENT_IMAGE_SUPPORTED=false)folder
: Absolute path to save the image/SVG (required when CONTENT_IMAGE_SUPPORTED=false)When running in Docker containers:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
during installationPUPPETEER_EXECUTABLE_PATH
to point to ChromePUPPETEER_SKIP_CHROMIUM_DOWNLOAD
CONTENT_IMAGE_SUPPORTED=false
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.