adeu
Adeu:AI 原生修订模式
大语言模型 (LLM) 使用 Markdown;律师使用“修订模式 (Track Changes)”。
Adeu 是一个模型上下文协议 (MCP) 服务器和 Python SDK,充当 Microsoft Word 的“虚拟 DOM”。它提供了一个双向抽象层,允许 AI 代理自由编辑文档文本,而不会破坏底层格式或复杂的 DOCX XML。
虽然像 python-docx 这样的标准库擅长从零开始生成文档,但它们在非破坏性修订方面表现不佳。Adeu 通过将 .docx 文件转换为标记高效的 Markdown 表示形式解决了这个问题。这使得 AI 代理能够完全专注于文档语义,而不必浪费 Token 去处理 OpenXML。
Adeu 充当智能代理,将 AI 的编辑处理为安全、原子的事务:
提取: 将文档(从磁盘或实时 Word)转换为对 LLM 友好的 CriticMarkup,并附带包含定义术语、交叉引用和潜在拼写错误的语义附录。代理从语义结构开始,而不是原始数据。
验证: 充当严格的安全门。它通过在文件修改前自动阻止模糊的文本匹配或无效的结构更改,来保护文档的完整性。
提交: 将 AI 的文本编辑转换为原生的 Word 修订记录。Adeu 在底层处理复杂的 XML,确保现有的布局、字体和页边距注释得到完美保留。
由 Adeu 维护。
设置
先决条件: Adeu 使用 uv 进行快速、隔离的执行。最简单的安装方法是通过 pip:
pip install uvmacOS
curl -LsSf https://astral.sh/uv/install.sh | shWindows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"Claude Desktop 集成
要立即将 Adeu 添加到 Claude Desktop,请运行:
uvx adeu init[!IMPORTANT] 此命令会自动检测并更新您的
claude_desktop_config.json。 之后请重启 Claude Desktop 以加载新工具。
验证是否正常工作
Claude Desktop 重启后,您可以直接向 Claude 发送以下消息来确认 Adeu 已连接:
“你能使用 Adeu 工具读取 DOCX 文件吗?”
如果设置正确,Claude 将确认它有权访问 Adeu 工具并描述其功能。如果它没有提到 Adeu 或说它没有文件工具,请仔细检查您在运行 uvx adeu init 后是否重启了 Claude Desktop。
由于 Adeu 需要 Python 3.12+,uvx 将自动处理下载正确的 Python 版本并运行服务器:
{
"mcpServers": {
"adeu": {
"command": "uvx",
"args": ["--from", "adeu", "adeu-server"]
}
}
}Related MCP server: docx-mcp
工作流程
1. 针对代理 (Claude / MCP)
Adeu 作为模型上下文协议 (MCP) 服务器运行。它为代理提供了特定的工具来安全地读取、审查和编辑文档。
MCP Apps UI:
read_docx工具支持最新的 MCP Apps UI 协议。当代理读取文档时,Adeu 会直接在您的 Claude 聊天窗口中动态渲染一个自定义的交互式 Markdown UI 视图——让您可以直观地查看提取的文本和格式,以及 AI 的推理过程!
推荐的代理提示词: 虽然 Adeu 的工具会自动向 LLM 描述其自身的模式,但您可以通过将此上下文添加到 Claude 的项目说明 (Project Instructions) 或代理的系统提示词中,来确保获得最佳的行为结果:
角色: 文档专家 工具:
read_docx(clean_view=True):读取文档的最终“干净”版本以了解上下文。
process_document_batch:提交与协商模式。 应用统一的更改列表。使用type: "modify"进行特定的查找和替换文本编辑,并使用type: "accept"、"reject"或"reply"来按 ID 管理现有的修订记录和注释。
sanitize_docx:发送前清理。 在共享前剥离危险的元数据、作者姓名和内部跟踪 ID。可以保留现有标记 (keep_markup=True) 或根据基准生成干净的差异。
实时 MS Word 集成
如果您在安装了 Microsoft Word 的 Windows 上运行,Adeu 可以充当实时副驾驶,在您面前直接编辑活动文档。
read_active_word_document:直接从实时打开的 Word 窗口中提取文本、修订记录和注释。process_active_word_batch:将 LLM 的编辑转换为原生的 COM 宏,自动观察 Word 在画布上进行键入、删除和添加注释的操作。
2. 针对开发者 (Python SDK)
如果您正在构建法律科技应用程序或自动化流水线,请直接使用 RedlineEngine。它处理 XML 操作的繁重工作。
from adeu import RedlineEngine, ModifyText
from io import BytesIO
# 1. Load the contract
with open("MSA.docx", "rb") as f:
stream = BytesIO(f.read())
# 2. Define the edit (e.g., from an LLM response)
# Adeu uses fuzzy matching to locate the target text, even if whitespace varies.
edit = ModifyText(
target_text="State of New York",
new_text="State of Delaware",
comment="Standardizing governing law."
)
# 3. Apply changes
engine = RedlineEngine(stream, author="AI Copilot")
engine.apply_edits([edit])
# 4. Save the result
with open("MSA_Redlined.docx", "wb") as f:
f.write(engine.save_to_stream().getvalue())3. CLI
从终端快速检查文档或应用批量编辑。
# Extract clean text for RAG or prompting
adeu extract contract.docx -o contract.md
# Generate a visual diff between two versions
adeu diff v1.docx v2.docx
# Preview what an edit list (JSON) would look like
adeu markup contract.docx edits.json --output preview.md
# Apply edits to the DOCX
adeu apply contract.docx edits.json --author "Review Bot"
# Scrub author metadata and internal trackers, but keep the visual redlines for the counterparty
adeu sanitize redline.docx -o clean.docx --keep-markup --author "My Firm" --report主要功能
格式安全
Adeu 不会“重写”文档。它进行修补。
图像与布局: 保持不变。
编号与页眉: 得到保留。
表格与列表: 复杂的网格跨度和多级法律编号受到明确保护。
复杂 XML: 它仅修改编辑所针对的文本运行 (text runs)。
CriticMarkup 表示
中间表示很重要。Adeu 使用 CriticMarkup 来可视化更改。
标记 | 含义 | 示例 |
| 删除 |
|
| 插入 |
|
| 注释 |
|
语义附录
合同中充满了 LLM 在第一遍阅读时会遗漏的地雷:定义术语使用不一致、断开的交叉引用以及混乱文档中的 OCR 式拼写错误。Adeu 在提取时预先计算这些内容,并在文本旁边向代理提供结构化附录。
智能映射
Word 文档很混乱。“Contract”这样的词可能会因为拼写检查或格式历史记录而被拆分为 ["Con", "tract"] 这样的 XML 运行。
运行合并: Adeu 规范化这些拆分,以便 AI 看到的是“Contract”。
模糊匹配: 它处理 LLM 内存与实际文档内容之间的细微空格差异。
元数据清理
现有的元数据清理器会破坏修订记录或静默剥离数据。Adeu 的 sanitize 命令会手术式地移除危险的跟踪器(rsids、模板、内部路径、时间戳)和孤立内容,同时保留有效的修订记录。关键的是,它会生成一份透明的审计报告,证明确切剥离了什么内容,以及接收者将看到什么。
Adeu Cloud
默认情况下,核心 Adeu 修订引擎和本地文件工具是完全开源的,并完全在您的机器上执行。Adeu 绝不会将您的本地文档发送到云端(尽管您选择的 LLM 提供商自然会处理代理读取的文本)。
但是,您可以明确选择将您的 MCP 服务器连接到 Adeu Cloud 以解锁:
端到端工作流程(电子邮件): 由于合同通过电子邮件传输,Adeu Cloud 允许代理安全地获取电子邮件线程,提取交易对手的 DOCX 附件进行审查,并附带您新清理的修订记录草拟回复。
高级文档验证: 异步运行复杂的、多文档的语义验证任务。通过将这些海量上下文安全地路由到 Adeu Cloud 进行处理,您可以防止本地 AI 代理耗尽其上下文窗口或达到速率限制。
贡献
我们欢迎社区的贡献!无论是修复错误、添加功能还是改进文档,请参阅我们的 贡献指南,了解如何设置本地 uv 环境、运行测试以及理解项目的严格 XML 安全准则。
许可证
MIT 许可证。开源且可免费用于商业应用程序。
Available Tools
11 toolsaccept_all_changesADestructive
Accepts all tracked changes and removes all comments in a single operation, producing a finalized clean document. Use this when a document review is entirely complete and you want to clear all redlines. For selective acceptance/rejection of specific changes, use process_document_batch instead.
Inputs: docx_path (required), output_path. Returns: result
create_email_draftA
Creates an email draft in the user's native draft box (e.g., Outlook/Gmail). Can either start a NEW email, or REPLY to an existing thread. To REPLY, provide 'reply_to_email_id' (the short ID from search_and_fetch_emails). To start a NEW email, omit the ID but provide 'subject' and 'to_recipients'. Allows attaching local files (PDF/DOCX) by providing their absolute paths. The body should be formatted in Markdown.
Inputs: body_markdown (required), reply_to_email_id, subject, to_recipients, +1 more.
diff_docx_filesARead-only
Compares two DOCX files and generates a text-based Unified Diff. Use this to see exactly what changed between two versions of a document. By default (compare_clean=True), it compares the 'Accepted' finalized states of both documents. Set compare_clean=False if you need to compare the raw underlying text including Tracked Change CriticMarkup.
Inputs: original_path (required), modified_path (required), compare_clean. Returns: result
login_to_adeu_cloudA
Logs the user into the Adeu Cloud backend. Securely opens a browser window for authentication.
Inputs: no named parameters. Returns: result
logout_of_adeu_cloudA
Logs out of the Adeu Cloud backend by clearing the local API key from the OS Keychain.
Inputs: no named parameters. Returns: result
open_local_fileA
Opens a local file in its native desktop application (e.g., Microsoft Word for DOCX files).
Inputs: file_path (required). Returns: result
process_document_batchADestructive
Applies a batch of structural edits, text modifications, and review actions to a document. This is your primary tool for editing DOCX files.
CRITICAL: All changes in the batch evaluate against the ORIGINAL document state. Do not send sequential edits that depend on each other within the same batch (e.g. rename X to Y, then modify Y). Instead, apply the rename in one batch, then modify Y in a subsequent batch.
The changes parameter is a list of operations. Each item MUST have a type:
'modify': Search-and-replace text. Provide exact
target_text(CRITICAL: include surrounding context if the word appears multiple times to ensure unique matching) andnew_text(the replacement).new_textsupports full Markdown structure: '# Heading 1' through '###### Heading 6' at the start of a line for heading styles, 'bold' and 'italic' inline formatting, and blank lines ('\n\n') to splitnew_textinto multiple paragraphs. Multi-paragraph inserts are tracked as one logical revision. To delete text, makenew_textempty. Do NOT manually write CriticMarkup tags ({++, {--, {>>). To add a comment, use the 'comment' parameter.'accept': Finalize a tracked change. Requires
target_id(e.g., 'Chg:12'). (Note: Accepting one half of a paired modify cascades to accept the other half).'reject': Revert a tracked change. Requires
target_id(e.g., 'Chg:12'). (Note: Rejecting one half cascades to reject the other half).'reply': Reply to a comment. Requires
target_id(e.g., 'Com:5') andtext.'insert_row': Insert table row. Requires
target_text(anchor),position('above'/'below'), andcells(Markdown strings).'delete_row': Delete table row. Requires
target_textinside the row to be deleted.
Always provide a realistic author_name for Tracked Changes. This name will be used for attribution in the document's tracked changes and comments.
Inputs: original_docx_path (required), author_name (required), changes (required), output_path. Returns: result
read_docxARead-only
Reads a DOCX file and extracts its text content. Use this to ingest documents into your context window. By default (clean_view=False), it returns text with inline CriticMarkup (e.g., {++inserted++}, {--deleted--}, {==highlighted==}{>>comment<<}) representing Tracked Changes and Comments. Set clean_view=True ONLY if you want to read the final, clean text, ignoring all redlines and comments.
PAGINATION & OUTLINE:
mode='outline' returns a structural map of headings with page numbers, styles, table presence, and referenced footnotes. Body content is omitted. Use this first on large documents to plan targeted reads.
mode='full' (default) returns the document body. Documents over ~19,000 characters are split into pages; use page=N to read a specific page (1-indexed). Documents under the limit are returned in full on page 1.
Page boundaries differ between clean_view=True and clean_view=False.
The Structural Appendix (defined terms, anchors, diagnostics) is repeated on every page.
Inputs: file_path (required), clean_view, mode, page.
sanitize_docxADestructive
Sanitizes a DOCX file by stripping dangerous metadata (rsids, author names, template paths, DMS metadata, hidden text, orphaned content) and producing an audit report of everything removed. Use this before sending documents to external parties. Supports three modes: full scrub (for signing/closing), keep-markup (preserves your track changes and open comments), or baseline (recomputes your delta against the original document).
Inputs: file_path (required), output_path, keep_markup, baseline_path, +2 more. Returns: object
search_and_fetch_emailsARead-only
Searches the user's live email inbox. By default, searches only the Inbox folder (matching what the user sees in their mail client) — this excludes deleted items, drafts, and spam. Use filters to find specific emails (e.g., 'is_unread=True' for new emails, 'days_ago=7' for last week, 'folder=sent' for sent items, 'folder=all' to search the entire mailbox including trash). It returns a list of lightweight email previews. To read the full email body, thread history, and automatically download attachments to local disk, call this tool again and provide the specific email_id. Emails often contain attachments. It is highly recommended to always provide the working_directory parameter so attachments are saved directly to the user's actual project folder. This directory path refers to the user's native operating system, not the LLM's sandbox environment.
Inputs: sender, subject, has_attachments, attachment_name, +7 more.
validate_documentsA
Validates documents for inconsistencies, contradictions, and risk assessments. To START a new validation, provide 'file_paths' as a JSON-encoded string representing a list of file paths. This will immediately return a task_id. To CHECK the status of a validation, call this tool AGAIN and provide ONLY the 'task_id'. The checking process will poll for up to 50 seconds. If it times out, continue checking.
Inputs: file_paths, task_id.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Each tool targets a distinct operation (auth, email, document reading/editing/finalization/comparison/sanitization/validation) with clear boundaries. No two tools serve overlapping purposes.
All tool names follow a consistent verb_noun snake_case pattern (e.g., accept_all_changes, create_email_draft, sanitize_docx). No mixing of styles or vague verbs.
The 11 tools cover the core functionality (document editing, email handling, authentication) without being excessive. Each tool serves a well-defined purpose.
The set covers read, edit, finalize, compare, sanitize, search/create drafts, and validate. However, adding new comments is not directly exposed (only replying), which is a minor gap.
Maintenance
Related MCP Connectors
Contract review that keeps your contracts: cited answers, Word redlines, key-date alerts.
Convert, create and edit Word, PowerPoint, Excel and PDF documents from any AI agent.
Create documents and reusable templates, request signatures, and track approvals — for AI agents.
AI contract management (CLM): contract review, data extraction, reminders and renewal deadlines.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables creating professional Word documents from markdown or structured content with fast, customized formatting via natural language.71ISC
- AlicenseAqualityDmaintenanceLegal document redlining engine that applies AI-generated JSON changes as professional tracked changes with comments in .docx files, producing Word-indistinguishable output.61MIT
- AlicenseBqualityCmaintenanceStructure-preserving Word DOCX editing MCP server with a .NET Open XML backend and Office.js live sessions. Enables safe, auditable, incremental editing of Microsoft Word documents for AI agents.6312 npm10AGPL 3.0
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to generate format-stable, editable Word DOCX documents from structured content and reusable templates, with document type recognition, schema retrieval, template rendering, validation, and conservative fixes.MIT