Markdown + Mermaid to PDF MCP Server

Markdown + Mermaid to PDF MCP Server

Converts Markdown files and standalone Mermaid diagrams into high-quality PDF or PNG documents using Puppeteer and SVG rendering. It supports custom CSS styling and provides tools for professional document generation from markdown-based content.

Category
Visit Server

README

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

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured