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.
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 fileoutput_path(optional): Absolute path where the PDF should be saved. If not provided, uses the same name as input with.pdfextensioncustom_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 stringoutput_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 stringoutput_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
- Markdown Parsing: Reads and parses Markdown content using the
markedlibrary - HTML Generation: Converts Markdown to HTML while preserving Mermaid code blocks
- Mermaid Rendering: Injects Mermaid.js library to render diagrams as SVG in the browser
- 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
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Neon Database
MCP server for interacting with Neon Management API and databases
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.
E2B
Using MCP to run code via e2b.