Markdown + Mermaid to PDF MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
npm install
npm run build
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add md-mmd-pdf -- node "<FULL_PATH_TO_MCP_MD_MMD_PDF>/dist/index.js"

Replace <FULL_PATH_TO_MCP_MD_MMD_PDF>/dist/index.js with the actual folder you prepared in step 1.

README.md

Converts Markdown files and Mermaid diagrams into high-quality PDF or PNG.

Markdown + Mermaid to PDF MCP Server

An MCP (Model Context Protocol) server that converts Markdown files containing Mermaid diagrams into PDF documents, and also converts standalone Mermaid diagrams to PNG or PDF. The server uses a hybrid approach: converting Markdown to HTML, rendering Mermaid diagrams as SVG graphics, and then generating outputs using Puppeteer.

Features

  • Converts Markdown files with Mermaid diagrams to PDF
  • Converts standalone Mermaid diagram code to PNG images
  • Converts standalone Mermaid diagram code to PDF files
  • Automatically renders Mermaid diagrams as high-quality SVG graphics
  • Clean, professional default styling
  • Support for custom CSS styling (for Markdown conversion)
  • Simple MCP tool interface

Installation

npm install
npm run build

Usage

As an MCP Server

Add this server to your MCP client configuration (e.g., Claude Desktop):

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

Tool: `convert_md_to_pdf`

Converts a Markdown file with Mermaid diagrams to PDF.

Parameters:

  • input_path (required): Absolute path to the input Markdown file
  • output_path (optional): Absolute path where the PDF should be saved. If not provided, uses the same name as input with .pdf extension
  • custom_css (optional): Additional CSS styles to apply to the PDF

Example:

{
  "input_path": "/path/to/document.md",
  "output_path": "/path/to/output.pdf"
}

Tool: `convert_mermaid_to_png`

Converts a standalone Mermaid diagram code to a PNG image file.

Parameters:

  • mermaid_code (required): Raw Mermaid diagram code as a string
  • output_path (required): Absolute path where the PNG file should be saved

Example:

{
  "mermaid_code": "graph TD\n  A[Start] --> B[Process]\n  B --> C[End]",
  "output_path": "/path/to/diagram.png"
}

Tool: `convert_mermaid_to_pdf`

Converts a standalone Mermaid diagram code to a PDF file.

Parameters:

  • mermaid_code (required): Raw Mermaid diagram code as a string
  • output_path (required): Absolute path where the PDF file should be saved

Example:

{
  "mermaid_code": "sequenceDiagram\n  Alice->>Bob: Hello\n  Bob->>Alice: Hi!",
  "output_path": "/path/to/diagram.pdf"
}

How It Works

  1. Markdown Parsing: Reads and parses Markdown content using the marked library
  2. HTML Generation: Converts Markdown to HTML while preserving Mermaid code blocks
  3. Mermaid Rendering: Injects Mermaid.js library to render diagrams as SVG in the browser
  4. PDF Export: Uses Puppeteer (headless Chrome) to generate the final PDF with all content rendered

Example Markdown

See example.md for a sample document with Mermaid diagrams.

Development

# Install dependencies
npm install

# Build
npm run build

# Watch mode for development
npm run dev

# Run the server
npm start

Requirements

  • Node.js 18 or higher
  • Sufficient memory for Puppeteer to run headless Chrome

License

MIT

Tools (3)

convert_md_to_pdfConverts a Markdown file with Mermaid diagrams to PDF.
convert_mermaid_to_pngConverts a standalone Mermaid diagram code to a PNG image file.
convert_mermaid_to_pdfConverts a standalone Mermaid diagram code to a PDF file.

Configuration

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

Try it

Convert my project documentation at /home/user/docs/readme.md into a professional PDF.
Generate a PNG image from this Mermaid sequence diagram: sequenceDiagram Alice->>Bob: Hello
Create a PDF version of this flowchart: graph TD A[Start] --> B[End]
Convert my markdown file to PDF and apply custom CSS to change the font size.

Frequently Asked Questions

What are the key features of Markdown + Mermaid to PDF?

Converts Markdown files with Mermaid diagrams to PDF. Converts standalone Mermaid diagram code to PNG images. Converts standalone Mermaid diagram code to PDF files. Supports custom CSS styling for Markdown conversion. Renders Mermaid diagrams as high-quality SVG graphics.

What can I use Markdown + Mermaid to PDF for?

Generating professional PDF reports from technical markdown documentation.. Exporting Mermaid diagrams for inclusion in presentations or documents.. Automating the creation of visual documentation from code-based diagrams.. Applying custom branding to markdown-generated PDFs via CSS..

How do I install Markdown + Mermaid to PDF?

Install Markdown + Mermaid to PDF by running: npm install && npm run build

What MCP clients work with Markdown + Mermaid to PDF?

Markdown + Mermaid to PDF works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Markdown + Mermaid to PDF docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare