Skip to main content

A powerful Office document management environment designed for AI agents to interact with Office documents

Project description

Office4AI

Python Version License: MIT Version

Office4AI 是一个 MCP Server,让 AI Agent 通过 Office Add-In 实时读写 Office 文档。

当前状态: Word(9 个工具)已实现,PowerPoint 和 Excel 开发中。

支持平台

平台 状态 工具数
Word 已就绪 9
PowerPoint 规划中
Excel 规划中

快速开始

1. 安装证书(仅首次)

Office4AI 使用 HTTPS 与 Office Add-In 通信。运行 setup 生成并安装本地 CA 证书:

uvx office4ai-mcp setup

将生成本地 CA 和服务器证书,并将 CA 安装到系统信任存储(需要管理员权限)。

2. 启动服务

uvx office4ai-mcp serve

3. 配置 MCP 客户端

Claude Code(推荐)

claude mcp add office4ai -- uvx --from office4ai office4ai-mcp

Claude Desktop / Cursor 等 MCP 客户端

在 MCP 配置文件中添加:

{
  "mcpServers": {
    "office4ai": {
      "command": "uvx",
      "args": ["office4ai-mcp", "serve"]
    }
  }
}

4. 安装 Office Add-In

Office Add-In 通过 Socket.IO 连接 Microsoft Office 与 MCP Server。

Add-In 安装说明将另行提供,敬请关注。

可用工具

Word 工具(9 个)

工具 说明
word_get_selected_content 获取当前选中内容——文本、元素及元数据
word_get_visible_content 获取当前视口中可见的内容
word_insert_text 在光标处插入文本,支持格式(粗体、斜体、字体、颜色、样式)
word_append_text 在文档开头或末尾追加文本
word_replace_text 查找并替换文本(等同 Ctrl+H),支持大小写敏感和全词匹配
word_insert_image 插入 base64 编码的图片,支持尺寸和替代文字
word_insert_table 插入表格,指定行列数、数据和样式
word_insert_equation 插入 LaTeX 公式(默认为行内公式)
word_insert_toc 插入目录(可配置标题级别)

所有工具均需要 document_uri 参数来标识目标文档。

CLI 命令参考

office4ai-mcp <command>
命令 说明
serve 启动 MCP Server(未指定命令时的默认行为)
setup 生成证书并将 CA 安装到系统信任存储
cleanup 从信任存储移除 CA 并删除证书文件

服务器选项

可通过 CLI 参数或环境变量设置:

选项 环境变量 默认值 说明
--transport TRANSPORT stdio MCP 传输方式:stdiossestreamable-http
--host HOST 127.0.0.1 服务器绑定地址
--port PORT 8000 MCP HTTP 端口(用于 sse/streamable-http
--socketio-port SOCKETIO_PORT 3000 Socket.IO 端口(Add-In 连接)

证书位置

证书默认存储在 ~/.office4ai/certs/,可通过 OFFICE4AI_CERT_DIR 环境变量覆盖。

系统要求

  • Python 3.10+
  • macOS 或 Windows
  • 支持 Add-In 的 Microsoft Office(Word 桌面版或 Word Online)

开发

开发环境配置、常用命令、代码规范和贡献指南请参考 docs/CONTRIBUTING.md

许可证

MIT 许可证 - 详见 LICENSE

联系方式

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

office4ai-0.1.1.tar.gz (590.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

office4ai-0.1.1-py3-none-any.whl (110.7 kB view details)

Uploaded Python 3

File details

Details for the file office4ai-0.1.1.tar.gz.

File metadata

  • Download URL: office4ai-0.1.1.tar.gz
  • Upload date:
  • Size: 590.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for office4ai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 748d264607fd8169688c5aa34ce690c9520fd356e9957959526b7f4dd5878146
MD5 539d3a0ff91d4cdf0bc96888043b187c
BLAKE2b-256 b55f28364c04d88d2e70a8d11eb4571e62be68b4ebc3535b9263269d8422743d

See more details on using hashes here.

Provenance

The following attestation bundles were made for office4ai-0.1.1.tar.gz:

Publisher: publish.yml on JIAQIA/office4ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file office4ai-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: office4ai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 110.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for office4ai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9213227b28f7f91815a82184218b1b7f321eed57061bf6074dfbd36de6ad35c9
MD5 5e8e5f6f93cecc68e64b81300a6bdd44
BLAKE2b-256 475bcb87a4d846ecaa99d1e28c58a7804a9768aa02bad5c514bd21d1cbca04f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for office4ai-0.1.1-py3-none-any.whl:

Publisher: publish.yml on JIAQIA/office4ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page