Skip to main content

Edit .docx files with tracked changes, comments, and revision restoration — for humans and AI agents

Project description

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
  • 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.

Installation

pip install revisedoc

For AI agent integration (opencode, Claude Code):

pip install "revisedoc[mcp]"

[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.

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_list_revisions List all tracked changes
docx_restore Undo a revision by ID
docx_get_text Print document plain text

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

revisedoc-0.1.0.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

revisedoc-0.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file revisedoc-0.1.0.tar.gz.

File metadata

  • Download URL: revisedoc-0.1.0.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for revisedoc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f43f89741833eab69d8e5afcf11a3b00b568f8785ba966c75694c3f7edb7f99d
MD5 9d9026b0bf131fa6abfcf47d1e73aaf6
BLAKE2b-256 6c65b144650749cd4dc2f951e828169260697f140535c809d8ba6c38c9cd68bb

See more details on using hashes here.

File details

Details for the file revisedoc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: revisedoc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for revisedoc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a78999678ae082824f175d90f1b9f3e0229aabdbd876cc17b7d1c5941ab1545
MD5 27bb99e8fcf24fd75de420d7dbbaa4f7
BLAKE2b-256 8822bdd3d930499a2e08b71d761212a6d03dd3f87b696d4a5e24c9c196dff62e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page