safe-docx

safe-docx

Editing of existing Word (.docx) files with formatting preservation. Supports comments, footnotes, and document comparison.

Category
Visit Server

README

Safe DOCX Suite

CI codecov

safe-docx by UseJunior — use coding agents for paperwork too.

Part of the UseJunior developer tools.

Safe Docx is an open-source TypeScript stack for surgical editing of existing Microsoft Word .docx files. It is built for workflows where an agent proposes changes and a human still needs reliable, formatting-preserving document edits.

If you review contracts with AI, the slowest step is often applying accepted recommendations in Word. Safe Docx turns that into deterministic tool calls.

Why This Exists

AI coding CLIs are great with code and text files but weak on brownfield .docx editing. Business and legal workflows still run on Word documents, so we built a native TypeScript path for:

  • reading and searching existing documents in token-efficient formats
  • making surgical edits without destroying formatting
  • producing clean/tracked outputs and revision extraction artifacts

Mission: enable coding agents to do paperwork too. Safe Docx focuses on deterministic edits to existing Word files where formatting and review semantics must survive automation.

Positioning

Safe Docx is optimized for agent workflows that need deterministic, local-first edits on existing .docx files:

  • typed MCP tools for edit, compare, revision extraction, comments, footnotes, and layout
  • auditable behavior with test evidence and traceability artifacts
  • TypeScript runtime distribution without requiring Python or LibreOffice for supported usage

Safe Docx is not intended to replace generation-first .docx libraries.

Start Here

For setup and daily usage, go to:

  • packages/docx-mcp/README.md

Quick run:

npx -y @usejunior/safe-docx

What Safe Docx Is Optimized For

  • Brownfield editing of existing .docx files
  • Formatting-preserving text replacement and paragraph insertion
  • Comment and footnote workflows
  • Tracked-changes outputs for review (download, compare_documents)
  • Revision extraction as structured JSON (extract_revisions)

What Safe Docx Is Not Optimized For

Safe Docx is not a from-scratch document generation toolkit.

If your primary need is generating new .docx files from templates/programmatic layout, use packages such as docx.

Document Families

Automated fixture coverage in this repo

  • Common Paper style mutual NDA fixtures
  • Bonterms mutual NDA fixture
  • Letter of Intent fixture
  • ILPA limited partnership agreement redline fixtures

Designed for complex legal and business .docx classes

  • NVCA financing forms
  • YC SAFEs
  • Offering memoranda
  • Order forms and services agreements
  • Limited partnership agreements

Packages

  • @usejunior/docx-core: primitives + comparison engine for existing .docx documents
  • @usejunior/docx-mcp: MCP server implementation and tool surface
  • @usejunior/safe-docx: canonical end-user install name (npx -y @usejunior/safe-docx)
  • @usejunior/safedocx-mcpb: private MCP bundle wrapper

Reliability and Trust Surface

  • Tool schemas are generated from packages/docx-mcp/src/tool_catalog.ts.
  • OpenSpec traceability matrix: packages/docx-mcp/src/testing/SAFE_DOCX_OPENSPEC_TRACEABILITY.md
  • Assumption matrix: packages/docx-mcp/assumptions.md
  • Conformance guide: docs/safe-docx/sprint-3-conformance.md

FAQ

What is Safe Docx?

A TypeScript-first DOCX editing stack for coding-agent workflows that need deterministic, formatting-preserving edits on existing Word documents.

Does this preserve formatting during edits?

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 + @xmldom/xmldom.

Can this generate contracts from scratch?

Not the primary focus. For from-scratch generation, use packages such as docx.

What document types has this been tested on in-repo fixtures?

Mutual NDAs (including Common Paper/Bonterms-style fixtures), Letter of Intent, and ILPA limited partnership agreement redline fixtures.

Is this only for lawyers?

No. The same brownfield .docx editing problems appear in HR, procurement, finance, sales ops, and other paperwork-heavy workflows.

Where should I start as an MCP user?

Use @usejunior/safe-docx via npx, then follow setup examples in packages/docx-mcp/README.md.

Where can I inspect the tool schemas?

See the generated reference at packages/docx-mcp/docs/tool-reference.generated.md.

Development

npm ci
npm run build
npm run lint --workspaces --if-present
npm run test:run
npm run check:spec-coverage
npm run test:coverage:packages
npm run coverage:packages:check
npm run coverage:matrix

See Also

Privacy

Safe Docx runs entirely on your local machine. No document content is sent to external servers. See our Privacy Policy for details.

Governance

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured