Pandoc MCP Server for Markdown to PDF, DOCX
Convert Markdown, HTML, CSV and more to PDF, DOCX and other formats with the Pandoc MCP server for fast, reliable document conversion.
npx -y @vivekVells/mcp-pandocOverview
Pandoc MCP Server is a lightweight HTTP service that uses Pandoc to convert documents between a wide range of formats. It’s designed for developers who need fast, reliable conversions (e.g., Markdown → PDF or DOCX) as part of automated pipelines, web apps, or serverless workflows. The server exposes a simple API for submitting content or files and returns converted outputs ready for download.
Because it delegates conversion work to Pandoc, the server supports most input/output formats Pandoc can handle while adding process safety, optional configuration, and an HTTP interface. This makes it useful for generating reports, exporting blog posts, or integrating document conversion into CI/CD pipelines without bundling Pandoc into every application.
Features
- HTTP API for on-demand document conversion (POST requests)
- Support for common Pandoc formats: Markdown, HTML, LaTeX, DOCX, PDF, EPUB, ODT, and more
- Accepts raw content, file uploads, or URLs as input
- Configurable Pandoc command-line arguments and templates
- Streaming binary responses (PDF, DOCX) and meaningful JSON error messages
- Docker-friendly and environment-configurable options
- Lightweight process isolation and size limits for safe operation
Installation / Configuration
Clone and run locally:
# Install dependencies (if Node-based)
# Build/start (project may use npm scripts)
Docker (build and run):
# Build an image from the repository
# Run on port 3000
Common environment variables (typical configuration options):
- PORT — HTTP port the server listens on (default: 3000)
- PANDOC_PATH — path to the pandoc binary (if not on PATH)
- TEMPLATE_DIR — folder for Pandoc templates
- MAX_UPLOAD_MB — maximum allowed upload size
- WORK_DIR — temporary working directory for conversions
Configuration is usually done via environment variables or a config file in the repo root. Adjust Pandoc arguments (e.g., --pdf-engine=xelatex) through the API call or server configuration to control output rendering.
Available Resources
API endpoints (example signatures — check the repo’s API docs for exact details):
| Endpoint | Method | Description |
|---|---|---|
| /convert | POST | Convert input content or uploaded file to a target format |
| /health | GET | Basic health check returning server status |
| /formats | GET | (Optional) List of supported input/output formats |
Typical POST /convert payloads:
- form-data file upload with fields: file, from, to, args[]
- JSON body with: content (string), from, to, args (array)
Response types:
- Binary stream with appropriate Content-Type for formats like PDF or DOCX
- JSON with status and error details for failures
Repository and additional resources:
- Source code and examples: https://github.com/vivekVells/mcp-pandoc
- Pandoc documentation (for available formats and CLI options): https://pandoc.org
Use Cases
- Convert Markdown to PDF for automated report generation
- Client POSTs Markdown content and requests
to=pdf. - Server runs Pandoc with a chosen PDF engine and returns application/pdf. Example curl:
- Produce DOCX from HTML for downstream editing
- Convert generated HTML pages into DOCX files so non-technical users can edit documents in Word:
- Batch processing in CI/CD
- Use the server in a build pipeline to convert a set of Markdown files into multiple formats (PDF, EPUB). The server can be invoked by scripts or runners and returns artifacts for publishing.
- CSV → DOCX/Table reports
- Convert CSV to a Markdown table (or use a Pandoc filter) and convert that to DOCX/PDF for printable reports. This server offloads that step to a centralized conversion service.
Examples (client snippets)
Node (fetch):
;
;
Python (requests):
=
Notes and Best Practices
- Ensure Pandoc and any required engines (e.g., TeX for PDF) are installed on the host or included in your container image.
- Limit request sizes and run conversions in temporary directories to prevent resource exhaustion.
- Use templates and Pandoc args to control styling and engines (e.g., –pdf-engine=xelatex).
- For production, run behind a reverse proxy, add authentication, and enable HTTPS.
This server is intended to simplify integrating Pandoc conversions into applications and pipelines while providing a stable HTTP API for developers. For exact API details and configuration examples, consult the repository: https://github.com/vivekVells/mcp-pandoc.