SuperAPI AI Directory

mermaid-mcp-server

Turn local projects or GitHub repositories into Mermaid diagrams rendered via Kroki.

Open website

About this tool

Purpose: mermaid-mcp-server is an MCP server for agents that converts large codebases (local folders or GitHub repositories) into Mermaid diagrams and renders them as PNG images via Kroki, helping to quickly and reliably understand project structure and flows.

Main capabilities: supports both local and GitHub sources; provides a tool-based workflow list_files → read_file → generate_mermaid → render_mermaid; local reads are restricted to PROJECT_ROOT; configurable maximum file size (MAX_FILE_CHARS) and output directory (DIAGRAM_OUT_DIR); rendering results are returned as image content and saved as PNG.

Three tools: list_files returns a file list, with parameters source (local/github), root (default .), glob (default **/*), repo_url (required when source=github), ref (default main), recursive (default true); read_file reads file contents, with parameter path required and max_chars defaulting to MAX_FILE_CHARS; render_mermaid accepts Mermaid text, renders it to PNG via Kroki, returns ImageContent and saves it to PROJECT_ROOT/DIAGRAM_OUT_DIR/<filename>.png (default ./diagrams/), the filename is derived from title and sanitized, a default name is used when missing, files with the same name are overwritten, and an error is raised if mermaid is empty.

Usage: requires Python 3.10+ and network access (Kroki, and also access to GitHub when the source is GitHub). After cloning the repository, create a virtual environment and install dependencies, configure via environment variables, run the server over stdio, and register it in the configuration of an MCP client (such as Claude Desktop). The project includes a canonical prompt generate_mermaid_canonical (defined in src/prompts/mermaid_prompt.py), which requires reading and embedding the mermaid://styles/blue-flowchart style resource as-is, and following the above tool workflow.

Use cases: quickly sort out the structure of a new codebase, and generate architecture or flow diagrams.

Limitations: local reads are limited to PROJECT_ROOT; the output directory must be within PROJECT_ROOT; network access is required; future plans include support for more sources such as GitLab, Bitbucket, Azure DevOps Repos, ZIP, or single-file URLs, which are not currently provided.