MCP Mermaid Image Gen
Generates diagrams from Mermaid syntax (flowcharts, sequence diagrams, class diagrams, etc.) in multiple output formats including PNG, PDF, and SVG, with support for multiple themes and customizable backgrounds.
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., "@MCP Mermaid Image Gengenerate a flowchart for user login"
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.
MCP Mermaid Image Gen
An MCP server that generates diagrams from Mermaid code in multiple formats (primarily PNG and PDF, with SVG also available). This server enables AI assistants and other MCP clients to create diagrams using the Mermaid diagram syntax, with support for multiple themes, formats, and customizable backgrounds.
Overview
This MCP server wraps the Mermaid CLI (@mermaid-js/mermaid-cli) to provide diagram generation capabilities through the Model Context Protocol (MCP). It offers two operation modes:
File-based: Save diagrams to disk and return the file path
Stream-based: Return the diagram directly as base64-encoded data
Both modes work with either STDIO or SSE transport, but the stream-based mode requires an MCP client capable of handling image data.
The server is designed to be used by AI coding assistants and other tools that support the MCP protocol, allowing them to generate diagrams without needing direct access to the Mermaid CLI.
📚 For AI Assistants: See AI_SETUP_GUIDE.md for a structured guide to help users with installation.
Related MCP server: vaults-diagram-tools
Features
Generate diagrams from Mermaid syntax (flowcharts, sequence diagrams, class diagrams, etc.)
Multiple output formats:
PNG: Raster graphics, recommended for general use and broad compatibility.
PDF: Document format, perfect for print and formal documentation.
SVG: Vector graphics, available for web and scalable diagrams where specifically needed.
Support for multiple themes (default, neutral, dark, forest, base)
Customizable background colors (hex codes or named colors)
Two operation modes (both available in STDIO and SSE transport):
File-based: Save diagrams to disk and return the path
Stream-based: Return base64-encoded diagram data (requires MCP client with image support)
Comprehensive error handling and validation
Detailed logging with configurable levels
Prerequisites
Required
UV Package Manager: Install using the official installer or via
curl -LsSf https://astral.sh/uv/install.sh | shon Unix-like systems.Operating Systems: Linux, macOS, Windows are supported.
Auto-Managed (Optional Manual Install)
Node.js: Version 14 or higher. The server will attempt to use system Node.js if available.
Mermaid CLI: The server will automatically install a local copy if not found in PATH. For manual system-wide installation:
npm install -g @mermaid-js/mermaid-cli
🚀 Auto-Installation Feature: If Node.js is available but the Mermaid CLI (
mmdc) is not found, the server will automatically install it to a user-specific directory (~/.local/share/mcp_mermaid_image_gen/on Linux/macOS or%LOCALAPPDATA%\mcp_mermaid_image_gen\on Windows). This happens transparently on first use.
Installation Methods
Primary Method: UV Tool Install (Recommended)
The most reliable way to install this MCP server is using uv tool install. This creates an isolated environment and installs the server with all its dependencies:
# Install the MCP server as a UV tool
uv tool install mcp-mermaid-image-gen
# Verify installation and find the binary location
uv tool list | grep mcp-mermaid-image-gen
# Note the installation path shown in the outputFallback Method: UVX (Direct Execution)
⚠️ Warning: This method may encounter dependency conflicts if other tools in your environment use incompatible versions of shared dependencies.
# Run directly with uvx (downloads and caches on first run)
uvx mcp-mermaid-image-genPlatform-Specific Binary Locations
After installation with uv tool install, find your binary location:
macOS
# Binary typically installed at:
~/.local/bin/mcp-mermaid-image-gen
# Verify exact location:
which mcp-mermaid-image-genLinux
# Binary typically installed at:
~/.local/bin/mcp-mermaid-image-gen
# Verify exact location:
which mcp-mermaid-image-genWindows
# Binary typically installed at:
%USERPROFILE%\.local\bin\mcp-mermaid-image-gen.exe
# Verify exact location:
where mcp-mermaid-image-genConfiguring Your MCP Client
Claude Desktop Configuration
Configure Claude Desktop by editing the claude_desktop_config.json file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
Option 1: Using UV Tool (After Installation)
{
"mcpServers": {
"mermaid_image_generator": {
"command": "/absolute/path/to/mcp-mermaid-image-gen"
}
}
}Replace /absolute/path/to/mcp-mermaid-image-gen with the actual path from the verification step above.
Option 2: Using UVX (Direct Execution)
{
"mcpServers": {
"mermaid_image_generator": {
"command": "uvx",
"args": [
"mcp-mermaid-image-gen"
]
}
}
}Other MCP Clients
Adapt the configuration to your client's format, using either:
The absolute path to the installed binary (Option 1)
The
uvxcommand withmcp-mermaid-image-genas an argument (Option 2)
Development Installation
For contributing to the server or running a modified version:
# Clone the repository
git clone https://github.com/yourusername/mcp_mermaid_image_gen.git
cd mcp_mermaid_image_gen
# Create and activate a virtual environment using UV
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install in development mode
uv pip install -e .
# Find the development binary
which mcp-mermaid-image-genDevelopment Configuration Example
{
"mcpServers": {
"mermaid_image_generator_dev": {
"command": "/path/to/your/project/.venv/bin/mcp-mermaid-image-gen"
}
}
}Troubleshooting
Dependency Conflicts
If you encounter dependency conflicts when using uvx:
Use
uv tool installinstead for a fully isolated environmentCheck for conflicting packages:
uv tool listIf issues persist, uninstall and reinstall:
uv tool uninstall mcp-mermaid-image-gen uv tool install mcp-mermaid-image-gen
Binary Not Found
If the MCP client can't find the binary:
Verify installation:
uv tool list | grep mcp-mermaid-image-genCheck PATH: Ensure
~/.local/binis in your PATHUse the absolute path in your client configuration
Testing with MCP Inspector
The MCP SDK includes a development console (MCP Inspector) that allows you to test the server interactively. After installation, run:
mcp dev mcp_mermaid_image_gen/server/app.pyThis will:
Start the MCP Inspector web interface
Allow testing via both STDIO and SSE transport modes
Provide a UI for calling the server's tools
Display returned images directly in the browser
Show detailed logs and debugging information
The Inspector is particularly useful for:
Testing different diagram types
Trying out various formats (PNG, PDF, and SVG)
Experimenting with themes and colors
Debugging issues with Mermaid syntax
Verifying both file and stream-based operation modes
Available Tools
generate_mermaid_diagram_file
Generates a Mermaid diagram and saves it to a local file.
Parameters:
code(str): Mermaid diagram syntaxfolder(str): Output directory pathname(str): Output filename (extension can determine format)theme(str, optional): Theme name (default, neutral, dark, forest, base)backgroundColor(str, optional): Background color (hex or named color)format(str, optional): Output format. Recommended: "png". Also supports "pdf". "svg" is available but not recommended for general use. If not specified:Inferred from filename extension (e.g., "diagram.png" -> png).
Defaults to "png" if no valid extension or format is provided.
Returns: Path to the generated file
Format Selection Priority:
Explicit
formatparameter if providedFile extension in
nameparameter if validDefaults to PNG if neither is specified
generate_mermaid_diagram_stream
Generates a Mermaid diagram and returns it directly as base64-encoded data. Requires an MCP client that supports handling image data (like the MCP Inspector).
Parameters:
code(str): Mermaid diagram syntaxtheme(str, optional): Theme name (default, neutral, dark, forest, base)backgroundColor(str, optional): Background color (hex or named color)format(str, optional): Output format. Recommended: "png". Also supports "pdf". "svg" is available but not recommended. Defaults to "png" if not specified.
Returns: Base64-encoded diagram data with appropriate MIME type:
PNG:
image/pngPDF:
application/pdfSVG:
image/svg+xml(available if explicitly requested)
Transport Modes
Both STDIO and SSE transport modes support all server functionality. The choice between them depends on your use case:
STDIO Mode (Default)
Synchronous operation
Simple command-line integration
Works with all tools and operation modes
Ideal for scripts and command-line tools
Example client: MCP Inspector, Cursor
SSE Mode
Asynchronous operation
HTTP-based communication
Works with all tools and operation modes
Ideal for web applications and services
Example client: MCP Inspector, web applications
Client Compatibility
The server supports any MCP client, but some features require specific client capabilities:
File-based generation (
generate_mermaid_diagram_file):Requires client to have file system access
Works with all MCP clients
Client must be able to read the returned file path
Stream-based generation (
generate_mermaid_diagram_stream):Requires client capable of handling base64-encoded image data
Works with MCP Inspector and other image-capable clients
No file system access needed
The MCP Inspector (included with the MCP SDK) supports all features in both transport modes.
Usage
The server provides two entry points:
mcp_mermaid_image_gen-server: The MCP server# Run with stdio transport (default) mcp_mermaid_image_gen-server # Run with SSE transport mcp_mermaid_image_gen-server --transport sse --port 3001mcp_mermaid_image_gen-client: Test client (for development)mcp_mermaid_image_gen-client "your mermaid code here"
Logging
The server logs all activity to both stderr and a rotating log file. Log files are stored in OS-specific locations:
macOS:
~/Library/Logs/mcp-servers/mcp_mermaid_image_gen.logLinux:
Root user:
/var/log/mcp-servers/mcp_mermaid_image_gen.logNon-root:
~/.local/state/mcp-servers/logs/mcp_mermaid_image_gen.log
Windows:
%USERPROFILE%\AppData\Local\mcp-servers\logs\mcp_mermaid_image_gen.log
Log files are automatically rotated when they reach 10MB, with up to 5 backup files kept.
Configure logging level with the LOG_LEVEL environment variable:
LOG_LEVEL=DEBUG mcp_mermaid_image_gen-serverValid log levels: DEBUG, INFO (default), WARNING, ERROR, CRITICAL
Author
Tim Kitchens (timkitch@codingthefuture.ai)
License
This project is licensed under the MIT License. See the LICENSE file for details.
Available Tools
2 toolsgenerate_mermaid_diagram_fileA
Generate a Mermaid diagram and save it to a local file system directory.
SYSTEM PREREQUISITES:
Node.js must be installed (v14 or higher)
Mermaid CLI must be installed globally: npm install -g @mermaid-js/mermaid-cli
The 'mmdc' command must be available in the system PATH
Python 3.8 or higher with MCP tools installed
IMPORTANT TRANSPORT & ACCESS REQUIREMENTS:
Works with both STDIO and SSE transport modes
REQUIRES: The MCP client (e.g., AI assistant) must have access to the local file system where the image is saved
The client must have write permissions for the specified folder
PARAMETER GUIDANCE:
code: Valid Mermaid diagram syntax (see https://mermaid.js.org/)
folder: Absolute or relative path to an existing directory with write permissions
name: Filename for the diagram (extension can determine format if format not specified)
theme: Theme name for the diagram. MUST be one of: ["default", "neutral", "dark", "forest", "base"]
default: Default theme for all diagrams
neutral: Great for black and white documents that will be printed
dark: Works well with dark-colored elements or dark-mode
forest: Contains shades of green
base: The only theme that can be modified for customization
backgroundColor: Optional hex color code (e.g., '#FFFFFF') or color name (e.g., 'white', 'transparent')
format: Output format. Recommended: "png". Also supports "pdf". "svg" is available but not recommended for general use. If not specified:
Inferred from filename extension (e.g., "diagram.png" -> png).
Defaults to "png" if no valid extension or format is provided.
RESPONSE:
Returns the absolute path to the generated file
The client must be able to access this path to use the generated image
USE CASE: Best suited for scenarios where:
The client needs to persist the diagram to disk
The client has local file system access
The client needs to reference the image file path in subsequent operations
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| folder | Yes | ||
| name | Yes | ||
| theme | No | ||
| backgroundColor | No | ||
| format | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, so description carries full burden. It covers transport modes, prerequisites, and response format. However, it does not disclose behaviors like overwriting files, error handling if folder is missing, or side effects.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Well-structured with clear sections (purpose, prerequisites, parameter guidance, response, use case). Slightly lengthy but each section adds value. Front-loaded with primary purpose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no output schema and 6 parameters, description provides thorough guidance on parameters, prerequisites, and use cases. Lacks error handling details and examples, but is largely complete for typical usage.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, but description's PARAMETER GUIDANCE section provides detailed explanations for all 6 parameters, including options for theme, format inference, and background color. This adds significant value beyond the bare schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the specific verb 'generate' and resource 'Mermaid diagram' and the action of saving to file system. It distinguishes from the sibling tool 'generate_mermaid_diagram_stream' by focusing on file persistence.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides a USE CASE section with explicit scenarios (client needs to persist to disk, has local FS access, needs file path). It also includes SYSTEM PREREQUISITES and ACCESS REQUIREMENTS. However, it does not explicitly state when not to use this tool vs the sibling stream tool.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
generate_mermaid_diagram_streamA
Generate a Mermaid diagram and return it directly as a base64-encoded image.
SYSTEM PREREQUISITES:
Node.js must be installed (v14 or higher)
Mermaid CLI must be installed globally: npm install -g @mermaid-js/mermaid-cli
The 'mmdc' command must be available in the system PATH
Python 3.8 or higher with MCP tools installed
MCP client must support SSE transport and binary/base64 image handling
IMPORTANT TRANSPORT REQUIREMENTS:
REQUIRES SSE TRANSPORT MODE ONLY
Will NOT work with STDIO transport
DO NOT use this endpoint if your MCP client doesn't support SSE transport
DO NOT use this endpoint if your client can't handle binary/base64 image data
PARAMETER GUIDANCE:
code: Valid Mermaid diagram syntax (see https://mermaid.js.org/)
theme: Theme name for the diagram. MUST be one of: ["default", "neutral", "dark", "forest", "base"]
default: Default theme for all diagrams
neutral: Great for black and white documents that will be printed
dark: Works well with dark-colored elements or dark-mode
forest: Contains shades of green
base: The only theme that can be modified for customization
backgroundColor: Optional hex color code (e.g., '#FFFFFF') or color name (e.g., 'white', 'transparent')
format: Output format. Recommended: "png". Also supports "pdf". "svg" is available but not recommended. Defaults to "png" if not specified.
RESPONSE:
Returns the diagram as a base64-encoded image in the specified format
No file system access or permissions required
Image data is streamed directly back to the client
USE CASE: Best suited for scenarios where:
The client is using SSE transport mode
The client can handle base64-encoded image data
No need to persist the image to disk
No file system access is available or desired
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| theme | No | ||
| backgroundColor | No | ||
| format | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description provides extensive behavioral details: system prerequisites, transport constraints, no file system access, and direct base64 streaming. However, it lacks specifics about error handling or behavior when prerequisites are not met.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with clear sections and front-loaded purpose. While somewhat verbose, the level of detail is justified given the tool's complexity (streaming, prerequisites, transport). Could be slightly more concise but remains effective.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers system prerequisites, parameter usage, response format, and use cases, which is comprehensive for a tool with 4 parameters and no output schema. It could mention potential errors or limitations, but overall it provides sufficient context for an agent to decide to invoke the tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 0% description coverage, but the description compensates fully by explaining each parameter's purpose, allowed values for theme, formatting guidance for backgroundColor and format, and default behaviors. This adds significant value beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: generate a Mermaid diagram and return it as a base64-encoded image. It distinguishes from the sibling tool 'generate_mermaid_diagram_file' by emphasizing streaming and no file persistence.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides explicit when-to-use and when-not-to-use guidance, including system prerequisites, transport requirements (SSE only), and a dedicated 'USE CASE' section. It implicitly contrasts with the sibling tool for file-based persistence.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
Each tool has a distinct output method: file persistence vs. base64 streaming. No ambiguity between them.
Both tools follow the same verb_noun pattern 'generate_mermaid_diagram_' with a suffix differentiating output type ('file' vs 'stream').
Only 2 tools, but they cover the two primary output modes for a focused diagram generation server. Slightly thin but reasonable.
Core functionality of generating Mermaid diagrams as images is covered via file and stream. Lacks SVG-specific handling or validation tools, but these are minor gaps.
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 Connectors
Render, verify, describe, and safely edit Mermaid diagrams through MCP.
Create and manage Mermaid.js flowcharts and diagrams with AI agents via MCP.
MCP server for generating rough-draft project plans from natural-language prompts.
Collaborative whiteboard MCP server — create objects, connectors, C4 diagrams, and manage boards
Related MCP Servers
- AlicenseBqualityCmaintenanceA Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.1266234MIT
- AlicenseNot gradedqualityBmaintenanceMCP server for rendering Mermaid diagrams and generating source-code diagrams, with tools to render text/files and produce dependency/class diagrams.96MIT
- FlicenseNot gradedqualityDmaintenanceMCP server that generates Mermaid diagrams with live browser preview, supports real-time rendering and SVG/PNG export.12
- AlicenseAqualityAmaintenanceMCP server for creating and editing diagrams using draw.io. Allows generating diagrams from Mermaid or XML, searching shapes, and opening them in draw.io for export.20Apache 2.0
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/codingthefuturewithai/mcp_mermaid_image_gen'
If you have feedback or need assistance with the MCP directory API, please join our Discord server