
Safe Docx
Local MCP server for surgical, formatting-preserving edits to existing Word (.docx) and OpenDocument (.odt) files.
Add to your client
Copy the config for your MCP client and paste it into its config file.
npx -y @usejunior/safe-docxPaste into ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"safe-docx": {
"command": "npx",
"args": [
"-y",
"@usejunior/safe-docx"
]
}
}
}Step-by-step guides: Add to Claude Desktop · Add to Cursor · Add to Windsurf
Before you start
- Node.js (run via npx)
- An MCP client such as Claude Code, Claude Desktop, Cursor, or Gemini CLI
About Safe Docx
Safe Docx is a deliberately narrow, local-first MCP server for deterministic, formatting-preserving edits to existing Word .docx and OpenDocument .odt files. It targets brownfield document workflows — contract review, legal markup, HR/procurement/finance paperwork — where an agent proposes changes and a human still needs reliable, auditable, formatting-preserving edits with tracked-changes outputs for review. It is headless (no editor, rendering, or collaboration layer) and works across MCP clients including Claude Code, Claude Desktop, Cursor, and Gemini CLI. The companion @usejunior/docx-core library can also generate new .docx files from a declarative DocumentSpec, but generation is not yet exposed as an MCP tool.
Tools & capabilities (10)
read_fileRead an existing .docx/.odt file in a token-efficient format (e.g. toon), returning paragraphs with stable 12-char hex paragraph IDs.
grepSearch a document for a pattern and return the matching paragraph(s) and their IDs.
replace_textSurgically replace old_string with new_string in a targeted paragraph, preserving formatting; accepts an instruction for tracked-change attribution.
insert_paragraphInsert a new paragraph into an existing document while preserving structure and formatting.
add_commentAdd a comment to a document (works on both .docx and .odt).
get_commentsRetrieve existing comments from a document.
saveSave the edited document to a local path; supports clean and tracked-changes outputs (save_format: clean, tracked, or both).
compare_documentsCompare two documents (or a live editing session against its original) and write a tracked-changes redline — DOCX, or a native ODF redline for .odt that round-trips in LibreOffice.
extract_revisionsExtract a document's revisions as structured JSON.
downloadProduce tracked-changes outputs for review.
What this server can do
Safe Docx provides tools for these capabilities — tap one to see every MCP server that does the same:
When to use it
- Applying AI-recommended contract edits in Word with formatting preserved
- Generating clean and tracked-changes copies of an NDA or agreement for human review
- Editing and redlining existing legal documents (NDAs, SAFEs, LPAs, offering memoranda, order forms)
- Extracting document revisions as structured JSON for downstream processing
- Editing OpenDocument (.odt) files with native ODF tracked-changes redlines for LibreOffice teams
Security notes
Runs entirely on your local machine; no document content is sent to external servers. Word template files (.dotx) are rejected — convert to a normal .docx first. No rendering, layout, or pagination guarantees; documents are validated structurally and against ECMA-376, not pixel-by-pixel.
Safe Docx FAQ
Does this preserve formatting during edits?
Yes — that is a core design goal. The tool surface is built around surgical operations (replace_text, insert_paragraph, layout controls) that preserve document structure and formatting semantics as much as possible.
Does this require .NET, Python, or LibreOffice in normal runtime usage?
No. Supported runtime usage is JavaScript/TypeScript with jszip and @xmldom/xmldom.
Can this generate documents from scratch?
The @usejunior/docx-core library ships generateDocx(spec) for declarative generation, but the MCP server does not yet expose a generate_document tool. Brownfield editing of existing documents is the primary focus.
What file types are supported?
Microsoft Word .docx and OpenDocument .odt. Word template files (.dotx) are rejected — convert them to a normal .docx first.
Is this only for lawyers?
No. The same brownfield .docx editing problems appear in HR, procurement, finance, sales ops, and other paperwork-heavy workflows.
Alternatives to Safe Docx
Compare all alternatives →Official MCP reference server for secure local filesystem read/write within allowed directories.
Official MCP server for reading, searching, and manipulating a local Git repository's files and history.
Official AWS Labs MCP server to manage and query S3 Tables (table buckets, namespaces, tables).
Compare Safe Docx with: