mcp-pandoc-ts logo

mcp-pandoc-ts

by mystique920

This project provides document conversion capabilities via the Model Context Protocol (MCP). It uses a two-component architecture: a TypeScript-based MCP server and a Python Flask host service to leverage a `pandoc` installation on the host machine without needing to install it inside the container.

View on GitHub

Last updated: N/A

What is mcp-pandoc-ts?

mcp-pandoc-ts is a document conversion MCP server built with TypeScript that utilizes a separate Python Flask host service to execute Pandoc conversions. This allows for leveraging a host machine's Pandoc installation from within a containerized environment.

How to use mcp-pandoc-ts?

  1. Set up and run the pandoc-host-service on the host machine, ensuring Pandoc and necessary dependencies are installed. 2. Configure the PANDOC_HOST_URL environment variable for the mcp-pandoc-ts container service to point to the host service. 3. Run the mcp-pandoc-ts server, which will listen for MCP requests and forward conversion tasks to the host service.

Key features of mcp-pandoc-ts

  • Document conversion via MCP

  • Two-component architecture (container service and host service)

  • Leverages host machine's Pandoc installation

  • Supports Markdown, HTML, PDF, DOCX, TXT conversion (LaTeX and EPUB untested)

  • Configuration via environment variables

  • Base64 encoding for binary output formats

Use cases of mcp-pandoc-ts

  • Integrating document conversion into applications using MCP

  • Converting documents within containerized environments without installing Pandoc inside the container

  • Automating document format transformations

  • Providing document conversion as a service

FAQ from mcp-pandoc-ts

What is the purpose of the pandoc-host-service?

The pandoc-host-service is a Python Flask service that runs on the host machine and executes the pandoc command. It receives HTTP requests from the container service and returns the converted document.

Why is the PANDOC_HOST_URL environment variable important?

The PANDOC_HOST_URL tells the mcp-pandoc-ts server where to find the running pandoc-host-service. Without it, the server cannot contact the host service and will fail to process requests.

What document formats are supported?

Currently, the server supports conversion between Markdown, HTML, PDF, DOCX, and TXT. LaTeX and EPUB are listed as supported but are currently untested.

Can I use input_file to specify an input file for conversion?

No, the input_file option is currently not supported due to path complexities between the container and the host. Only the contents input is supported.

How do I set up the PANDOC_HOST_URL?

The PANDOC_HOST_URL can be set either as an environment variable directly in your deployment configuration or, for local development, in a .env file in the project root.