Skip to main content

The problem

AI coding agents are reliable with code and plain text files, but they break down on brownfield .docx editing. Standard Word files carry rich formatting, tracked changes, comments, footnotes, and structural metadata that text-based tools cannot safely touch. Applying AI-proposed edits directly to .docx files through generic tools corrupts formatting, destroys review semantics, and produces outputs that cannot be sent to legal, procurement, or finance counterparties. Business and legal workflows still run on Word documents. Contracts get reviewed, redlined, and signed as .docx files — not Markdown. If you want an AI agent to act on accepted recommendations, you need a tool path that preserves the document as it is.

The solution

Safe Docx is a local MCP server that gives AI agents a typed, deterministic tool surface for editing existing Word files. It runs entirely on your machine via npx, communicates over stdio, and exposes structured tools for reading, searching, replacing text, inserting paragraphs, managing comments and footnotes, comparing documents, and extracting revisions as structured JSON. Because it is a local MCP server, no document content ever leaves your machine.

What Safe Docx is optimized for

  • Brownfield editing — applying changes to existing .docx files, not generating new ones from scratch
  • Formatting preservation — surgical replace_text and insert_paragraph operations that keep run and paragraph formatting intact
  • Review workflows — producing clean and tracked-changes output variants for human review
  • Document comparison — comparing an original and a revised file into a tracked-changes output with compare_documents
  • Revision extraction — pulling revision data as structured JSON with extract_revisions
  • Comment and footnote management — adding, reading, and deleting comment bubbles and footnotes as first-class operations

What Safe Docx is not for

Safe Docx is not a from-scratch document generation toolkit. If your primary need is generating new .docx files from templates or programmatic layout, use a library such as docx instead.

Document families

Safe Docx is built and tested against the complex legal and business documents that real workflows produce:
Document classExamples
Non-disclosure agreementsCommon Paper mutual NDA, Bonterms mutual NDA
Letters of intentLOI fixtures with defined term replacements
Partnership agreementsILPA limited partnership agreement redline fixtures
Financing formsNVCA financing forms, YC SAFEs
Commercial agreementsOrder forms, services agreements, offering memoranda
The same brownfield editing problems appear outside legal teams too — HR, procurement, sales ops, and finance all work with Word documents that agents should be able to edit safely.

Packages

@usejunior/safe-docx

The canonical end-user install. Run with npx -y @usejunior/safe-docx to start the local stdio MCP server. This is the package you add to your MCP client config.

@usejunior/docx-mcp

The MCP server implementation. Contains the full tool surface: read/search, edit/layout, planning/batch, compare/revision, and comments/footnotes toolgroups. Used internally by @usejunior/safe-docx.

@usejunior/docx-core

The underlying TypeScript library with primitives and the comparison engine. Import this directly if you need to integrate .docx editing into application code rather than using the MCP server.
Ready to get started? Follow the quickstart to have the MCP server running in minutes.

Quickstart

Get the Safe Docx MCP server running in your AI client in under five minutes.

Build docs developers (and LLMs) love