home / mcp / mermaid mcp server

Mermaid MCP Server

Turns local or GitHub codebases into Mermaid diagrams and renders PNGs via Kroki.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "gittyburstein-mermaid-mcp-server": {
      "command": "python",
      "args": [
        "src/server/server.py"
      ],
      "env": {
        "PROJECT_ROOT": ".",
        "KROKI_TIMEOUT": "20",
        "KROKI_BASE_URL": "https://kroki.io",
        "MAX_FILE_CHARS": "200000",
        "DIAGRAM_OUT_DIR": "diagrams"
      }
    }
  }
}

Mermaid MCP Server lets you feed Python-based code that lives locally or in GitHub into Mermaid diagrams, render those diagrams as PNGs using Kroki, and access them through a consistent, agent-friendly workflow. It helps you quickly discover project structure, visualize dependencies, and share diagrams without guessing file paths or parsing files by hand.

How to use

You interact with the server through an MCP client that can launch a local stdio process. The recommended workflow is to run the server locally and use the three tools in sequence to build a Mermaid diagram from a codebase.

How to install

Prerequisites: Python 3.10 or newer. You will also need a shell to run commands and network access for Kroki.

Install and run the server locally with a virtual environment, then start the server to accept stdio connections.

Security & configuration

Access to code is restricted to the project root you specify, and outputs are saved inside a designated diagrams directory within that root. Customize read limits and output locations through environment variables to tailor the server to your workspace.

The server supports two core inputs: local project folders and GitHub repositories. You can set a maximum file size, specify a destination directory for diagrams, and provide a Kroki endpoint for rendering.

Example usage flow

1) List files from a source (local or GitHub) to discover what exists in the project.

2) Read selected files to fetch their contents within a safe length limit.

3) Generate Mermaid from the gathered data and then render to PNG using Kroki.

4) Retrieve the PNG and save it to disk for sharing or documentation.

Troubleshooting

If you see missing input errors, verify you provided a valid source type (local or github) and that required fields like path or repo_url are present. Ensure the output directory is inside PROJECT_ROOT and that you have permissions to write there.

Available tools

list_files

List files from a local folder or GitHub repository with root and glob filtering.

read_file

Read file contents from local or GitHub with a maximum length limit.

render_mermaid

Render Mermaid text via Kroki and return ImageContent while saving the PNG to disk.