home / mcp / md mermaid pdf mcp server

MD Mermaid PDF MCP Server

Converts Markdown with Mermaid diagrams to PDF and renders standalone Mermaid diagrams to PNG/PDF.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "aoprisan-mcp-md-mmd-pdf": {
      "command": "node",
      "args": [
        "/absolute/path/to/md-mmd-pdf/build/index.js"
      ]
    }
  }
}

This MCP server converts Markdown files that contain Mermaid diagrams into PDF documents and can also render standalone Mermaid diagrams to PNG or PDF. It renders Mermaid diagrams as SVGs in a headless browser and assembles the final outputs with a reliable, high-quality rendering pipeline. This makes it easy to generate polished documents and diagrams from Markdown for sharing, printing, or archival.

How to use

You run this server locally and connect a client to it to perform three main tasks: convert Markdown with Mermaid diagrams to PDF, convert standalone Mermaid code to PNG, and convert standalone Mermaid code to PDF. The server processes content by converting Markdown to HTML, rendering Mermaid blocks as SVG, and exporting the result to PDF or image format.

To start using it with your MCP client, add a local stdio-based server configuration that points to the runtime script. This lets your client invoke the server’s tools directly from your machine.

{
  "mcpServers": {
    "md_mmd_pdf": {
      "command": "node",
      "args": ["/absolute/path/to/md-mmd-pdf/build/index.js"]
    }
  }
}

What you can do with the tools

The server exposes three primary tools for converting content and diagrams.

{
  "input_path": "/path/to/document.md",
  "output_path": "/path/to/output.pdf",
  "custom_css": "/path/to/styles.css"
}
{
  "mermaid_code": "graph TD\n  A[Start] --> B[Process]",
  "output_path": "/path/to/diagram.png"
}
{
  "mermaid_code": "sequenceDiagram\n  Alice->>Bob: Hello\n  Bob->>Alice: Hi!",
  "output_path": "/path/to/diagram.pdf"
}

How outputs are produced

For Markdown files, you provide the input path and optionally an output path and custom CSS. The server renders Markdown to HTML, renders Mermaid diagrams as SVG, and uses a headless browser to export a PDF that includes the full content and diagrams.

Notes on usage patterns

- Use the Markdown-to-PDF tool when you have documentation or notes with embedded Mermaid diagrams that you want to share as a single, printable document. - Use the standalone Mermaid-to-PNG or Mermaid-to-PDF tools when you have individual diagrams that you want as image or document assets.

How to install

Prerequisites: ensure Node.js 18 or higher is installed and you have enough memory for Puppeteer to run headless Chrome.

1) Install dependencies for the server package locally.

npm install

2) Build the server to generate the runnable script.

npm run build

3) Start the server in your environment. The runtime script will be available at the path you provided in the stdio configuration.

npm start

Additional notes and tips

- The server leverages Puppeteer for PDF rendering, so ensure you have sufficient system memory to run headless Chrome smoothly. - You can customize the styling of Markdown-to-PDF outputs with a CSS file passed as the custom_css parameter when using the Markdown-to-PDF tool.

- If you plan to reuse the same CLI or MCP client configuration repeatedly, store the stdio command and arguments in your client’s project configuration to simplify subsequent invocations.

Tools exposed by this server

convert_md_to_pdf converts a Markdown file with Mermaid diagrams to PDF. It accepts an input path, an optional output path, and optional custom CSS.

convert_mermaid_to_png converts a standalone Mermaid diagram code to a PNG image file, given the code and an output path.

convert_mermaid_to_pdf converts a standalone Mermaid diagram code to a PDF file, given the code and an output path.

Available tools

convert_md_to_pdf

Converts a Markdown file with Mermaid diagrams to PDF by parsing Markdown, rendering Mermaid diagrams as SVG, and exporting the result as a PDF.

convert_mermaid_to_png

Converts a standalone Mermaid diagram code to a PNG image file by rendering the diagram and exporting it as an image.

convert_mermaid_to_pdf

Converts a standalone Mermaid diagram code to a PDF file by rendering the diagram and exporting it as a PDF.