Back to projects

Word-MCP

Python MCP server bridging AI agents into a live Microsoft Word process over Windows COM (pywin32), using a dedicated Win32 STA worker thread, anchor IDs, and atomic UndoRecord rollbacks.

2026 · YearSystems Engineer, Architect · Role
  • Python 3.10+
  • Windows COM (pywin32)
  • MCP SDK
  • PyMuPDF
  • Pydantic v2
  • pytest
Private / Local build · source & live deployment unavailable

01Overview

Editing open `.docx` files on disk breaks whenever Microsoft Word holds a file lock. Word-MCP solves this by talking directly to the live Word COM automation object, isolating every call onto a dedicated Win32 Single-Threaded Apartment (STA) worker thread with `WinSta0\Default` desktop-station escape.

Document nodes are addressed via deterministic anchor IDs (`h:X`, `p:X`, `tbl:X`) using `Range` APIs that never hijack the user's cursor, while multi-step edits run inside an atomic `UndoRecord` so a single `Ctrl+Z` reverts an entire agent operation.

02Key features

  • 39 curated live-COM MCP tools consolidated per ADR-0005 with Pydantic v2 schemas
  • Dedicated Win32 STA worker thread and WinSta0\Default desktop-station handling (ADR-0003/0004)
  • Zero-lock Range co-authoring with anchor IDs (h:X, p:X, tbl:X) and single-step UndoRecord rollback
  • Multimodal word_preview_page (PyMuPDF ImageContent), layout diagnostics, and 13 pytest suites

03Screenshots

2 screens