Skip to main content

revisedoc

Edit .docx files the way Word intended — with full change tracking, inline comments, and revision history. No more sending around unmarked copies or losing track of what changed. Use it from the command line, from your Python code, or hook it up as an MCP server so your AI coding agent can edit documents with the same care a human reviewer would.

Features

  • Tracked-changes replace — Replace text using Word-compatible <w:del> / <w:ins> markup
  • Inline comments — Anchor comments to any text range
  • Comment extraction — Read existing sidebar comments back, each linked to the exact text it annotates
  • Revision inspection — List all tracked changes with id, author, date, type, text
  • Revision restoration — Undo a specific tracked change
  • MCP server — Expose all operations as structured tools for AI agents (opencode, Claude Code, etc.)

Use Cases

  • Contract redlining — Replace outdated terms in a .docx contract with tracked changes so the other side sees exactly what was modified.

  • Document review workflows — Annotate drafts with inline comments, then list and restore revisions to review changes systematically.

  • AI-assisted editing — Connect the MCP server to opencode or Claude Code and have your agent propose edits with full change tracking — no more "just trust me, I made some changes."

  • Batch processing — Script document updates across hundreds of files using the Python API, with every change recorded in Word's revision log.

Quick Start

Create a document, then use the MCP tools from your AI agent:

1. docx_inspect     — see the paragraph structure and formatting
2. docx_search      — locate exact text before editing
3. docx_replace     — make tracked changes (strikethrough + underline)
4. docx_comment     — annotate clauses with inline comments
5. docx_list_revisions — review what changed

Every operation produces standard Word revision markup — open the output in Word to see tracked changes, or accept/reject them as usual.

Installation

pip install revisedoc          # with pip
pipx install revisedoc          # with pipx (isolated)

For AI agent integration (opencode, Claude Code):

pip install "revisedoc[mcp]"     # pip — quotes required in zsh
pipx install "revisedoc[mcp]"    # pipx — quotes required in zsh

[mcp] is an optional extra — it installs the same revisedoc package plus the mcp SDK dependency. Without it, the CLI and Python API work fine; only the revisedoc-mcp server is unavailable.

Note for zsh users: the square brackets must be quoted. Use pip install "revisedoc[mcp]" not pip install revisedoc[mcp].

CLI Usage

# Replace text with tracked changes
revisedoc replace input.docx output.docx "old text" "new text" --author "Me"

# Add a comment
revisedoc comment input.docx output.docx "target text" "my comment" --author "Reviewer"

# List tracked changes
revisedoc list-revisions input.docx
revisedoc list-revisions input.docx --format json

# Undo a revision (restore deleted text)
revisedoc restore input.docx output.docx --revision-id 3

# Undo an insertion instead
revisedoc restore input.docx output.docx --revision-id 3 --restore-type insertion

# Print document plain text
revisedoc get-text input.docx

Python API

from docx import Document
from revisedoc import replace_text, add_comment, list_revisions, restore_revision, get_full_text, finalize_comments

doc = Document("input.docx")
replace_text(doc, "old phrase", "new phrase", author="MyBot")
add_comment(doc, "some specific text", "Review this part", author="Reviewer")
pending = doc.part._pending_comments
doc.save("output.docx")
finalize_comments("output.docx", pending_comments=pending)

MCP Server — AI Agent Integration

Start the MCP server:

revisedoc-mcp

opencode

Add to opencode.json:

{
  "mcp": {
    "revisedoc": {
      "type": "local",
      "command": ["revisedoc-mcp"],
      "enabled": true
    }
  }
}

Claude Code

Add to .claude/settings.json:

{
  "mcpServers": {
    "revisedoc": {
      "command": "revisedoc-mcp"
    }
  }
}

Available Tools

Tool Description
docx_replace Replace text with tracked changes
docx_comment Add a comment anchored to text
docx_inspect Inspect paragraph structure, formatting, revisions, and anchored comments
docx_search Locate exact text and its run offsets before editing
docx_list_revisions List all tracked changes
docx_restore Undo a revision by ID
docx_get_text Print document plain text

Reading comments

docx_inspect (and the inspect_document Python function) surfaces sidebar comments per paragraph. Each comment is linked to the text it annotates:

{
  "index": 0,
  "para_id": "1A2B3C4D",
  "text": "This is the clause that needs review.",
  "runs": [ ... ],
  "revisions": { "insertions": 0, "deletions": 0 },
  "comments": [
    {
      "comment_id": "0",
      "author": "John Doe",
      "date": "2024-08-28T10:00:00Z",
      "content": "Please verify the liability limits here.",
      "anchored_text": "the clause that needs review",
      "spans_paragraphs": false
    }
  ]
}

For a comment whose range stays within one paragraph, anchored_text is a substring of the paragraph text (deleted text is excluded). When a comment's range continues into a later paragraph, it is attached to the paragraph where it starts, spans_paragraphs is true, and anchored_text is the newline-joined text spanning those paragraphs.

Development

pip install -e ".[mcp,test]"
pytest tests/ -v

Architecture

The package structure:

src/revisedoc/
├── __init__.py     # Public API exports
├── editor.py       # Core editing operations
├── cli.py          # Command-line interface
└── mcp.py          # MCP server for AI agents

Metadata

Release files for revisedoc 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for revisedoc 0.1.4
File Size Uploaded Provenance
revisedoc-0.1.4.tar.gz 20.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for revisedoc 0.1.4
File Interpreter ABI Platform
revisedoc-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 34.9 kB

Release files / revisedoc-0.1.4.tar.gz

Download URL revisedoc-0.1.4.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
420208ffb97ddbcd3646d2e4ce3e38bc50e7e744fb323995a79c3df59163ca6c
BLAKE2b-256 checksum
How to use checksums
7a491b5336d0c30d1e0ac49b0014972ef9e255fccbf695873a0a2d1ae2a17554
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Release files / revisedoc-0.1.4-py3-none-any.whl

Download URL revisedoc-0.1.4-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d57402acfa8d341fd6a66e34202baec712af3f99dcf1fd08f6a25049f384a7a8
BLAKE2b-256 checksum
How to use checksums
1c0f26bc2995ccfa09c918eeca626b9cb99dc05939dd9b89285b16a2ff47781e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Security for revisedoc 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for revisedoc-0.1.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page