docx-mcp
You can read and search a DOCX using its accepted text (tracked deletions removed) without changing the file.
Read paginated paragraphs of accepted text with paragraph indices, text, tracked-change flag, and character counts.
Search accepted text with Python regexes, returning matches, context, and paragraph indices.
Count and locate spelling variants of terms across the whole document.
Get structure statistics: paragraph/word counts, tracked-change paragraphs, comments, and file size.
Scan the first N paragraphs for working notes like
TODO:or custom patterns.Read a known paragraph range by start/end index.
All tools are read-only; missing or damaged files produce errors rather than empty results.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@docx-mcp Please read report.docx and summarize it with all tracked changes accepted."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
docx-mcp
Read the wiki for how it works, the evidence, the design decisions and the limits.
A read-only MCP server that lets an AI agent read and search a Word document as it would stand with every tracked change accepted.
简体中文: docx-mcp 是一个只读的 MCP 服务器,让 AI 智能体读取和搜索 Word 文档。它返回接受全部修订后的文本,已删除的内容不会被当作正文,文件本身不会被修改。
繁體中文: docx-mcp 是一個唯讀的 MCP 伺服器,讓 AI 代理讀取與搜尋 Word 文件。它回傳接受全部修訂後的文字,已刪除的內容不會被當成內文,檔案本身不會被修改。
Designed and authored by Daniel Boles; implemented with coding agents.
What it does
Most DOCX readers were written for clean documents. Point one at a file with tracked changes and it can report deleted words as text, or drop pending insertions, and nothing tells you. An agent working from that text is wrong and sounds sure of itself.
This server gives an agent six tools. None of them can write.
Tool | Purpose |
| Paginated paragraphs of accepted text. |
| Regex search over accepted text, with context. |
| Count each spelling of a term and say where it appears. |
| Paragraph, word, tracked-change and comment counts. |
| Find working notes such as |
| Read a known range of paragraphs by index. |
flowchart LR
A[Agent] -->|MCP over stdio| B[docx-mcp server]
B --> C[docx_tools]
C -->|zipfile| D[word/document.xml]
C -->|zipfile| E[word/comments.xml]
D --> F[Safe XML parser]
E --> F
F --> G[Join runs per paragraph]
G --> H[Drop del and moveFrom text]
H -->|structured results| ARelated MCP server: MCP Word Commander
Quick start
Python 3.12 or newer.
git clone https://github.com/dboles99/docx-mcp.git
cd docx-mcp
python -m venv .venv
.venv/bin/pip install -e ".[dev]" # Windows: .venv\Scripts\pip
.venv/bin/python examples/call_over_stdio.pycall_over_stdio.py builds an invented DOCX in a temporary folder, starts the server as a subprocess, and calls it through the MCP client. Its output:
tools: check_docx_term_variants, find_docx_term, get_docx_structure_stats, list_docx_paragraph_range, read_docx_accepted_text, scan_docx_meta_notes
stats: {"comment_count": 0, "file_size_kb": 1.1, "has_tracked_changes": true, "paragraph_count": 4, "tracked_change_paragraph_count": 1, "word_count_approx": 31}
accepted: The pilot covered twelve sites and met its target in the first year.
search for deleted word: 0 hits
variants: {"cyber security": 1, "cybersecurity": 1}
notes: TODO: check the figures before this goes out.Register it in an MCP client
Most clients take a block like examples/mcp-client-config.json:
{
"mcpServers": {
"docx": {
"command": "docx-mcp",
"args": []
}
}
}If docx-mcp is not on the client's PATH, give the full path to the script inside your virtual environment. With Claude Code:
claude mcp add docx -- docx-mcpUse it without MCP
from docx_mcp import find_term, read_accepted_text
rows = read_accepted_text("report.docx", limit=20)
hits = find_term("report.docx", r"carbon (tax|levy)")Design notes
Accepted text. Insertions are included.
w:delandw:moveFromare excluded at any depth, by walking the tree, not by pattern-matching the XML.Split runs. Word divides sentences across runs for formatting and spell-check reasons. Text is joined per paragraph first, so a phrase that crosses runs is still found.
Stable addresses.
para_indexis a paragraph's position in the document, not in a result page, so an agent can page, search and then jump back to the same place.Could not read is not nothing found. A missing or damaged file raises in Python and is a readable tool error over MCP. It does not return an empty list.
Untrusted files. The XML parser does not resolve entities, load a DTD or use the network, and any XML part over 256 MB when decompressed is refused.
Dependencies. Only
lxmland the MCP SDK. The DOCX logic indocx_tools.pydoes not import the SDK and works on its own.
Limits
It reads the document body, including tables and text boxes. Headers, footers, footnotes and endnotes are not read.
Comments are counted, not read.
Accepted text is per paragraph. A tracked deletion of a paragraph mark does not merge the two paragraphs.
Field results are read as stored text and are not recalculated.
find_docx_termruns the caller's regular expression with no time limit, so a pathological pattern can stall the server.The server reads any path its process can read. Run it with an account that can reach only what the agent should see.
word_count_approxsplits on whitespace, so it undercounts text with no spaces, such as Chinese or Japanese.It does not open legacy
.docfiles.Fixtures are generated in code. Tested on Windows with Python 3.12. Not tested on Linux or macOS, or with a file saved by Word itself.
Tests
pytestLast run, on Windows with Python 3.12: 67 passed.
Every fixture is an invented document built in code, and no DOCX file is stored in this repository. The tests include a real subprocess round trip over stdio. As a one-off check, the example document was also read with pandoc --track-changes=accept, which gave the same text.
Licence
Apache-2.0. Copyright 2026 Daniel Boles. See LICENSE.
Available Tools
6 toolscheck_docx_term_variantsA
Count occurrences of each term across all accepted text in a DOCX.
Useful for consistency checks, for example passing ["cyber security", "cybersecurity"] to see which spelling is used and where.
Inputs: path (required), terms (required), case_sensitive. Returns: object
find_docx_termB
Search the accepted text of a DOCX for a regular expression.
pattern is a Python regex. flags is a comma-separated list of re flag names, such as "IGNORECASE,DOTALL". Returns a list of {para_index, match, context, has_tracked_change}.
Inputs: path (required), pattern (required), flags, limit, +1 more. Returns: result
get_docx_structure_statsB
Return quick statistics for a DOCX: paragraph and word counts, tracked-change paragraph count, comment count and file size.
Inputs: path (required). Returns: object
list_docx_paragraph_rangeB
Return accepted text for paragraphs [start, end) by index, to inspect a known region of a document.
Inputs: end (required), path (required), start (required), include_empty. Returns: result
read_docx_accepted_textA
Read paragraphs from a DOCX as accepted text, with tracked deletions removed.
Returns a list of {para_index, text, has_tracked_change, char_count}. Pagination: start=0, limit=50 examines paragraphs 0 to 49. Set min_length=0 to include short and empty paragraphs.
Inputs: path (required), limit, start, min_length. Returns: result
scan_docx_meta_notesB
Scan the first N paragraphs of a DOCX for working notes left in by mistake, such as "TODO:" or "[internal]". Pass patterns to replace the defaults. Returns a list of {para_index, text, matched_pattern}.
Inputs: path (required), patterns, check_first_n. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
read_docx_accepted_text and list_docx_paragraph_range both return accepted paragraph text by index and differ only in pagination vs. explicit range, which invites misselection. find_docx_term, check_docx_term_variants, and scan_docx_meta_notes are all text-pattern searches over the same accepted text, though their return shapes (matches vs. counts vs. flagged notes) provide some differentiation.
All names are snake_case and follow a verb_docx_object pattern (read_docx_..., find_docx_..., get_docx_...), so the domain prefix is highly predictable. The leading verbs vary (read/find/check/get/scan/list), which slightly weakens predictability but remains readable and non-chaotic.
Six tools is a reasonable, tight scope for a read-only DOCX inspection server, and each tool has a plausible job. It is on the lean side given the overlapping read/search pairs, which suggests one or two tools could be consolidated rather than added.
The surface covers reading, searching, counting, and quick stats, but it is read-only with no ability to inspect comment contents (only a count), no detailed tracked-change data beyond a boolean flag, and no structural extraction such as headings, tables, or sections. These notable gaps limit deeper document analysis workflows.
Maintenance
Related MCP Connectors
Real Word and Excel for agents: open your .docx/.xlsm, read, propose, apply, get it back intact.
Check a document for hidden text before your agent reads it. PDF, Office, RTF, HTML.
Send AI-made document changes for human review, then read the decisions back.
Convert, create and edit Word, PowerPoint, Excel and PDF documents from any AI agent.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to edit Microsoft Word documents live while they are open, with full support for tracked changes, comments, formatting, and 124 tools.845 PyPI284MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to directly read, edit, and manipulate Word documents, supporting image and table operations, paragraph editing, and search/replace.202MIT
- FlicenseAqualityDmaintenanceEnables AI agents to edit Word documents using track changes, allowing lawyers to review each modification via Word's revision interface.5-
- AlicenseCqualityCmaintenanceEnables AI agents to create, read, and edit Word documents with tracked changes, comments, and template manipulation, including bulk text replacement and paragraph-level operations.100MIT