loading…
Search for a command to run...
loading…
Converts Markdown files to Word (.docx) and PDF documents. Supports .dotx templates for branded styling and batch conversion.
Converts Markdown files to Word (.docx) and PDF documents. Supports .dotx templates for branded styling and batch conversion.
PyPI version Python Versions Tests License: MIT
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.
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.
.dotx templates for consistent, branded styling.docx, .pdf, or bothChoose the installation method that best fits your needs:
| Method | Code Download? | PDF Support | Best For |
|---|---|---|---|
| uvx (Option 1) | ❌ No | ✅ Yes (LibreOffice required) | Claude Desktop users |
| pip (Option 2) | ❌ No | ✅ Yes (LibreOffice required) | Python package users |
| From Source (Option 3) | ✅ Yes | ✅ Yes (LibreOffice required) | Developers |
uvx (Recommended - No Code Download Needed)Best for: Claude Desktop users who want the simplest installation.
Requirements:
brew install --cask libreoffice)sudo apt-get install libreoffice)Installation:
# No code download needed - uvx handles everything
uvx mcp-md-pdf
Claude Desktop Setup:
Add to your claude_desktop_config.json:
{
"mcpServers": {
"md-pdf": {
"command": "uvx",
"args": ["mcp-md-pdf"]
}
}
}
Restart Claude Desktop for changes to take effect.
📖 See Configuration section for config file location and alternative setups.
pip (No Code Download Needed)Best for: Users who want to install as a Python package.
Requirements:
Installation:
# Install from PyPI (when published)
pip install mcp-md-pdf
# Or install with development dependencies
pip install "mcp-md-pdf[dev]"
Claude Desktop Setup:
Add to your claude_desktop_config.json:
{
"mcpServers": {
"md-pdf": {
"command": "python",
"args": ["-m", "md_pdf_mcp.server"]
}
}
}
Restart Claude Desktop for changes to take effect.
📖 See Configuration section for config file location and alternative setups.
Best for: Developers who want to modify the code or contribute.
Requirements:
Installation:
# 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]"
Claude Desktop Setup:
Add to your claude_desktop_config.json:
{
"mcpServers": {
"md-pdf": {
"command": "python",
"args": ["-m", "md_pdf_mcp.server"]
}
}
}
Restart Claude Desktop for changes to take effect.
📖 See Configuration section for config file location and alternative setups.
Windows:
%APPDATA%\Claude\claude_desktop_config.json
macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Open the configuration file and add the mcp-md-pdf server:
Option A: Using uvx (Recommended)
{
"mcpServers": {
"md-pdf": {
"command": "uvx",
"args": ["mcp-md-pdf"]
}
}
}
Option B: Local Installation
{
"mcpServers": {
"md-pdf": {
"command": "python",
"args": ["-m", "md_pdf_mcp.server"]
}
}
}
Option C: With Environment Variables
{
"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_markdownConvert a single Markdown file to Word or PDF.
Parameters:
markdown_path (str) – Path to the .md fileoutput_path (str) – Output base path (no extension)output_format (str) – "docx", "pdf", or "both" (default: "docx")template_path (str, optional) – Path to .dotx templateExamples:
# 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_markdown_batchConvert multiple Markdown files at once.
Parameters:
markdown_files (list[str]) – List of .md filesoutput_dir (str) – Output directoryoutput_format (str) – "docx", "pdf", or "both"template_path (str, optional) – Shared .dotx templateExample:
convert_markdown_batch(
["doc1.md", "doc2.md", "doc3.md"],
"output",
"both",
"template.dotx"
)
list_supported_formatsList supported formats and their capabilities.
| Feature | Supported | Notes |
|---|---|---|
| Headings (H1–H6) | ✅ | # through ######, with template fallback |
| Bold / Italic | ✅ | Markdown standard syntax |
| Inline code | ✅ | Monospaced with gray background |
| Code blocks | ✅ | Professional styling with background and borders |
| Bullet & Numbered lists | ✅ | Nested up to 3 levels |
| Tables | ✅ | With header styling and inline formatting |
| Blockquotes | ✅ | Italic text with left border and background shading |
| Horizontal rules | ✅ | --- |
| Unicode & Emoji | ✅ | Full UTF-8 support |
For detailed feature coverage analysis, see docs/MARKDOWN_COVERAGE.md
Use a .dotx Word template to define your document style:
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 is required for PDF conversion because it preserves ALL formatting from DOCX files:
.dotx template formatting carried through to PDFAlternative 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)
If you have Microsoft Word installed:
# 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
Verify installation:
# 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).
Installation (Choose one method):
# 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)
System Requirements:
Verify installation:
which soffice
# Should output: /Applications/LibreOffice.app/Contents/MacOS/soffice
libreoffice --version
# Should output: LibreOffice 25.x.x or higher
Ubuntu/Debian (Recommended method):
# 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
For headless servers (CI/CD):
# 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
Fedora/RHEL:
sudo dnf install libreoffice libreoffice-writer
Arch Linux:
sudo pacman -S libreoffice-fresh
Verify installation:
libreoffice --version
# Should output: LibreOffice 7.x or 25.x
# Test headless mode
soffice --headless --version
# Should output version without GUI
Why LibreOffice for PDF? LibreOffice preserves ALL DOCX formatting when converting to PDF:
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/
Covers:
Structure:
tests/
├── conftest.py
├── test_converter.py
├── test_server.py
└── README.md
# Run the MCP server directly
python -m md_pdf_mcp.server
Or inspect via:
npx @modelcontextprotocol/inspector python -m md_pdf_mcp.server
Example usage:
User: Convert my README.md to Word format
→ Created: README.docx
User: Create a PDF with our company template
→ Created: guide.pdf
User: Convert all docs to both formats
→ Batch Conversion Complete (5 succeeded, 0 failed)
claude_desktop_config.json is valid JSON (no trailing commas)%APPDATA%\Claude\logs\~/Library/Logs/Claude/Verify your Python installation:
python --version
# or
python3 --version
If the command doesn't work, find your Python path:
where pythonwhich python3Update the configuration file with the correct path.
Error: pywin32 library required for PDF conversion on Windows
Fix (Windows):
pip install pywin32
Error: LibreOffice not found
Fix (macOS):
brew install --cask libreoffice
Fix (Ubuntu/Debian):
sudo apt-get install libreoffice libreoffice-writer
Fix (Fedora):
sudo dnf install libreoffice
Error: Invalid or missing .dotx file
Fix:
Error: ModuleNotFoundError: No module named 'fastmcp'
Fix:
pip install -e . from the project directorypip install mcp-md-pdfFor advanced debugging, test the server directly:
npx @modelcontextprotocol/inspector python -m md_pdf_mcp.server
This opens a web interface to interact with the MCP tools directly.
MIT License – see LICENSE file.
Pull requests are welcome. If you have ideas for improving conversions, templates, or new formats, we’d love to see them.
Built with ❤️ using the FastMCP framework — created to make Markdown documents look like real reports, not just text on GitHub.
Выполни в терминале:
claude mcp add mcp-md-pdf -- npx Безопасность
Низкий рискАвтоматическая эвристика по публичным данным — не гарантия безопасности.