Docx4j Word documents logo

Docx4j Word documents

Read, fill, and convert Word documents between DOCX, PDF, Markdown, and HTML through MCP.

Install Docx4j Word documents

Run the project’s own setup commands, in order.

Setup steps from the project

docx4j Word documents installs with its own steps rather than a config we can generate, so these are copied as-is. Follow them in order and run the commands in a terminal. Source: github.com

  1. 1. Install
    mvn package            # -> target/docx4j-mcp.jar (shaded, runnable)
    
  2. 2. Start the server
    docker run -i --rm -v /path/to/documents:/data ghcr.io/plutext/docx4j-mcp
    

Overview

The docx4j Word documents MCP server lets AI agents read, fill, and convert `.docx` files using docx4j. It supports template inspection and population, PDF conversion, Markdown and HTML import/export, text extraction, and document math. Files must be inside directories supplied with `--root`, making it suitable for controlled document automation from Claude Desktop, Claude Code, or other MCP clients.

Use cases

  • Inspect a DOCX template before supplying merge data
  • Fill contracts or forms while preserving Word formatting
  • Convert Markdown or HTML content into styled Word documents
  • Export Word documents to PDF with equations and vector drawings
  • Extract document text for downstream agent processing

Key features

  • OpenDoPE and mail merge template support
  • DOCX, PDF, Markdown, and HTML conversion
  • Editable equation handling through OMML and MathML
  • Tracked-change handling during DOCX to Markdown conversion
  • Root-restricted filesystem access
  • Plain-text extraction from paragraphs and tables

Tools8

What Docx4j Word documents lets your agent do. Expand a tool for its parameters.

Self-reported~320 tokens of context

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

13/13 checks healthy over the last 83d

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

Last commit2mo agoMost recent push to the default branch.
Tools exposed8Callable tools this server registers over MCP.
Directory activity3 viewsConfig copies, upvotes, and views on AllMCPs.

How Docx4j Word documents works

What docx4j Word documents does

The docx4j Word documents MCP server exposes docx4j document-processing functions to MCP-compatible AI clients. It works with Word .docx files stored on the local filesystem and can inspect templates, populate them, convert them to PDF or HTML, and move content between DOCX and Markdown or HTML.

Template workflows support both OpenDoPE or bound content controls and traditional mail merge fields. The server can report a template’s expected data before filling it, including skeleton XML, XPath expressions, conditions, field names, and format switches. Filled documents retain the template’s formatting. Repeating sections and conditional content are processed for the XML-based template format.

How it works

Run the packaged Java application over stdio and provide one or more permitted document directories with --root. Tool paths are checked against those roots after symlink resolution; the server has no default root and will not start without one. Protocol messages go to stdout, while logs go to stderr.

The docx4j Word documents MCP server writes generated files only when the requested output path is within an allowed root. Writers do not overwrite an existing file unless overwrite: true is supplied. Text returned directly to the client is limited by --max-inline-chars, which defaults to 200,000 characters. Larger results can be written to an output path or truncated with a marker.

Setup and configuration

Build requirements are JDK 17 or newer and Maven. mvn package produces a runnable shaded JAR, and mvn test runs the JUnit 5 tests. The application can be started with a command such as:

bash
java -jar target/docx4j-mcp.jar --root /path/to/documents

The project also provides an .mcpb bundle for Claude Desktop, a Docker image, and a Claude Code plugin. Docker mounts a host directory at /data; paths passed to tools then use the container path. The Claude Code plugin can use DOCX4J_MCP_JAR and optionally DOCX4J_MCP_ROOTS.

Tools and capabilities

The docx4j Word documents MCP server provides these tools:

  • describe_template identifies data requirements for OpenDoPE, bound controls, and mail merge templates.
  • fill_template applies XML or JSON data while preserving document formatting.
  • convert_to_pdf uses XSL-FO and Apache FOP, supports table-of-contents updates, and reports font substitutions.
  • markdown_to_docx handles headings, numbering, GFM tables, footnotes, task lists, and TeX math.
  • docx_to_markdown preserves document structure and can accept or mark tracked changes.
  • html_to_docx normalizes loose HTML, maps heading elements to Word styles, and supports an altchunk mode.
  • convert_to_html produces standalone HTML and can export images separately.
  • extract_text returns plain text from paragraphs and tables.

Math can travel through supported conversions: TeX in Markdown and MathML in HTML become editable Word equations, while PDF output renders equations and WMF/EMF drawings as vectors. HTML output uses native MathML without JavaScript.

Limitations and notes

Remote images and stylesheets are not fetched during HTML import. A very long single display equation is treated as one atomic PDF graphic and does not wrap. PDF conversion includes metric-compatible fonts such as Carlito, Caladea, Liberation, and Tinos, but the tool reports substitutions when requested fonts are unavailable. The documented license is Apache License 2.0.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Docx4j Word documents

docx4j Word documents is an MCP server that connects AI agents to the docx4j Word document engine. Its main tools inspect and fill templates, convert DOCX files to PDF, Markdown, or HTML, import Markdown or HTML into DOCX, extract text, and handle supported equations during document conversion.

Build it with JDK 17 or newer and Maven, then run the shaded JAR with at least one `--root` directory. The project also offers a Claude Desktop `.mcpb` bundle, Docker image, and Claude Code plugin.

Start the server with one or more `--root` directories. Every tool path must resolve inside one of those directories, including after symlinks are resolved. The server refuses to start if no root is supplied.

Yes. Call `describe_template` first to identify OpenDoPE, bound-control, or mail-merge requirements, then call `fill_template`. XML data supports repeats and conditions, while mail merge accepts a JSON object.

Yes. Claude Desktop is supported through the Java stdio configuration or the provided `.mcpb` bundle. The bundle lets users select folders the server may access and requires Java 17 or newer on the system path.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewDocx4j Word documents AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/docx4j-word-documents?style=directory)](https://allmcps.com/mcp/docx4j-word-documents)
HTML Embed
<a href="https://allmcps.com/mcp/docx4j-word-documents"><img src="https://allmcps.com/api/badge/docx4j-word-documents?style=directory" alt="Docx4j Word documents on AllMCPs" /></a>