Mermaid (peng-shawn)

Design and media

A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.

Your AI app calls the Mermaid (peng-shawn) MCP server, which does the design and media work and sends the result back to the chat.

About Mermaid (peng-shawn)

Mermaid (peng-shawn) is a community MCP server from peng-shawn, filed in our directory under design and media. A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.

Mermaid (peng-shawn) runs on your own machine: your AI app starts it with the command npx -y tsc and talks to it over standard input and output.

At a glance

Publisher
peng-shawn (community)
Runs
Locally on your machine
Install from
Node.js package on npm: tsc
Written in
TypeScript
License
MIT
GitHub stars
234

How to set up Mermaid (peng-shawn)

  1. Install Node.js on the machine that runs your AI app, because Mermaid (peng-shawn) starts with npx and downloads its package on first run.
  2. Check the Mermaid (peng-shawn) README for keys or settings; the registry lists none that Mermaid (peng-shawn) requires.
  3. Add Mermaid (peng-shawn) to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the Mermaid (peng-shawn) tools to confirm the connection.
  5. Run one read-only task with Mermaid (peng-shawn) first, and keep your app asking before each tool call until the results look right.

Mermaid (peng-shawn) compared with similar servers

  • Magicuidesign by magicuidesign has fewer GitHub stars than Mermaid (peng-shawn) (233 against 234); both are community servers, and both run locally.
  • Feedback Collector by sanshao85 has fewer GitHub stars than Mermaid (peng-shawn) (234 against 234); both are community servers, and both run locally.
  • Solidworks by alisamsam has fewer GitHub stars than Mermaid (peng-shawn) (232 against 234); both are community servers, and both run locally.

Before you connect Mermaid (peng-shawn)

  • Give Mermaid (peng-shawn) its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each Mermaid (peng-shawn) tool call until you trust what it does with them.
  • Treat text that Mermaid (peng-shawn) fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for Mermaid (peng-shawn) on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for Mermaid (peng-shawn)

How marketing and sales teams put Mermaid (peng-shawn) to work, by company size. Pick the size closest to yours and start Mermaid (peng-shawn) on one use case.

Small business

  • A small business can use Mermaid (peng-shawn) to resize and adapt one design for every channel instead of hiring for each version.
  • Owners can ask Mermaid (peng-shawn) to pull brand assets and make quick ad and social variations that still look on brand.
  • Mermaid (peng-shawn) runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Creative teams can connect Mermaid (peng-shawn) so agents produce variants for testing while designers keep control of the master files.
  • Marketing teams can use Mermaid (peng-shawn) to hand off designs to web and ads with specs attached, cutting review rounds.
  • Start Mermaid (peng-shawn) on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprises can use Mermaid (peng-shawn) with brand rules and approved assets only, so generated work stays inside the brand system.
  • Large creative ops teams can use Mermaid (peng-shawn) to localize and version assets for many markets with review built in.
  • Mermaid (peng-shawn) is a community server, so have security review the code and pin a version before Mermaid (peng-shawn) touches company data.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

Mermaid (peng-shawn) README

From peng-shawn/mermaid-mcp-server on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

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:

  1. Launching a headless browser instance
  2. Creating an HTML template with the Mermaid code
  3. Loading the Mermaid.js library
  4. Rendering the diagram to SVG
  5. Either saving the SVG directly or taking a screenshot as PNG
  6. 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 @latest so npx picks 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 modelcontextprotocol.io/docs/tools/inspector.

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:

  1. The server now attempts to use Puppeteer's bundled browser by default

  2. If you encounter browser-related errors, you have two options:

    Option 1: During Docker image build:

    • Set PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true when installing Puppeteer
    • Install Chrome/Chromium in your Docker container
    • Set PUPPETEER_EXECUTABLE_PATH at runtime to point to the Chrome installation

    Option 2: Use Puppeteer's bundled Chrome:

    • Ensure your Docker container has the necessary dependencies for Chrome
    • No need to set PUPPETEER_SKIP_CHROMIUM_DOWNLOAD
    • The code will use the bundled browser automatically

For Smithery users, the latest version should work without additional configuration.

API

The server exposes a single tool:

  • generate: Converts Mermaid diagram code to a PNG image or SVG file
    • Parameters:
      • code: The Mermaid diagram code to render
      • theme: (optional) Theme for the diagram. Options: "default", "forest", "dark", "neutral"
      • backgroundColor: (optional) Background color for the diagram, e.g. 'white', 'transparent', '#F0F0F0'
      • outputFormat: (optional) Output format for the diagram. Options: "png", "svg" (defaults to "png")
      • name: Name for the generated file (required when CONTENT_IMAGE_SUPPORTED=false)
      • folder: Absolute path to save the image/SVG to (required when CONTENT_IMAGE_SUPPORTED=false)

The behavior of the generate tool depends on the CONTENT_IMAGE_SUPPORTED environment variable:

  • When CONTENT_IMAGE_SUPPORTED=true (default): The tool returns the image/SVG directly in the response
  • When CONTENT_IMAGE_SUPPORTED=false: The tool saves the image/SVG to the specified folder and returns the file path

Environment Variables

  • CONTENT_IMAGE_SUPPORTED: Controls whether images are returned directly in the response or saved to disk
    • true (default): Images are returned directly in the response
    • false: Images are saved to disk, requiring name and folder parameters

Examples

Basic Usage
// Generate a flowchart with default settings
{
  "code": "flowchart TD\n    A[Start] --> B{Is it?}\n    B -->|Yes| C[OK]\n    B -->|No| D[End]"
}
With Theme and Background Color
// Generate a sequence diagram with forest theme and light gray background
{
  "code": "sequenceDiagram\n    Alice->>John: Hello John, how are you?\n    John-->>Alice: Great!",
  "theme": "forest",
  "backgroundColor": "#F0F0F0"
}
Saving to Disk (when CONTENT_IMAGE_SUPPORTED=false)
// Generate a class diagram and save it to disk as PNG
{
  "code": "classDiagram\n    Class01 <|-- AveryLongClass\n    Class03 *-- Class04\n    Class05 o-- Class06",
  "theme": "dark",
  "name": "class_diagram",
  "folder": "/path/to/diagrams"
}
Generating SVG Output
// Generate a state diagram as SVG
{
  "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"
}

FAQ

Doesn't Claude desktop already support mermaid via canvas?

Yes, but it doesn't support the theme and backgroundColor options. Plus, having a dedicated server makes it easier to create mermaid diagrams with different MCP clients.

Why do I need to specify CONTENT_IMAGE_SUPPORTED=false when using with Cursor?

Cursor doesn't support inline images in responses yet.

Publishing

This project uses GitHub Actions to automate the publishing process to npm.

Method 1: Using the Release Script (Recommended)
  1. Make sure all your changes are committed and pushed

  2. Run the release script with either a specific version number or a semantic version increment:

    # Using a specific version number
    npm run release 0.1.4
    
    # Using semantic version increments
    npm run release patch  # Increments the patch version (e.g., 0.1.3 → 0.1.4)
    npm run release minor  # Increments the minor version (e.g., 0.1.3 → 0.2.0)
    npm run release major  # Increments the major version (e.g., 0.1.3 → 1.0.0)
    
  3. The script will:

    • Validate the version format or semantic increment
    • Check if you're on the main branch
    • Detect and warn about version mismatches between files
    • Update all version references consistently (package.json, package-lock.json, and index.ts)
    • Create a single commit with all version changes
    • Create and push a git tag
    • The GitHub workflow will then automatically build and publish to npm
Method 2: Manual Process
  1. Update your code and commit the changes
  2. Create and push a new tag with the version number:
    git tag v0.1.4  # Use the appropriate version number
    git push origin v0.1.4
    
  3. The GitHub workflow will automatically:
    • Build the project
    • Publish to npm with the version from the tag

Note: You need to set up the NPM_TOKEN secret in your GitHub repository settings. To do this:

  1. Generate an npm access token with publish permissions
  2. Go to your GitHub repository → Settings → Secrets and variables → Actions
  3. Create a new repository secret named NPM_TOKEN with your npm token as the value

Badges

License

MIT

Questions about Mermaid (peng-shawn)

What is the Mermaid (peng-shawn) MCP server?

A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images. Mermaid (peng-shawn) is maintained by peng-shawn on GitHub at peng-shawn/mermaid-mcp-server, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the Mermaid (peng-shawn) MCP server?

Add Mermaid (peng-shawn) to your AI app's MCP config with the command npx -y tsc. In Claude Code, run claude mcp add --transport stdio mermaid -- npx -y tsc. To run Mermaid (peng-shawn) this way you need Node.js installed.

Does Mermaid (peng-shawn) need an API key?

The registry lists no required keys for Mermaid (peng-shawn). Check the Mermaid (peng-shawn) README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is Mermaid (peng-shawn) an official MCP server?

No. Mermaid (peng-shawn) is a community server maintained by peng-shawn. Community servers can be excellent; read the code and the open issues before you give Mermaid (peng-shawn) access to company data.

What license is Mermaid (peng-shawn) under?

Mermaid (peng-shawn) is released under the MIT license, according to its GitHub repository. The license covers the code of Mermaid (peng-shawn); the service it connects to has its own terms.