Render Mermaid diagram to PNG
render_mermaidConvert Mermaid diagram markup to a PNG image. Preview inline or save to disk with an optional output path.
Instructions
Render Mermaid diagram markup to a PNG image. Returns the image inline so it can be previewed. If outputPath (an absolute .png path) is provided, the PNG is also saved there and the path is returned. Useful for turning AI-generated Mermaid (flowcharts, sequence, class, ER, gantt, state diagrams, etc.) into images.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"diagram": "<diagram>"
},
"name": "render_mermaid"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| diagram | Yes | Mermaid diagram source, e.g. `graph TD; A-->B;` | |
| outputPath | No | Absolute path ending in .png to save the image to. Omit to only return the image inline. | |
| theme | No | Mermaid theme. Defaults to "default". | |
| backgroundColor | No | Background color, e.g. "white", "transparent", "#ffffff". Defaults to "white". | |
| width | No | Output width in pixels. | |
| height | No | Output height in pixels. | |
| scale | No | Device scale factor; higher = sharper/larger PNG. Defaults to 1. |