Safe Docx
@UseJunior
关于 Safe Docx
Edit Word (.docx) documents with tracked changes, redlines, and formatting preservation. Built for AI coding agents. Surgical text replacement, comments, footnotes, and document comparison — all local, no cloud upload. MIT licensed.
基本信息
配置
使用下面的配置,将此服务器添加到你的 MCP 客户端。
{
"mcpServers": {
"safe-docx": {
"command": "npx",
"args": [
"-y",
"@usejunior/safe-docx"
]
}
}
}工具
23Read document content (DOCX or Google Doc). Output is token-limited (~14k tokens) by default with pagination metadata (has_more, next_offset). Use offset/limit to paginate.
Search paragraphs with regex. Use file_path for session-based search, file_paths for stateless multi-file search, or google_doc_id for Google Docs.
Initialize revision-bound context metadata for coordinated multi-agent planning.
Deterministically merge multiple sub-agent plans and detect hard conflicts before apply.
Validate and apply a batch of edit steps (replace_text, insert_paragraph) to a document in one call. Validates all steps first; applies only if all pass. Accepts inline steps or a plan_file_path. Compatible with merge_plans output.
Replace text in a paragraph by _bk_* id, preserving formatting. Supports DOCX and Google Docs.
Insert a paragraph before/after an anchor paragraph by _bk_* id. Supports DOCX and Google Docs.
Save document. For DOCX: saves clean and/or tracked changes output. For Google Docs: checkpoint (default) returns revisionId, or snapshot exports as DOCX.
Apply layout controls (paragraph spacing, table row height, cell padding). Google Docs supports paragraph spacing only.
Accept all tracked changes in the document body, producing a clean document with no revision markup. Returns acceptance stats.
Check whether the document body contains tracked-change markers (insertions, deletions, moves, and property-change records). Read-only.
Get file/session metadata including edit count, normalization stats, and cache info. Supports DOCX and Google Docs.
Close an open file session, or close all sessions with explicit confirmation. Supports DOCX and Google Docs.
Add a comment or threaded reply to a document. Provide target_paragraph_id + anchor_text for root comments, or parent_comment_id for replies.
Get all comments from the document with IDs, authors, dates, text, and anchored paragraph IDs. Includes threaded replies. Read-only.
Delete a comment and all its threaded replies from the document. Cascade-deletes all descendants.
Compare two DOCX documents and produce a tracked-changes output document. Provide original_file_path + revised_file_path for standalone comparison, or file_path to compare session edits against the original.
Get all footnotes from the document with IDs, display numbers, text, and anchored paragraph IDs. Read-only.
Add a footnote anchored to a paragraph. Optionally position the reference after specific text using after_text. Note: [^N] markers in read_file output are display-only and not part of the editable text used by replace_text.
Update the text content of an existing footnote.
Delete a footnote and its reference from the document.
Clear specific run-level formatting (bold, italic, underline, highlight, color, font) from paragraphs.
Extract tracked changes as structured JSON with before/after text per paragraph, revision details, and comments. Supports pagination via offset and limit. Read-only - does not modify the document.
概览
What is Safe Docx?
Safe Docx is an open-source TypeScript stack for surgical editing of existing Microsoft Word .docx files. It is optimized for coding-agent workflows that need deterministic, formatting‑preserving edits on existing documents, where a human still must review changes.
How to use Safe Docx?
Install and run via npx -y @usejunior/safe-docx. For MCP clients (Claude Code, Claude Desktop, Gemini CLI, or any stdio‑based MCP client), configure the MCP server with command npx and args ["-y", "@usejunior/safe-docx"]. The server provides typed MCP tools that agents call automatically — no manual integration code needed.
Key features of Safe Docx
- Deterministic, formatting‑preserving text replacement and paragraph insertion
- Tracked‑changes outputs for human review
- Comment and footnote workflows
- Revision extraction as structured JSON
- TypeScript runtime — no .NET, Python, or LibreOffice required
- Auditable behavior with test evidence and traceability artifacts
Use cases of Safe Docx
- Editing an NDA to change governing law and outputting both a clean and tracked‑changes copy
- Multistep contract translation pipelines in law firms
- Automated contract markup review (e.g., 22M+ tokens processed by a 150‑lawyer firm)
- Brownfield
.docxediting in HR, procurement, finance, sales ops, and legal workflows - Generating comparison documents and revision artifacts from existing Word files
FAQ from Safe Docx
What document types has Safe Docx been tested on?
In‑repo fixtures include mutual NDAs (Common Paper‑ and Bonterms‑style), Letters of Intent, and ILPA limited partnership agreement redline files.
Does Safe Docx require .NET, Python, or LibreOffice in normal runtime usage?
No. Supported runtime usage is JavaScript/TypeScript with jszip and @xmldom/xmldom.
Does Safe Docx preserve formatting during edits?
That is a core design goal. The tool surface uses surgical operations like replace_text and insert_paragraph that preserve document structure and formatting as much as possible.
Can Safe Docx generate contracts from scratch?
Not the primary focus. For from‑scratch generation, use packages such as docx. Safe Docx is optimized for editing existing documents.
Where does document data live and how is it transported?
Safe Docx runs entirely on your local machine. No document content is sent to external servers. MCP transport is stdio.
文件与存储 分类下的更多 MCP 服务器
mcp-v8: V8 JavaScript MCP Server
r33drichardsMCP server that exposes a V8 JavaScript runtime as a tool for AI agents like Claude and Cursor. Supports persistent heap snapshots via S3 or local filesystem, and is ready for integration with modern AI development environments.
Rust MCP Filesystem
rust-mcp-stackBlazing-fast, asynchronous MCP server for seamless filesystem operations.
box-mcp-server
hmkA Box model context protocol server to search, read and access files
PDF Extraction MCP Server (Claude Code Fork)
xraywuMCP server to extract contents from a PDF file
Filesystem
chrisdocManage your Hevy workouts, routines, folders, and exercise templates. Create and update sessions faster, organize plans, and search exercises to build workouts quickly. Stay synced with changes so your training log is always up to date.
评论