Office Addin Mcp

io.github.dsbissett由 GitHub 账号 dsbissett 发布v0.8.0更新于 Nov 3, 2026

MCP server for Office add-ins via WebView2/CDP. Provides excel.*, page.*, and addin.* tools.

概览

AI 生成的概览

本地 MCP 服务器,通过 CDP 连接 Office 的 WebView2 加载项,让助手读取和修改 Excel、Word、Outlook、PowerPoint 与 OneNote 内容。

可以做什么
  • 汇总、表格化、查询并批量修改 Excel 工作簿,含服务端筛选/分组/聚合 DSL
  • 发现 Word 文档结构并批量执行查找替换编辑
  • 查询 Outlook 邮箱与当前邮件,并在撰写模式下设置主题或正文
  • 查询 PowerPoint 幻灯片并重写标题或正文要点;查询 OneNote 笔记本并向页面追加 HTML 或要点
  • 读取 Excel 区域并嵌入 PowerPoint 幻灯片,把工具调用序列录制为可重放的宏,管理加载项生命周期
  • 作为备选提供页面自动化:截图、快照、点击、输入、导航、控制台与网络日志
适用场景
适合让助手在 Windows 上直接操作已打开的 Office 文档和邮件,例如汇总工作簿、按区域透视表格、起草回复或重建幻灯片,免去用户来回复制数据。在 macOS 和 Linux 上也可用于无头 Chrome 页面自动化。
运行要求
以本地 stdio 进程运行,通常通过 npx(需 Node.js 14+)或预编译二进制启动;从源码构建需 Go 1.22+。Office 相关工具需要 Windows 10/11 上的 Office,并开启 WebView2 调试端口(设置 WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS 为远程调试端口),或用 --launch-addin 侧载加载项项目。服务器默认探测本地调试端点。
安装前请注意
工具会写入真实文档、邮件草稿、幻灯片和笔记本,runScript 类工具会执行任意 Office.js 回调,改动可能造成破坏。--allow-dangerous-cdp 标志(环境变量 OAMCP_ALLOW_DANGEROUS_CDP)会启用崩溃/终止类 CDP 方法。文档结构快照会缓存到本地 doccache 文件。当服务器负责启动时,它会重启 Office 并可能启动开发服务器。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Office Addin Mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

office-addin-mcp

Drive Excel, Word, Outlook, PowerPoint, and OneNote add-ins from any MCP client — through one Go binary that speaks the Model Context Protocol over stdio.

office-addin-mcp attaches to the WebView2 runtime that Office uses to host Office.js add-ins, then exposes a high-level tool surface to LLM clients. Instead of teaching the model how to chain 15 raw Office.js primitives, the server ships one tool call per workflow.

See the latest release · CHANGELOG.md · PLAN-workflow-surface.md.

Highlights

  • Workflow tools, not primitives. excel.tabulateRegion, word.applyEdits, outlook.draftReply, powerpoint.rebuildSlideFromOutline, onenote.appendToPage, and excel.summarizeWorkbook each compress what used to be 5–20 calls into one Office.js batch (one CDP round-trip).
  • Server-side query DSL. excel.query / outlook.query / powerpoint.query / onenote.query run filter / project / groupBy / agg / limit inside the host so a 100k-row workbook returns a 5-row answer.
  • Persistent document context cache. *.discover tools snapshot workbook / document / mailbox / deck / notebook structure to %LOCALAPPDATA%\office-addin-mcp\doccache.json so repeat discovery calls cost zero CDP round-trips.
  • MCP Resources with live subscriptions. Reference Office state by URI — office://excel/Book1/Sheet1!A1:D20, office://word/<doc>/bookmark/<name>, office://outlook/inbox, office://pp/<deck>/slide<N>, office://onenote/<notebook>/<section>/<page> — and subscribe to notifications/resources/updated when contents change.
  • Macro record & replay. macro.record_start → run any sequence of tools → macro.record_stop writes a JSON macro to disk. On next launch the server registers each macro as a callable macro.<name> tool.
  • Auto-diagnostics on Office.js errors. ItemNotFound, address parse failures, slide-index errors, and compose-vs-read mismatches are enriched in the failure envelope with available_sheets, nearest_name_suggestions, parsed_address, slide_count, item_mode, and a recoveryHint — so the model can self-correct without a second round-trip.
  • Self-healing CDP connection. If Excel closes unexpectedly, the server detects the dead connection on the next tool call, stops the stale sideload registration, relaunches Excel (including the dev server if needed), resets the session pool, and retries the original operation — no agent intervention required. Only activates when the server owns the launch (via --launch-addin or a prior addin.launch call); attaching to an external --browser-url endpoint is never disturbed.
  • Progress notifications on long operations. addin.launch, addin.ensureRunning, and macro replay stream MCP $/progress notifications at each phase boundary (dev-server start, sideload, CDP-ready wait, step execution) so clients can show a live status bar instead of a silent spinner.
  • Cross-host orchestration. office.embed reads a range from Excel and inserts it onto a PowerPoint slide in one call.
  • Page automation fallback. page.* / pages.* / inspect.* / interact.* cover screenshot, snapshot, click, fill, type, hover, navigate, evaluate, wait, console log, network log — same primitives against headless Chrome on macOS/Linux.
  • Per-host runScript escape hatch. excel.runScript, word.runScript, outlook.runScript, powerpoint.runScript, onenote.runScript run arbitrary <Host>.run callbacks when the workflow surface isn't enough.

Requirements

RequirementNotes
Office on Windows 10/11Required for all *.runScript / *.query / *.discover / *.applyDiff / addin.* tools — Office only uses WebView2 on Windows
Node.js 14+For the npx install path
Go 1.22+Only needed to build from source
macOS / LinuxSupported for page.* / pages.* against headless Chrome (no Office)

Install

npm (recommended)

bash
npm install -g @dsbissett/office-addin-mcp

Or run on demand without installing:

bash
npx @dsbissett/office-addin-mcp@latest --help

Pre-built binaries for Windows x64, macOS (Intel + Apple Silicon), and Linux (x64 + ARM64) ship via optional npm dependencies — the correct binary is fetched automatically.

Build from source

bash
go install github.com/dsbissett/office-addin-mcp/cmd/office-addin-mcp@latest

Use it in Claude Code

One command registers the server globally:

bash
claude mcp add office-addin-mcp -- npx -y @dsbissett/office-addin-mcp@latest

Or add it manually. Project scope (.claude/mcp.json in the repo) or user scope (~/.claude.json → mcpServers) both work:

json
{  "mcpServers": {    "office-addin-mcp": {      "command": "npx",      "args": ["-y", "@dsbissett/office-addin-mcp@latest"]    }  }}

Then, in any Claude Code session:

  1. Open the Office host (see Office host setup below) so the WebView2 debug port is listening.
  2. Ask Claude to do something — e.g. "Summarize the workbook, then pivot the Sales sheet by region." It will pick excel.summarizeWorkbook and excel.query automatically.
  3. Run /mcp in Claude Code to inspect the tool list, or claude mcp list from a shell.

Tip: pass --launch-addin and Claude can sideload the add-in project under the current working directory automatically. No manual env var needed.

Use it in other MCP clients

VS Code (GitHub Copilot)

Workspace config at .vscode/mcp.json:

json
{  "servers": {    "office-addin-mcp": {      "type": "stdio",      "command": "npx",      "args": ["-y", "@dsbissett/office-addin-mcp@latest"]    }  }}

Or: Command Palette → MCP: Add Server → paste the command.

Cursor

~/.cursor/mcp.json (global) or .cursor/mcp.json (project):

json
{  "mcpServers": {    "office-addin-mcp": {      "command": "npx",      "args": ["-y", "@dsbissett/office-addin-mcp@latest"]    }  }}
Codex (OpenAI)

~/.codex/config.toml:

toml
[mcp_servers.office-addin-mcp]command = "npx"args = ["-y", "@dsbissett/office-addin-mcp@latest"]
Windsurf

~/.codeium/windsurf/mcp_config.json:

json
{  "mcpServers": {    "office-addin-mcp": {      "command": "npx",      "args": ["-y", "@dsbissett/office-addin-mcp@latest"]    }  }}
Any MCP-compatible client
  • command: npx
  • args: ["-y", "@dsbissett/office-addin-mcp@latest"]
  • transport: stdio

Office host setup

Office hosts only expose their WebView2 runtime to CDP when started with a debug-port env var. The variable is shared across every Office app, so the same setup works for all five:

PowerShell

powershell
$env:WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS = "--remote-debugging-port=9222"Start-Process excel.exe my-workbook.xlsx# or:  Start-Process winword.exe my-document.docx# or:  Start-Process outlook.exe# or:  Start-Process powerpnt.exe my-deck.pptx# or:  Start-Process onenote.exe

Command Prompt

cmd
set WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9222excel.exe my-workbook.xlsx

The server probes http://127.0.0.1:9222 by default. Override with --browser-url or --ws-endpoint. Or skip the setup entirely with --launch-addin — the server will detect the Office add-in project under cwd and sideload it through office-addin-debugging.

Tool surface

Phase 0 of PLAN-workflow-surface.md deleted the raw cdp.* surface; everything below is the workflow-shaped replacement. Each workflow tool is one MCP call → one Office.js batch → one CDP round-trip.

Excel

ToolPurpose
excel.summarizeWorkbookSheets, tables, named ranges, used-range bounds — single call
excel.tabulateRegionLoad a range, return rows-as-objects + per-column type tags
excel.queryServer-side filter / project / groupBy / agg / limit DSL
excel.discoverPersistent workbook fingerprint snapshot (doccache)
excel.applyDiffBatch cell/range patches in one Excel.run
excel.runScriptRun an arbitrary Excel.run callback

Word

ToolPurpose
word.discoverDocument structure snapshot
word.applyEditsBatch find/replace edits in one Word.run
word.runScriptRun an arbitrary Word.run callback

Outlook

ToolPurpose
outlook.queryQuery the mailbox / current item
outlook.discoverMailbox + active-item snapshot
outlook.draftReplySet subject and/or body on a compose-mode item
outlook.runScriptRun an arbitrary callback against Office.context.mailbox

PowerPoint

ToolPurpose
powerpoint.querySlide-level query DSL
powerpoint.discoverDeck structure snapshot
powerpoint.rebuildSlideFromOutlineRewrite a slide's title and/or body bullets
powerpoint.runScriptRun an arbitrary PowerPoint.run callback

OneNote

ToolPurpose
onenote.queryNotebook / section / page query DSL
onenote.discoverNotebook structure snapshot
onenote.appendToPageAppend HTML and/or bullets to a page
onenote.runScriptRun an arbitrary OneNote.run callback

Cross-host & macros

ToolPurpose
office.embedRead an Excel range and insert it on a PowerPoint slide
macro.record_startBegin capturing subsequent tool calls into a named macro
macro.record_stopFinalize and persist the macro to disk
macro.<name>Replay a persisted macro (auto-registered on next startup)

Add-in lifecycle & generic page automation

Tool groupPurpose
addin.*ensureRunning (start here — probes then launches if needed), launch, stop, detect, status, contextInfo, cfRuntimeInfo, openDialog, dialogSubscribe, dialogClose, listTargets
page.*screenshot, snapshot, click, fill, typeText, hover, navigate, evaluate, pressKey, waitFor, consoleLog, networkLog, networkBody
pages.*list, select, close, handleDialog
inspect.* / interact.*DOM / accessibility inspection and higher-level interaction primitives

MCP Resources

LLM clients can reference Office state by URI instead of re-fetching it every turn. Five resource templates are registered on startup:

URI templateBacked by
office://excel/<workbook>/<sheet>!<range>excel.tabulateRegion
office://word/<doc>/bookmark/<name>word.runScript (inline script)
office://outlook/<folder>outlook.query
office://pp/<deck>/slide<N>powerpoint.query
office://onenote/<notebook>/<section>/<page>onenote.query

Resources support resources/subscribe. The server polls fingerprints every 30s and emits notifications/resources/updated when content changes; resources/unsubscribe (or client disconnect) tears down the polling goroutine.

Performance notes

  • urlPattern selects the WebView2 page by substring match against the target URL. After the first call against a session, the selector cache drops diagnostics.cdpRoundTrips from ~3 to 1 on subsequent calls.
  • The session pool allows 3 reconnects per 60-second window. Exhaustion surfaces as connection/session_acquire_failed. If the server owns the launch, it attempts one automatic stop+relaunch cycle before surfacing that error, so transient Excel restarts are transparent to the agent.
  • DocCache snapshots are atomic-rename writes, mode 0600. Disable with --no-doccache.

Flags & environment variables

FlagEnvDefaultDescription
--browser-url—http://127.0.0.1:9222WebView2 / Chrome debug endpoint
--ws-endpoint——Direct browser WebSocket URL (overrides --browser-url)
--log-file—stderrAppend diagnostics to a file instead of stderr
--log-level—infoslog level: debug, info, warn, error
--launch-addin—offAuto-detect and sideload the Office add-in project under cwd at startup, only if no CDP endpoint is reachable
--launch-excel—offDeprecated alias for --launch-addin
--no-doccache—offDisable the persistent document discovery cache (*.discover still runs; reads/writes to doccache.json are skipped)
--allow-dangerous-cdpOAMCP_ALLOW_DANGEROUS_CDPoffEnable crash/terminate CDP methods
--version——Print binary version and exit

The binary takes no positional subcommands — it speaks MCP over stdio. The legacy call / daemon / serve --stdio subcommands have been removed.

Layout

cmd/office-addin-mcp/   main entryinternal/tools/         registry, dispatcher, envelope, diagnosticsinternal/cdp/           hand-rolled CDP WebSocket clientinternal/webview2/      endpoint discoveryinternal/session/       session pool + reconnect budgetinternal/officejs/      Office.js executor + payloadsinternal/js/            embedded Office.js scriptsinternal/doccache/      persistent document discovery cacheinternal/resources/     office:// URI parsing + provider + polling watcherinternal/recorder/      macro recorder storeinternal/tools/macrotool/  macro.record_start / record_stop / replayinternal/mcp/           SDK server wiring + resource registration

License

MIT

来源:README.md,提交 fc2ee47

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.8.0最新Sep 16, 2026

评分

已满足适用检查项的 40%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

    请在仓库或注册中心条目中声明许可证。