mcpField
A
Arezzo

Arezzo

本地服务
github.com记忆与知识026 周前更新

关于 Arezzo

Arezzo 是用于 Google Docs API 操作的确定性编译器,面向需要通过 Agent 编辑文档的开发者。它将语义编辑指令转换为正确的 batchUpdate 请求,并处理 UTF-16 索引和级联偏移。

主要功能

  1. 01语义操作编译为 batchUpdate 请求
  2. 02按标题、命名范围或书签定位
  3. 03处理 UTF-16 索引计算
  4. 04跟踪多次编辑造成的偏移
  5. 05支持文本、表格和格式操作

适用场景

  1. 01按标题插入或替换文档内容
  2. 02在批量修改中避免索引错位
  3. 03通过 Agent 编辑表格或文本样式
  4. 04读取文档结构后执行定位编辑

MCP 相关

Arezzo 通过 MCP 提供读取文档结构与编辑文档的工具,并由服务调用 Google Docs API。编辑工具将语义操作编译为 batchUpdate 请求。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"arezzo": {
"command": "uvx",
"args": [
"arezzo"
],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "<GOOGLE_APPLICATION_CREDENTIALS>"
}
}
}
}
启动命令uvx arezzo
需要配置的环境变量
GOOGLE_APPLICATION_CREDENTIALS密钥Path to the Google OAuth2 client credentials JSON (Desktop application type, Docs API enabled). Required — the Google Docs API does not support anonymous access. Run 'arezzo init' to walk through OAuth setup and write platform config.

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
pypiarezzo0.1.1

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

Arezzo

用于 Google Docs API 操作的确定性编译器。

你无法通过自行构造 batchUpdate 请求来安全地修改 Google 文档。该 API 使用 UTF-16 代码单元,并会导致索引级联偏移——在位置 50 插入 10 个字符后,批次中所有后续索引都会出错。只要有一次计算错误,文档就会在没有任何错误提示的情况下被悄然损坏。

Arezzo 会将语义意图编译为正确的请求序列。告诉它你想做什么;索引计算交给它处理。

面向 AI Agent(MCP 工具)

Arezzo 通过 Model Context Protocol 提供三个工具:

read_document(document_id)
  → Returns the document's structural map: headings with hierarchy,
    named ranges, tables, section boundaries. Call this before editing
    so you know what addresses are available.

edit_document(document_id, operations)
  → Compiles operations into correct batchUpdate requests and executes
    them. Handles UTF-16 arithmetic, cascading index shifts, and
    OT-compatible request ordering. Supported operations: insert/delete/
    replace text, formatting (bold, italic, headings, links), tables,
    lists, images, headers/footers, footnotes, named ranges.

validate_operations(document_id, operations)
  → Compile-only dry run. Returns the compiled requests for inspection
    without executing. Use before edit_document when uncertain.
操作格式
{
  "type": "insert_text",
  "address": {"heading": "Revenue Analysis"},
  "params": {"text": "New paragraph content.\n"}
}

地址模式:

  • {"heading": "Section Name"} — 按标题文本定位
  • {"named_range": "range_name"} — 按命名范围定位
  • {"bookmark": "bookmark_id"} — 按书签 ID 定位
  • {"start": true} — 文档开头
  • {"end": true} — 文档结尾
  • {"index": 42} — 绝对 UTF-16 索引

操作类型: insert_text、delete_content、replace_all_text、replace_section、 update_text_style、update_paragraph_style、insert_bullet_list、 insert_table、insert_table_row、insert_table_column、 delete_table_row、delete_table_column、insert_image、 create_header、create_footer、create_footnote、 create_named_range、replace_named_range_content、insert_page_break

推荐工作流
read_document → edit_document → (if structural changes) read_document → edit_document

编辑前务必先读取。插入结构元素(表格、页眉、页脚)后,再次读取以获取新元素的索引,然后再向其中添加内容。

安装

pip install arezzo
arezzo init

arezzo init 会引导你完成 Google OAuth 设置,并为你的 MCP 客户端写入平台配置文件。

设置

前提条件: 一个已启用 Google Docs API 的 Google Cloud 项目,以及一个 OAuth 2.0 客户端 ID(桌面应用类型)。

arezzo init

向导会:

  1. 将你的 credentials.json 复制到 ~/.config/arezzo/
  2. 运行 OAuth 授权流程(浏览器会打开一次)
  3. 为 Claude Code、Cursor 和 VS Code 生成配置文件

对于 Claude Desktop,arezzo init 会打印配置块,供你手动添加。

平台配置

运行 arezzo init 后,配置文件会写入你的项目目录:

Claude Code / Cursor(.mcp.json):

{
  "mcpServers": {
    "arezzo": {
      "command": "arezzo"
    }
  }
}

VS Code(.vscode/mcp.json):

{
  "servers": {
    "arezzo": {
      "type": "stdio",
      "command": "arezzo"
    }
  }
}

Claude Desktop(macOS 上的 ~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "arezzo": {
      "command": "arezzo"
    }
  }
}

Arezzo 的存在意义

Google Docs 的 batchUpdate API 使用 UTF-16 代码单元和绝对索引位置。每次插入或删除字符,都会使所有后续索引发生偏移。在包含多项修改的批次中,每个请求的索引都必须考虑同一批次中之前每个请求的影响。

要正确处理这些操作,需要:

  • 计算 UTF-16 长度(不能用 Python 的 len()——代理对的计数方式不同)
  • 对同类型修改按逆序执行(从后向前删除)
  • 分两阶段编译(先修改内容,再修改格式)
  • 跟踪多步操作中的级联偏移

Arezzo 会以确定性的方式处理这些操作。相同输入总会产生相同输出。不需要推理,不需要猜测,也不会出现“通常能用”的情况。

架构

semantic operation
    ↓
arezzo.parser.parse_document()    — build heading/range/bookmark indexes
    ↓
arezzo.address.resolve_address()  — semantic reference → document index
    ↓
arezzo.operations.*               — operation → batchUpdate request(s)
    ↓
arezzo.index.sort_requests()      — OT-compatible mutation ordering
    ↓
correct batchUpdate request sequence

引擎是一个纯函数:compile_operations(doc, operations) → requests。确定性执行,无副作用,不调用 API。

MCP 服务(arezzo.server)将引擎与 Google Docs API I/O 以及行为指导字段(next_step、present_to_user、document_reality)封装在一起。

许可证

MIT — Convergent Methods, LLC

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。