MCP-MD-PDF: Markdown to Word/PDF Converter

by sham-devs

Not rated
GitHub

About

A simple, reliable Model Context Protocol (MCP) server that converts Markdown files into professional Word (.docx) and PDF documents — with full support for .dotx templates.

Details

Author
sham-devs
Categories
Productivity, Other

Setup

Install MCP-MD-PDF: Markdown to Word/PDF Converter in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/sham-devs/mcp-md-pdf

Follow the installation instructions in the repository README, then restart your MCP client.

MCP-MD-PDF: Markdown to Word/PDF Converter

A simple, reliable Model Context Protocol (MCP) server that converts Markdown files into professional Word (.docx) and PDF documents — with full support for .dotx templates.

MCP-MD-PDF: Markdown to Word/PDF Converter

A simple, reliable Model Context Protocol (MCP) server that converts Markdown files into professional Word (.docx) and PDF documents — with full support for.dotxtemplates.

This tool was born from a practical need. We often write documentation, guides, and technical notes in Markdown — it’s fast, lightweight, and easy to version. But when it’s time to deliver these files to clients or present them professionally, we usually want them to match our project or company style: clean layout, consistent fonts, branded cover page, and polished formatting.

So instead of doing that manually every time, we built a simple flow:

Convert Markdown → Word (.docx using a.dotxtemplate) → PDF

By using Word templates, we could apply our own design once and keep every document consistent. That’s where this small project came from — a quick way to turn Markdown into beautiful, ready-to-share documents that look like they belong to your organization.

- 🚀Fast Conversion– From Markdown to Word or PDF in seconds
- 🎨Template Support– Apply.dotxtemplates for consistent, branded styling
- 📦Batch Processing– Convert multiple files at once
- 🔧Flexible Output– Choose between.docx,.pdf, or both
- 🤖AI-Ready– Built to integrate smoothly with Claude and other MCP-compatible AI tools

Choose the installation method that best fits your needs:

Option 1: Usinguvx(Recommended - No Code Download Needed)

Best for:Claude Desktop users who want the simplest installation.

- Python 3.10+
- For PDF conversion:

- Windows:Microsoft Word (uses COM automation)
- macOS:LibreOffice (brew install --cask libreoffice)
- Linux:LibreOffice (sudo apt-get install libreoffice)

# No code download needed - uvx handles everything uvx mcp-md-pdf

Add to yourclaude_desktop_config.json:

{ "mcpServers": { "md-pdf": { "command": "uvx", "args": ["mcp-md-pdf"] } } }

Restart Claude Desktopfor changes to take effect.

📖 SeeConfiguration sectionfor config file location and alternative setups.

Option 2: Usingpip(No Code Download Needed)

Best for:Users who want to install as a Python package.

- Python 3.10+
- For PDF conversion (same as Option 1):

- Windows:Microsoft Word
- macOS/Linux:LibreOffice

# Install from PyPI (when published) pip install mcp-md-pdf # Or install with development dependencies pip install "mcp-md-pdf[dev]"

Add to yourclaude_desktop_config.json:

{ "mcpServers": { "md-pdf": { "command": "python", "args": ["-m", "md_pdf_mcp.server"] } } }

Restart Claude Desktopfor changes to take effect.

📖 SeeConfiguration sectionfor config file location and alternative setups.

Option 3: From Source (Code Download Required)

Best for:Developers who want to modify the code or contribute.

- Git
- Python 3.10+
- For PDF conversion (same as above)

# Step 1: Clone the repository git clone https://github.com/sham-devs/mcp-md-pdf.git cd mcp-md-pdf # Step 2: Install in development mode pip install -e . # Step 3: (Optional) Install dev dependencies pip install -e ".[dev]"

Add to yourclaude_desktop_config.json:

{ "mcpServers": { "md-pdf": { "command": "python", "args": ["-m", "md_pdf_mcp.server"] } } }

Restart Claude Desktopfor changes to take effect.

📖 SeeConfiguration sectionfor config file location and alternative setups.

%APPDATA%\Claude\claude_desktop_config.json
~/Library/Application Support/Claude/claude_desktop_config.json

Open the configuration file and add the mcp-md-pdf server:

{ "mcpServers": { "md-pdf": { "command": "uvx", "args": ["mcp-md-pdf"] } } }
{ "mcpServers": { "md-pdf": { "command": "python", "args": ["-m", "md_pdf_mcp.server"] } } }
{ "mcpServers": { "md-pdf": { "command": "python", "args": ["-m", "md_pdf_mcp.server"], "env": { "PYTHONPATH": "/path/to/mcp-md-pdf" } } } }

Close and reopen Claude Desktop for changes to take effect.

After setup, restart Claude Desktop and simply ask:

Convert my README.md to Word format Convert docs.md to PDF using my company-template.dotx Convert all markdown files in the docs folder to both Word and PDF

Convert a single Markdown file to Word or PDF.

- markdown_path(str)– Path to the.mdfile
- output_path(str)– Output base path (no extension)
- output_format(str)"docx","pdf", or"both"(default:"docx")
- template_path(str, optional)– Path to.dotxtemplate

# Create Word document convert_markdown("README.md", "output", "docx") # Create PDF with template convert_markdown("doc.md", "result", "pdf", "template.dotx") # Create both formats convert_markdown("guide.md", "final", "both", "company.dotx")

Convert multiple Markdown files at once.

- markdown_files(list[str])– List of.mdfiles
- output_dir(str)– Output directory
- output_format(str)"docx","pdf", or"both"
- template_path(str, optional)– Shared.dotxtemplate

convert_markdown_batch( ["doc1.md", "doc2.md", "doc3.md"], "output", "both", "template.dotx" )

List supported formats and their capabilities.

For detailed feature coverage analysis, seedocs/MARKDOWN_COVERAGE.md

Use a.dotxWord template to define your document style:

- Custom headings, fonts, and colors
- Page margins and layout
- Headers and footers
- Branding and logo placement
- Table of contents formatting

If no template is provided, a clean default design is used.

Important:PDF conversion requires LibreOffice (or Microsoft Word on Windows) to preserve all DOCX formatting.

LibreOffice isrequiredfor PDF conversion because it preserves ALL formatting from DOCX files:

- ✅Colors, backgrounds, borders- Professional styling intact
- ✅Code blocks- Syntax highlighting and backgrounds preserved
- ✅Tables- Headers, borders, and cell styling maintained
- ✅Template styles-.dotxtemplate formatting carried through to PDF
- ✅Fonts & spacing- Typography remains pixel-perfect

Alternative approaches (Pandoc, etc.) lose formatting- they treat DOCX as plain text markup, stripping visual styles during PDF conversion.

✅ Works out of the box - no additional software needed!

Option A: Microsoft Word (Best for Windows)

# Install Python COM automation library pip install pywin32

That's it! The converter will automatically use Word for PDF conversion.

Option B: LibreOffice (Recommended if no Word)

# Method 1: Direct download (easiest) # Visit: https://www.libreoffice.org/download/ # Method 2: Using Chocolatey package manager choco install libreoffice # Method 3: Using winget (Windows Package Manager) winget install TheDocumentFoundation.LibreOffice
# Check if LibreOffice is installed where.exe soffice # Should output: C:\Program Files\LibreOffice\program\soffice.exe

LibreOffice is REQUIRED for PDF conversion on macOS(no native MS Word COM support).

# Method 1: Homebrew (RECOMMENDED - easiest updates) brew install --cask libreoffice # Method 2: Direct download # Visit: https://www.libreoffice.org/download/ # Download LibreOffice_25.x.x_MacOS_aarch64.dmg (M1/M2/M3) # Or LibreOffice_25.x.x_MacOS_x86-64.dmg (Intel Macs)

- macOS 10.15 (Catalina) or newer
- ~800 MB disk space
- Works on both Intel and Apple Silicon (M1/M2/M3)

which soffice # Should output: /Applications/LibreOffice.app/Contents/MacOS/soffice libreoffice --version # Should output: LibreOffice 25.x.x or higher
# Update package list sudo apt-get update # Install LibreOffice (headless mode supported) sudo apt-get install -y libreoffice libreoffice-writer # Optional: Install additional fonts for better compatibility sudo apt-get install -y fonts-liberation fonts-dejavu
# Minimal installation without GUI components sudo apt-get install -y libreoffice-writer libreoffice-calc \ libxinerama1 libfontconfig1 libdbus-glib-1-2 libcairo2 \ libcups2 libglu1-mesa libsm6
sudo dnf install libreoffice libreoffice-writer
libreoffice --version # Should output: LibreOffice 7.x or 25.x # Test headless mode soffice --headless --version # Should output version without GUI

- DOCX Conversion:Works on all platforms (Windows, macOS, Linux) -no additional software required
- PDF Conversion:Cross-platform with automatic platform detection:

- Windows:Uses Microsoft Word (if installed) or LibreOffice
- macOS/Linux:Uses LibreOffice in headless mode

Why LibreOffice for PDF?LibreOffice preservesALLDOCX formatting when converting to PDF:

- ✅ Colors, backgrounds, and borders
- ✅ Professional code block styling (#F5F5F5 backgrounds)
- ✅ Blockquote borders (blue left border)
- ✅ Table headers with colored backgrounds
- ✅ Template styles from .dotx files
- ✅ Fonts, spacing, and layout

- Python 3.10+
- Pillow(image handling)
- python-docx(Word generation)
- pywin32(Windows only)
- fastmcp(MCP framework)

# Clone the repository git clone https://github.com/sham-devs/mcp-md-pdf.git cd mcp-md-pdf # Install with dev dependencies pip install -e ".[dev]" # Run tests pytest # Run tests with coverage pytest --cov=src/md_pdf_mcp --cov-report=html # Format code black src/ tests/ ruff check src/ tests/

- Markdown → Word conversion
- Template application
- MCP server tools
- Unicode, emoji, and edge cases

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.