Labsco
vivekVells logo

Pandoc

β˜… 565

from vivekVells

MCP server for seamless document format conversion using Pandoc, supporting Markdown, HTML, and plain text, with other formats like PDF, csv and docx in development.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedAccount requiredNeeds API keys

Downloads CI <br />

image

<!-- [![Downloads](https://static.pepy.tech/badge/mcp-pandoc/month)](https://pepy.tech/project/mcp-pandoc) --> <!-- ![PyPI - Downloads](https://img.shields.io/pypi/dm/mcp-pandoc?style=social) --> <!-- [![Downloads](https://img.shields.io/pypi/dm/mcp-pandoc.svg)](https://pypi.python.org/pypi/mcp-pandoc) [![CI](https://github.com/vivekVells/mcp-pandoc/actions/workflows/ci.yml/badge.svg)](https://github.com/vivekVells/mcp-pandoc/actions/workflows/ci.yml) <a href="https://smithery.ai/server/mcp-pandoc"><img alt="Smithery Badge" src="https://smithery.ai/badge/mcp-pandoc"></a> <a href="https://glama.ai/mcp/servers/xyzzgaj9bk"><img width="380" height="200" src="https://glama.ai/mcp/servers/xyzzgaj9bk/badge" /></a> -->

MseeP.ai Security Assessment Badge <a href="https://glama.ai/mcp/servers/xyzzgaj9bk"><img width="380" height="200" src="https://glama.ai/mcp/servers/xyzzgaj9bk/badge" />

mcp-pandoc: A Document Conversion MCP Server

Officially included in the Model Context Protocol servers open-source project. πŸŽ‰

Overview

A Model Context Protocol server for document format conversion using pandoc. This server provides tools to transform content between different document formats while preserving formatting and structure.

Please note that mcp-pandoc is currently in early development. PDF support is under development, and the functionality and available tools are subject to change and expansion as we continue to improve the server.

Credit: This project uses the Pandoc Python package for document conversion, forming the foundation for this project.

πŸ“‹ Quick Reference

New to mcp-pandoc? Check out πŸ“– CHEATSHEET.md for

  • ⚑ Copy-paste examples for all formats
  • πŸ”„ Bidirectional conversion matrix
  • 🎯 Common workflows and pro tips
  • 🌟 Reference document styling guide

Perfect for quick lookups and getting started fast!

Demo

mcp-pandoc - v1: Seamless Document Format Conversion for Claude using MCP server

πŸŽ₯ Watch on YouTube

<details> <summary>Screenshots</summary> <img width="2407" alt="Screenshot 2024-12-26 at 3 33 54β€―PM" src="https://github.com/user-attachments/assets/ce3f5396-252a-4bba-84aa-65b2a06b859e" /> <img width="2052" alt="Screenshot 2024-12-26 at 3 38 24β€―PM" src="https://github.com/user-attachments/assets/8c525ad1-b184-41ca-b068-7dd34b60b85d" /> <img width="1498" alt="Screenshot 2024-12-26 at 3 40 51β€―PM" src="https://github.com/user-attachments/assets/a1e0682d-fe44-40b6-9988-bf805627beeb" /> <img width="760" alt="Screenshot 2024-12-26 at 3 41 20β€―PM" src="https://github.com/user-attachments/assets/1d7f5998-6d7f-48fa-adcf-fc37d0521213" /> <img width="1493" alt="Screenshot 2024-12-26 at 3 50 27β€―PM" src="https://github.com/user-attachments/assets/97992c5d-8efc-40af-a4c3-94c51c392534" /> </details>

More to come...

Tools

  1. convert-contents
    • Transforms content between supported formats
    • Inputs:
      • contents (string): Source content to convert (required if input_file not provided)
      • input_file (string): Complete path to input file (required if contents not provided)
      • input_format (string): Source format of the content (defaults to markdown)
      • output_format (string): Target format (defaults to markdown)
      • output_file (string): Complete path for output file (required for pdf, docx, rst, latex, epub formats)
      • reference_doc (string): Path to a reference document to use for styling (supported for docx output format)
      • defaults_file (string): Path to a Pandoc defaults file (YAML) containing conversion options
      • filters (array): List of Pandoc filter paths to apply during conversion
    • Supported input/output formats:
      • markdown
      • html
      • pdf
      • docx
      • rst
      • latex
      • epub
      • txt
      • ipynb
      • odt
    • Note: For advanced formats (pdf, docx, rst, latex, epub), an output_file path is required

πŸ”§ Advanced Features

Defaults Files (YAML Configuration)

Use defaults files to create reusable conversion templates with consistent formatting:

Copy & paste β€” that's it
# academic-paper.yaml
from: markdown
to: pdf
number-sections: true
toc: true
metadata:
  title: "Academic Paper"
  author: "Research Team"

Example usage: "Convert paper.md to PDF using defaults academic-paper.yaml and save as paper.pdf"

Pandoc Filters

Apply custom filters for enhanced processing:

Example usage: "Convert docs.md to HTML with filters ['/path/to/mermaid-filter.py'] and save as docs.html"

πŸ’‘ For comprehensive examples and workflows, see CHEATSHEET.md

πŸ“Š Supported Formats & Conversions

Bidirectional Conversion Matrix

From\ToMDHTMLTXTDOCXPDFRSTLaTeXEPUBIPYNBODT
Markdownβœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…
HTMLβœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…
TXTβœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…
DOCXβœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…
RSTβœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…
LaTeXβœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…
EPUBβœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…
IPYNBβœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…
ODTβœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…

A Note on PDF Support

This tool uses pandoc for conversions, which allows for generating PDF files from the formats listed above. However, converting from a PDF to other formats is not supported. Therefore, PDF should be considered an output-only format.

Format Categories

CategoryFormatsRequirements
BasicMD, HTML, TXT, IPYNB, ODTNone
AdvancedDOCX, PDF, RST, LaTeX, EPUBMust specify output_file path
StyledDOCX with reference docCustom template support ⭐

Requirements by Format

  • PDF (.pdf) - requires TeX Live installation
  • DOCX (.docx) - supports custom styling via reference documents
  • All others - no additional requirements

Note: For advanced formats:

  1. Complete file paths with filename and extension are required
  2. PDF conversion requires TeX Live installation (see Critical Requirements section -> For macOS: brew install texlive)
  3. When no output path is specified:
    • Basic formats: Displays converted content in the chat
    • Advanced formats: May save in system temp directory (/tmp/ on Unix systems)

Development

Testing

To run the comprehensive test suite and validate all supported bidirectional conversions, use the following command:

Copy & paste β€” that's it
uv run pytest tests/test_conversions.py

This ensures backward compatibility and verifies the tool's core functionality.

Building and Publishing

To prepare the package for distribution:

  1. Sync dependencies and update lockfile:
Copy & paste β€” that's it
uv sync
  1. Build package distributions:
Copy & paste β€” that's it
uv build

This will create source and wheel distributions in the dist/ directory.

  1. Publish to PyPI:
Copy & paste β€” that's it
uv publish

Note: You'll need to set PyPI credentials via environment variables or command flags:

  • Token: --token or UV_PUBLISH_TOKEN
  • Or username/password: --username/UV_PUBLISH_USERNAME and --password/UV_PUBLISH_PASSWORD

Debugging

Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using the MCP Inspector.

You can launch the MCP Inspector via npm with this command:

Copy & paste β€” that's it
npx @modelcontextprotocol/inspector uv --directory /Users/vivekvells/Desktop/code/ai/mcp-pandoc run mcp-pandoc

Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.


Contributing

We welcome contributions to enhance mcp-pandoc! Here's how you can get involved:

  1. Report Issues: Found a bug or have a feature request? Open an issue on our GitHub Issues page.
  2. Submit Pull Requests: Improve the codebase or add features by creating a pull request.