Convert Markdown to PDF using the Markdown Preview Enhanced engine (mume) and Prince.
The output matches what you see in VS Code's Markdown Preview Enhanced extension — including Mermaid diagrams, KaTeX math, syntax-highlighted code blocks, tables, task lists, and footnotes.
npm install -g mpe2pdfOr run directly with npx:
npx mpe2pdf input.mdmpe2pdf input.md # produces input.pdf
mpe2pdf input.md output.pdf # explicit output path
mpe2pdf ch1.md ch2.md ch3.md # batch: produces ch1.pdf, ch2.pdf, ch3.pdf| Flag | Description |
|---|---|
--help |
Show usage information |
--help-agent |
Show usage + agent integration guide |
--mcp |
Run as an MCP (Model Context Protocol) server on stdio |
--version |
Print version number |
Run mpe2pdf --mcp to start a stdio-based
Model Context Protocol server, allowing AI
agents to invoke PDF conversion as a tool.
Add to your Claude Code config (.mcp.json or ~/.claude.json):
{
"mcpServers": {
"mpe2pdf": {
"command": "mpe2pdf",
"args": ["--mcp"]
}
}
}The server exposes a convert tool that accepts an array of file objects with
input (required) and output (optional) paths. See
agents-guide.md for full tool schema details.
- mume renders the Markdown to HTML with full GFM support, Mermaid diagrams, and math rendering — the same pipeline as VS Code Markdown Preview Enhanced.
- Prince converts the HTML to a typeset PDF.
mpe2pdf runs with script execution enabled in the mume engine, so embedded scripts in Markdown files will execute. Only convert files you trust.
If you use an agentic coding tool, run mpe2pdf --help-agent or include
agents-guide.md in your project context.
Apache 2.0 — see LICENSE.