Skip to main content
Glama

word-agent-mcp

让 AI agent 以**修订模式(Track Changes)**编辑 Word 文档的 MCP server —— 律师版 "Claude Code for Word" 的文档操作层。

核心理念

程序员审代码用 diff,律师审文书用修订。本项目让 agent 的每一处修改都以标准 Word 修订(红线删除 + 下划线插入)写入 .docx,律师在 Word「审阅」界面逐条接受/拒绝——agent 永远不能未经审阅直接改动文书。

修订直接写入 OOXML(w:ins/w:del),不需要安装 Word、跨平台(Mac 开发、Windows 交付零移植)。

Related MCP server: word-mcp-live

架构

src/word_agent_mcp/
├── server.py          # MCP 工具层(read_document / replace_text / insert_paragraph / ...)
├── revisions.py       # OOXML 修订标记核心(w:ins / w:del 生成、run 拆分、修订扫描)
└── backend/
    ├── base.py        # WordBackend 抽象接口(按 Windows COM 能力超集设计)
    └── ooxml.py       # 文件后端:python-docx + lxml,跨平台
                       # (规划)com.py:Windows COM 后端,实时操控打开中的 Word

工具层只依赖 WordBackend 接口。阶段 2 在 Windows 上补一个 COM 后端即可获得"实时看着 agent 改文档"的体验,工具层零改动。

快速开始

uv sync                          # 安装依赖(自动准备 Python 3.11+)
uv run pytest                    # 跑测试
uv run python examples/demo.py   # 生成演示合同并修订,用 Word 打开看红线

接入 Claude Code

claude mcp add word-agent -- uv --directory /path/to/word-agent-mcp run word-agent-mcp

或在项目 .mcp.json 里:

{
  "mcpServers": {
    "word-agent": {
      "command": "uv",
      "args": ["--directory", "/path/to/word-agent-mcp", "run", "word-agent-mcp"]
    }
  }
}

然后直接对话:「读一下 ~/Desktop/租赁合同.docx,把租金改成 9000 并加一条逾期解约条款」。

MCP 工具

工具

说明

read_document

读取全部段落(index / style / 有效文本)

replace_text

修订式替换;不唯一时要求更长上下文或 replace_all

insert_paragraph

在指定段后修订式插入新段落

delete_paragraph

修订式删除段落

list_revisions

列出文档全部修订(自检 / 汇报用)

安全设计:每次编辑前自动留 .bak 备份;所有修改必须过 Word 审阅这一关。

已知限制(MVP)

  • 只处理正文段落,表格/页眉页脚/脚注暂不支持

  • 匹配区间内含制表符、图片等复杂 run 结构时会明确报错(不会静默破坏文档)

  • 批注(comments)待加入

  • Windows 上 Word 正在打开的文件会被锁定:请让 agent 改副本,或关闭文档后编辑

Available Tools

5 tools
delete_paragraphA

以修订方式删除第 index 段(从 0 计,见 read_document)。

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes
indexYes
authorNoAI 律师助手

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.6/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description indicates the deletion uses 'revision mode,' suggesting a non-destructive tracked change. However, it does not detail what happens to the paragraph content (e.g., moved to revision history) or any required permissions. With no annotations, more behavioral context would be beneficial.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence with no extraneous text. It is front-loaded with the action and includes a cross-reference. While effective, it could be slightly more structured without adding length.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a delete operation with revision mode and three parameters, the description provides minimal but essential context. It references read_document for index but does not cover return values (though output schema exists) or reversibility. The description is adequate but not thorough.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description must compensate. It explains the 'index' parameter via reference to read_document, but does not elaborate on 'path' or 'author' (default 'AI 律师助手'). The description adds some value for index but leaves other parameters unexplained.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (delete paragraph) and the specific resource (paragraph at index 0-based), referencing read_document for index understanding. It distinguishes from siblings like insert_paragraph and replace_text by highlighting revision mode.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for deleting paragraphs by index but provides no explicit guidance on when to use this vs alternatives (e.g., replace_text or insert_paragraph). No exclusions or conditions are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

insert_paragraphA

在第 after_index 段(从 0 计,见 read_document)之后以修订方式插入新段落。

style 可选,填文档已有的段落样式名(如 "Heading 2")。

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes
textYes
styleNo
authorNoAI 律师助手
after_indexYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description explicitly states that insertion uses revision mode, which is a key behavioral trait. With no annotations provided, this adds important context. It also explains the index counting method, but does not cover all behavioral aspects like whether styles must exist or what the output contains.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences conveying all essential information without any redundant phrases. It is well-structured and front-loads the core action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the presence of an output schema and 5 parameters, the description provides sufficient context for the key parameters and insertion behavior. It references read_document for index counting, aiding understanding. However, missing explanation for path and author slightly reduces completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaning for after_index (counting from 0, see read_document) and style (optional, existing style names). However, it does not explain path, text, or author parameters, leaving gaps for 3 out of 5 parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool inserts a new paragraph after a specific index using revision mode. It distinguishes from siblings like delete_paragraph and replace_text by specifying the action and context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by mentioning the after_index parameter and reference to read_document for index counting, and notes style is optional with existing names. However, it does not explicitly state when not to use this tool or provide alternatives like replace_text.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_revisionsA

列出文档中现存的全部修订(含此前人工修订),返回 JSON。

用于编辑后自检,或向用户汇报"本次共产生了哪些修订"。

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It states the tool lists revisions (read operation) but does not explicitly declare it as read-only or safe. It adds a behavioral detail about including manual revisions, but lacks notes on prerequisites or side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, front-loaded with the core purpose, and each sentence adds value. No unnecessary words. It is concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has one simple parameter and an output schema (not shown). The description explains the purpose and use cases adequately. It lacks details about path validation or document existence requirements, but this is a minor gap given the simplicity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%. The only parameter is 'path', and the description does not explain its meaning or expected format. The parameter semantics rely entirely on the schema name, which is insufficient for effective use.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool lists all existing revisions (including manual ones) and returns JSON. It provides specific use cases (post-editing self-check, reporting revisions). The verb 'list' and resource 'revisions' are clear, and it distinguishes from sibling tools which are editing operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives explicit usage context: after editing to self-check or to report revisions. It does not explicitly state when not to use it or list alternatives, but the context of sibling tools (all modification actions) makes it clear this is for reading revision history.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

read_documentA

读取 Word 文档(.docx)的全部段落。path 必须是绝对路径。

返回 JSON 数组,每段含 index(段落序号,编辑工具以此定位)、style(样式名)、 text(接受全部现有修订后的有效文本)。编辑前必须先读取文档。

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It discloses the output format (JSON array with index, style, text) and how text is computed (after accepting all revisions). It does not mention permissions or side effects, but for a read tool this is sufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, each serves a purpose: first states action, second gives constraint, third describes output and usage. No unnecessary words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the presence of an output schema (not shown), the description adequately explains the return structure. It also ties to sibling tools by noting the prerequisite relationship. For a read tool with one parameter, this is complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so description must compensate. It adds that 'path must be absolute path', which is crucial beyond the type 'string'. Also it implies that the path points to a .docx file.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Read all paragraphs of a Word document (.docx)', specifying the verb (read) and resource (document paragraphs). It distinguishes from sibling editing tools by saying 'must read before editing', establishing it as a prerequisite.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly says 'Must read the document before editing', providing clear usage context. It does not explicitly state when not to use it, but the implication that it's for reading before editing is strong.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

replace_textA

以修订模式(Track Changes)替换文档中的文本。

修改不会直接生效,而是写成 Word 修订(删除线 + 下划线),由用户在 Word 审阅界面逐条接受/拒绝。old_text 在全文只出现一次时才会替换;出现多次时 需提供更长的唯一上下文,或明确 replace_all=True 全部替换。 new_text 传空字符串表示纯删除。

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes
authorNoAI 律师助手
new_textYes
old_textYes
replace_allNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description bears full responsibility for behavioral disclosure. It transparently explains the Track Changes behavior, the condition that old_text must appear only once for replacement, and that empty new_text means deletion. It lacks details on permissions or response format, but the core behavioral traits are well communicated.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise, using a single paragraph with line breaks for clarity. It front-loads the key purpose and behavioral details. Every sentence adds value, though some parameter descriptions could be more structured. It achieves good readability without excessive verbosity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has 5 parameters and an output schema (not shown). The description covers the main behavioral aspects and parameter usage for the most critical parameters. It does not address the return value, but the presence of an output schema mitigates this. The description is mostly complete for a text replacement tool, though missing details on path and author could be improved.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 5 parameters with 0% schema description coverage. The description adds meaning to old_text (must appear once), new_text (empty means deletion), and replace_all (boolean to replace all). However, path and author parameters are not explained; path's role as document path is implicit, and author's default value is not described. The description partially compensates for the schema gaps but not fully.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool replaces text using Track Changes mode, with specific verb '替换' (replace) and resource '文档中的文本' (text in document). It distinguishes from siblings like delete_paragraph and insert_paragraph, which operate on different structural units.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear usage context: it replaces text with revisions, noting that modifications are not direct but become Word revisions. It specifies conditions for replacement (single occurrence) and options (replace_all=True). However, it does not explicitly state when not to use the tool or suggest alternatives beyond the implicit context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 5 tool updatesv0.1.0
    • First observeddelete_paragraph
    • First observedinsert_paragraph
    • First observedlist_revisions
    • First observedread_document
    • First observedreplace_text

TDQS

A4.2/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose: reading, deleting paragraphs, inserting paragraphs, replacing text, and listing revisions. No overlap exists.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern in snake_case (delete_paragraph, insert_paragraph, list_revisions, read_document, replace_text).

Tool Count5/5

Five tools is well-scoped for a Word document editing server, covering essential operations without bloat.

Completeness4/5

Core CRUD operations are present (read, insert, delete, replace text, list revisions), but missing tools like modify paragraph style or accept revisions are minor gaps.

Maintenance

ActivityStale
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/leeyang0916/word-agent-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server