Skip to content

marcelocantos/mpe2pdf

Repository files navigation

mpe2pdf

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.

Prerequisites

Installation

npm install -g mpe2pdf

Or run directly with npx:

npx mpe2pdf input.md

Usage

mpe2pdf 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

Options

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

MCP Server Mode

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.

How it works

  1. mume renders the Markdown to HTML with full GFM support, Mermaid diagrams, and math rendering — the same pipeline as VS Code Markdown Preview Enhanced.
  2. Prince converts the HTML to a typeset PDF.

Security

mpe2pdf runs with script execution enabled in the mume engine, so embedded scripts in Markdown files will execute. Only convert files you trust.

Agent integration

If you use an agentic coding tool, run mpe2pdf --help-agent or include agents-guide.md in your project context.

License

Apache 2.0 — see LICENSE.

About

Convert Markdown to PDF via Markdown Preview Enhanced (mume) + Prince

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors