
OfficeAgent.NET
io.github.ilia-sokolov由 GitHub 账号 ilia-sokolov 发布v1.2.0更新于 Oct 24, 2026
Create and edit Word, PowerPoint, and Excel files with typed plans and safe previews
概览
本地 MCP 服务器,让助手通过带类型校验的计划和预览来创建、编辑 Word、PowerPoint 和 Excel 文件。
- 可以做什么
- 检查文档结构并查找文本,返回内容校验过的定位锚点
- 预览并提交针对 Word、PowerPoint、Excel 文件的类型化编辑计划
- 编辑 Word 的文本、表格、样式、图片、批注与修订记录
- 构建或更新 PowerPoint 演示文稿:幻灯片、版式、图表、备注、节、切换
- 检查工作表与区域,设置单元格和公式,追加表格行
- 填充模板、比较 Word 文档,并在启用后新建文件
- 适用场景
- 适合需要助手对本机已有 Office 文件做精准、可复核修改的场景,例如修订合同条款、依据工作簿更新报告或演示文稿,或用带标签的模板批量生成文档。
- 运行要求
- 以本地进程通过 stdio 运行;可作为 .NET 工具安装(dotnet tool install OfficeAgent.Mcp),或使用 Windows 与 macOS 的独立桌面安装包。需配置文件系统连接,设置 OfficeAgentFileSystemConnections0ConnectionId 与 OfficeAgentFileSystemConnections0RootPath;另有可选设置用于开启新建文档、额外文件扩展名、内联内容和会话连接。未声明身份验证。
安装
在 SourceWeft 中
- 打开 控制台中的 OfficeAgent.NET,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
OfficeAgent.NET
[build] [NuGet] [.NET 8 | 10] [API: SemVer 1.x stable] [native Office: 83/83 cases verified] [OpenSSF Best Practices] [OpenSSF Scorecard] [good first issues] [license]
OfficeAgent.NET is a .NET document-automation library built on the
Open XML SDK. Its direct
.NET API turns document intent into typed, validated operations for Word .docx,
PowerPoint .pptx, and Excel .xlsx packages.
Use it to generate documents and presentations, make targeted edits, update tables,
styles, and images, or manage comments and review state. An MCP server and adapters
for Microsoft Agent Framework and Microsoft.Extensions.AI are optional interfaces
to the same engine. Applications can use the engine directly without MCP.
One example is a targeted Word edit whose result remains reviewable:
[OfficeAgent.NET finds, previews, and applies a contract edit as a tracked change in Word.]
What this project does
An Office Open XML file is a package of related XML parts. A small change can affect runs, styles, numbering, comments, content controls, or revision markup. OfficeAgent.NET handles that document-specific work. The model works with structured document data and JSON-serialisable operations such as "replace this clause as a tracked change" or "add a row to this table."
The same engine is available in three forms:
- an MCP server for agents that support the Model Context Protocol;
- tools for Microsoft Agent Framework and
Microsoft.Extensions.AI; - a .NET API for applications that want to control the workflow directly.
It supports Word .docx, PowerPoint .pptx, and Excel .xlsx; one client routes
each document to the module that handles it. See Scope and limitations before choosing
it for a workflow that depends on Office's layout or calculation engine.
What you can build
Choose a starting point
Try a Word edit
This small workflow demonstrates that OfficeAgent can change an existing OOXML file without flattening its structure. It uses tracked changes because the result is easy to verify in Word; review is one part of the broader document operation set.
Install the exact server version documented by this release:
Make a folder for the agent to work in and download the sample contract into it — a fictional services agreement with a clause to change, a table, an open comment, and a pending redline:
PowerShell:
Any .docx of your own works too — the sample just gives you something with a comment and a
pending revision already in it.
Register the server with Claude Code, pointed at that folder and nothing else:
PowerShell:
For this review-specific workflow, you can optionally install the word-document-review skill before starting the client.
Then ask:
In services-agreement.docx, change the payment terms from thirty days to forty-five days.
Expected result when the client invokes OfficeAgent correctly: apply_plan reports
writeOutcome: "committed" and returns an output id, and clause 3 reads forty-five days
as a tracked change you can accept or reject. Open that output in Word and verify the change.
The regression test also verifies that the sample's existing table, comment, earlier payment
redline, and heading remain present with their tested XML semantics. It does not claim byte-for-byte
identity for every unrelated OOXML part; see the bounded preservation evidence.
If the agent did not call apply_plan, or if writeOutcome is not committed, do not report
the edit as complete. For unknown or writtenNotRegistered, preserve possibleOutput and
follow storage recovery instead of retrying blindly.
What else the sample is good for — reviewing comments, accepting revisions, editing the table.
Next, try creating a Word document, generating a PowerPoint deck, or using the direct .NET workflow.
If it does not work
Configure broader workflows
The quick start above is deliberately the smallest thing that works. Four settings extend it:
Past a couple of settings, use a file instead — the same OfficeAgent section, where a list
is a list:
The same configuration is available as
samples/config/word-and-powerpoint.json. Change
RootPath before using it.
Environment variables still override the file. Windows, PowerShell, other MCP clients, HTTP hosting and SharePoint are in Deployment and client setup; every setting is listed in MCP server.
Optional guidance for Word review
skills/word-document-review teaches the review
loop: read comments and pending revisions before editing, keep reviewable Word edits as
redlines, use document ids for multi-step work, and recover from stable error codes. The
installation guide gives complete Bash and PowerShell steps
for Claude Code and Codex, including installation from a fresh machine and verification.
The skill is only needed when the task requires that review discipline; document creation,
ordinary direct edits, and PowerPoint workflows use the server without it.
Optional guidance for application integration
skills/officeagent-integration helps an
implementation agent choose the direct .NET API first, add MCP or Microsoft Agent Framework
only when needed, and run installed-package recipes for tracked editing, template population,
and complete-plan comparison. The installation guide covers both
skills and makes clear that a skill does not install the runtime, NuGet packages, or MCP server.
What reaches the model
The inspect and find tools return document text and structure to the model — that is how it locates an edit. Filesystem and SharePoint operations keep the package behind an opaque id. Inline tools carry the whole file as base64 on every call. Session import/export also carries the package as base64 if the agent performs those calls; a host integration can instead move the bytes outside model context. Connect storage and model providers appropriate for the data.
The standalone server ships no authentication layer for HTTP hosting; put it behind your own, or start from the authenticated HostedGateway reference. A filesystem root is a trust boundary: its ACLs must stop untrusted principals creating, renaming or replacing entries while the server runs.
.NET quick start
Install the core package and Word module:
After registering services and a document provider, the edit loop looks like this:
Revision.Author is the name Word displays for the tracked change. It is not an
authenticated actor identity. See revision identity and audit receipts.
The complete example, including service registration and reading the saved file, is in Getting started. The minimal direct-.NET sample runs against the bundled fictional contract, so it needs no MCP client, language model, or document of your own:
Open quickedit-output.docx in Word and verify that the payment term is a tracked
change while the existing revision, comment, table, and headings remain intact.
QuickEdit also accepts an exact source and replacement text
for your own document. Releases also attach quickedit-sample.zip, a package-backed
copy that runs outside the repository against the released NuGet packages.
The repository also contains a
direct IChatClient Word-editing sample and an
interactive
Agent Framework sample, plus a complete
contract-review agent that separates model judgement from
validated document writes. The TemplateBatch sample generates two
quotes from one tagged template, while DocumentComparison
turns covered body-paragraph differences into a reviewable Word redline.
The DocumentAssembly sample combines a proposal, statement of
work, and appendix into one editable package with a multi-source audit receipt. See
Word document assembly for its formatting and compatibility scope.
How it works
Every edit follows the same four steps:
- Inspect returns a structured map of the document: its outline, paragraphs, styles, content controls, tables, images, and revisions.
- Find searches text and returns a content-verified anchor for each match.
- Preview validates a plan against the current document and reports the proposed changes without writing.
- Apply commits the complete plan and saves it through the configured provider.
A plan (DocumentPlan) is a typed, JSON-serialisable list of operations. An
anchor records both a location and the content expected there. If the content
or optional document snapshot has changed, validation fails instead of silently
targeting a different location. All operations are applied to one in-memory transaction or
none are; a later provider failure can still leave storage uncertain, so callers must inspect
writeOutcome before retrying.
The Word module supports changes to text, paragraphs, tables, images, styles, content controls, comment threads, footnotes and endnotes, page geometry and breaks, document properties, and tracked revisions. Operations with a Word revision representation record a redline when the connection asks for one - an inserted clause, a deleted row and a restyled heading all come back as revisions a reviewer accepts or rejects, not only a replaced phrase. Image resizing is applied directly because WordprocessingML has no revision representation for drawing dimensions. The PowerPoint module implements a broad, explicitly documented set of deck operations: text, bullets, run and paragraph formatting, template slots, style copying, tables, images, text boxes, embedded video and audio, speaker notes, resolvable comments, footers and slide numbers, sections, transitions and animations, and the slide lifecycle - adding, removing, reordering and duplicating. Several slide inserts in one plan author a deck end to end, so a single call turns nothing into a finished presentation. Any verb it does not support is named rather than silently skipped. The full operation schema is documented in Document plans, and the deck specifics in PowerPoint support.
Documents are accessed through configured providers. After registration,
editing calls use a (connectionId, documentId) pair instead of a storage path
or credentials. The filesystem provider restricts registrations to its root;
the SharePoint provider uses the permissions of its configured identity.
CreateAsync starts a new document inside a connection: the requested .docx
or .pptx extension selects a registered blank-document factory. The engine
applies an optional initial plan in memory, and then asks
the provider to create and register it without overwriting an existing name.
Documentation
Contributing
Bug reports, documentation fixes, new document operations, provider integrations, and focused test cases are useful contributions. If you found a problem, open an issue with the document feature involved, the operation you attempted, and the error or unexpected result. Do not attach confidential documents; a small sanitised reproduction is enough.
To work on the code, install the .NET 10 SDK and the .NET 8 runtime, fork the repository, and run:
Before starting a larger change, especially one that changes public types or the JSON wire format, open an issue so the design can be discussed. See CONTRIBUTING.md for code style, tests, and pull-request expectations.
Scope and limitations
OfficeAgent.NET edits Word .docx, PowerPoint .pptx, and Excel .xlsx files;
it does not automate the Office desktop applications.
The deck module refuses the verbs a presentation has no vocabulary for -
setProperty, revision, pageSetup, insertBreak and note - per
operation, rather than applying part of a plan, and refuses an explicit tracked
mode on any verb that carries one. PresentationML has no redline model, so tracked changes are Word-only, and
a slide has no header (that is a notes and handout concept). Animations cover
the effects expressible as a filtered p:animEffect; fly-in, zoom and motion
paths are refused rather than approximated. See
PowerPoint support for what a deck does and does not
accept.
The core engine does not render pages, calculate Word fields, or evaluate Excel formulas.
Formula edits set the workbook to recalculate when Excel opens it. The optional
OfficeAgent.Excel.Calculation package calculates a verified set of Excel functions and
writes the results as cached values; see formula calculation. Operations that depend on
pagination, table-of-contents rendering, or field recalculation are outside the core scope.
Preview reports structural changes. The optional rendering package can
produce PDF-derived page images through external processes, but it does not yet detect overflow
or page-fit problems. Test the workflow on representative documents and keep human review in the
loop for consequential edits.
Two more limits worth knowing before you build on it:
- Token savings depend on how you connect. Addressing a document by id keeps
the package out of the conversation, and inspection can be narrowed with
fidelityand paging - that is where the saving comes from. The inline*_contenttools are the deliberate exception: they carry the whole file as base64 in both directions, which costs tokens in proportion to file size. They suit a single self-contained call, not a sequence of edits - a model asked to pass a document of a few kilobytes back for a second edit reproduces it imperfectly and the follow-up fails. Use a connection, or a session connection, when more than one edit is coming. - Review guidance is optional. For review tasks, the server alone does not make an agent read open comments before editing or choose a redline. The word-document-review skill teaches that workflow; without it, review behaviour depends on the model and the prompt.
Commercial support
OfficeAgent.NET is MIT-licensed and can be self-hosted. Commercial support and deployment assistance are available from dotaction: contact dotaction. That service is separate from the project: it is governed by its own agreement and does not change the library's license, compatibility promise or community support policy.
Privacy Policy
OfficeAgent.NET runs on your machine or your own server and collects nothing: no telemetry, no analytics, no calls home. It reads and writes only the documents in the folders, SharePoint libraries, or session connections it is given, and contacts no third party except Microsoft Graph for a SharePoint connection a host configures. Tool results go to the AI assistant using it, under that assistant's own policy. The full policy, including what is stored and for how long, is in PRIVACY.md.
License
MIT. See LICENSE.
来源:README.md,提交 30143cb
工具
0版本历史
5- v1.2.0最新Oct 14, 2026
- v1.1.0Sep 30, 2026
- v1.0.0Sep 23, 2026
- v0.9.0Sep 21, 2026
- v0.8.0Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分