- Home
- MCP servers
- Md2pdf Mermaid
Md2pdf Mermaid
- typescript
0
GitHub Stars
typescript
Language
5 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"polarnego-md-to-pdf-with-mermaid-mcp": {
"command": "npx",
"args": [
"-y",
"github:polarnego/md-to-pdf-with-mermaid-mcp"
]
}
}
}This MCP server converts Markdown files containing Mermaid diagrams into PDFs by rendering Mermaid blocks to SVG images, replacing them in the Markdown, and then generating a PDF from the rendered Markdown. It can be called directly from MCP clients (for example, Claude Desktop) to automate the conversion as part of your workflow.
How to use
Register the MCP server in your MCP client so you can call the tool to convert Markdown to PDF with Mermaid diagrams. Use the following configuration snippet to connect via npx to the MCP server.
{
"mcpServers": {
"md2pdf_mermaid": {
"command": "npx",
"args": [
"-y",
"github:polarnego/md-to-pdf-with-mermaid-mcp"
]
}
}
}
After registration, you can use the tool named convert_markdown_to_pdf. Provide the absolute paths for the input Markdown file and the desired output PDF file.
{
"name": "md2pdf_mermaid",
"tool": {
"type": "convert_markdown_to_pdf",
"inputs": {
"inputPath": "/absolute/path/to/input.md",
"outputPath": "/absolute/path/to/output.pdf"
}
}
}
On success, you receive a response that confirms where the PDF was written, for example: PDF written: /absolute/path/to/output.pdf. The MCP server accepts only absolute paths for safety.
How to install
Prerequisites you need before you start:
- Node.js 18 or newer (ESM compatible)
- MCP-capable runtime
Optional but recommended to ensure network access for initial tool downloads and Chromium resources.
If you want to test locally without MCP, you can run the converter directly with Node.
# Quick local test (no MCP, direct script)
npm --version
node --version
# Run the converter with example files
node md_mermaid_to_pdf.js ./example.md ./example.pdf
Register the MCP server by using an MCP client with the following configuration (as shown in the usage section). This enables you to call the tool via MCP commands and manage inputs/outputs with absolute paths.
Notes and troubleshooting
Network access is required for the first run because tools may download Mermaid CLI components and Chromium. If you operate behind a firewall or proxy, ensure network requests are allowed.
If you encounter issues with the optional Pandoc fallback during PDF generation, ensure Pandoc is installed and available in your PATH. On macOS you can install it with brew install pandoc.
Make sure the output directory has write permissions so the final PDF can be saved to the specified absolute path.
Sample file
Create a Markdown file with Mermaid blocks and run the converter to produce a PDF. This sample Markdown demonstrates a simple Mermaid diagram.
## Example
```mermaid
graph TD;
A[Start] --> B{Is Mermaid Rendered?};
B -- Yes --> C[Export to PDF];
B -- No --> D[Render via mmdc];
D --> C;
`
Available tools
convert_markdown_to_pdf
Exposes a tool that converts a Markdown file containing Mermaid blocks to a PDF by rendering Mermaid blocks to SVG, substituting them in the Markdown, and converting the final document to PDF.