
docx4j Word documents
io.github.plutext由 GitHub 帳號 plutext 發布v0.2.0更新於 Oct 24, 2026
Read, convert and fill Word (.docx) documents: templates, Markdown/HTML in and out, PDF with math.
概覽
讓助理讀取、轉換與填寫 Word .docx 文件,包括範本、Markdown、HTML 以及 PDF 輸出。
- 可以做什麼
- 封裝 docx4j 引擎,向 MCP 用戶端提供 Word 文件處理能力。工具包括用於 OpenDoPE 或合併列印範本的 describe_template 與 fill_template,以及 convert_to_pdf、markdown_to_docx、docx_to_markdown、html_to_docx、convert_to_html 與 extract_text。數學公式端到端支援:TeX 與 MathML 會變成可編輯的 Word 方程式,並在 PDF 與 HTML 輸出中呈現。
- 適用情境
- 適合助理需要處理 Word 檔案的情境:填寫合約或信函範本、在 docx、Markdown、HTML 與 PDF 之間轉換,或從文件中擷取文字。適用於文件存放在本機資料夾、由伺服器獲准存取的桌面工作流程。
- 執行需求
- 透過 stdio 在本機執行,需要 PATH 中有 Java 17+。可以 .mcpb 套件、jar、OCI 映像或 Claude Code 外掛形式安裝。必須至少指定一個 --root 目錄,否則伺服器拒絕啟動;外掛使用 DOCX4J_MCP_JAR,可選 DOCX4J_MCP_ROOTS。未宣告驗證或 API 金鑰。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 docx4j Word documents,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
docx4j-mcp
A Model Context Protocol server that exposes docx4j's engine to AI agents: read, convert and fill Word (.docx) documents from Claude Desktop, Claude Code, or any MCP client.
Engine: docx4j 17.1.0 (the server versions independently; the bundled docx4j version is in the pom, the server's startup log, and its MCP instructions).
MCP protocol: 2025-11-25 (Java SDK 2.0.1, the newest available). Clients
speaking the 2026-07-28 spec work if they implement its dual-era fallback: the
server/discover probe gets a clean JSON-RPC -32601 and the client falls
back to initialize (verified over stdio). A modern-only client with no
fallback cannot connect until the SDK's 2026-07-28 support (milestone 2.2)
ships, at which point this server will migrate.
Status: phase 3 — all tools work over stdio against released docx4j 17.0.4;
packaged as a runnable jar, an .mcpb bundle, an OCI image and a Claude Code
plugin. The plan, tool surface and phasing are in CR-mcp-server.md.
Build
Requires JDK 17+. All docx4j dependencies (docx4j 17.1.0, ImportXHTML 17.0.4) come from Maven Central.
Run
Bare directory arguments are also accepted as roots (this is what the .mcpb
bundle's folder picker passes).
Claude Desktop, one click
Install docx4j-mcp.mcpb from the GitHub release (Settings → Extensions), pick
the folders the server may touch, done. Built locally with
packaging/build-mcpb.sh. Requires Java 17+ on your PATH.
Docker
(paths in tool calls are then container paths under /data;
packaging/docker/Dockerfile to build locally).
Claude Code plugin
packaging/claude-plugin/ bundles the server config and a skill for the
template/authoring workflows. Set DOCX4J_MCP_JAR (path to the jar) and
optionally DOCX4J_MCP_ROOTS.
Releasing
Tag vX.Y.Z: .github/workflows/release.yml builds jar + mcpb, attaches them
to the GitHub release, pushes ghcr.io/plutext/docx4j-mcp, and publishes
server.json (sha filled in) to the official MCP registry via GitHub OIDC.
Every file path an agent passes must resolve inside one of the --root
directories (symlinks are resolved first). There is no default root; the server
refuses to start without one. Logging goes to stderr; stdout is the protocol.
Tools that return text inline cap it at --max-inline-chars (default 200000) and
otherwise write to output_path or truncate with a marker.
Claude Code (.mcp.json in your project)
Claude Desktop (claude_desktop_config.json)
Tools
Mathematics is supported end to end: TeX math in Markdown
($..$) and MathML in HTML become real, editable Word equations (OMML), and
equations render in PDF (via jeuclid/FOP, no LaTeX toolchain) and HTML (native
MathML, no JavaScript) output. Known limitation: a very long single display
equation is one atomic graphic in PDF and does not line-wrap.
Writers take output_path and refuse to overwrite unless overwrite: true.
Example (Claude Code)
Use describe_template on contracts/nda-template.docx, then fill it for Acme Pty Ltd and write contracts/nda-acme.docx, then convert that to PDF.
The agent gets the skeleton XML (or MERGEFIELD names), fills it, and calls
fill_template and convert_to_pdf; the results tell it what was written and which
fonts were substituted.
Licence
Apache License 2.0.
來源:README.md,提交 58f53b1
工具
0版本歷史
1- v0.2.0最新Sep 16, 2026
評分
已滿足適用檢查項的 40%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
請在儲存庫或註冊中心條目中宣告授權條款。