Safe Docx

v0.26.1
io.github.UseJunior/safe-docx Checked 13 hours ago Published 8 days ago

AI-native surgical editing of Word .docx and OpenDocument .odt files with formatting preservation

Edit Word and OpenDocument files with coding agents. Safe Docx is a local MCP server and CLI for reading, searching, editing, comparing, converting, and saving document files. It preserves DOCX structure and can produce clean or tracked-changes output. Documents are processed on your machine. Safe Docx finds the clause, applies the targeted edit, and writes both files for review. The rest of the document stays outside the requested edit.

Summary extracted from the README.

@usejunior/safe-docx

Edit Word and OpenDocument files with coding agents.

npm version License: Apache 2.0

Safe Docx is a local MCP server and CLI for reading, searching, editing, comparing, converting, and saving document files. It preserves DOCX structure and can produce clean or tracked-changes output. Documents are processed on your machine.

Example

Ask your coding agent:

Edit NDA.docx. Change the governing law from New York to Delaware.
Save a clean copy and a tracked-changes copy. Do not change anything else.

Safe Docx finds the clause, applies the targeted edit, and writes both files for review. The rest of the document stays outside the requested edit.

Follow the complete editing walkthrough.

Install

npm install --global @usejunior/safe-docx
safe-docx --help

The package installs both safe-docx and safedocx; use safe-docx in new configurations.

Configure An MCP Client

Locate the installed executable with command -v safe-docx (where safe-docx on Windows). Desktop applications may not inherit your terminal's PATH, so configure clients with that absolute path. The server takes no arguments and uses stdio.

Claude Code:

claude mcp add safe-docx -- /absolute/path/to/safe-docx

JSON-based clients, including Antigravity CLI (~/.gemini/config/mcp_config.json):

{
  "mcpServers": {
    "safe-docx": {
      "command": "/absolute/path/to/safe-docx",
      "args": []
    }
  }
}

See installation and verification for pinning a version, inspecting the package before install, and building from source.

Tools

  • Read and navigate: read_file, get_document_outline, get_sections, grep
  • Edit: replace_text, insert_paragraph, batch_edit, clear_formatting
  • Format: format_layout, format_numbering, format_section, insert_section_break
  • Headers and footers: get_headers_footers, set_header_footer (header/footer paragraph ids also work in replace_text and insert_paragraph)
  • Tracked changes: has_tracked_changes, extract_revisions, accept_changes, accept_ai_edits, reject_ai_edits
  • Compare: compare_documents
  • Document properties: get_document_properties, set_document_properties
  • Comments and footnotes: add_comment, get_comments, delete_comment, get_footnotes, add_footnote, update_footnote, delete_footnote
  • Save and convert: save, export, convert_to_odt, get_file_status, close_file

Parameters and behavior for each tool are in the tool reference.

Not Optimized For

Safe Docx is not a visual editor or layout engine. It does not provide browser rendering, real-time collaboration, or pixel-level pagination guarantees. .dotx templates must be converted to .docx before use.