Skip to main content

Arezzo

Deterministic compiler for Google Docs API operations.

You cannot safely modify a Google Doc by constructing batchUpdate requests yourself. The API uses UTF-16 code units with cascading index shifts — insert 10 characters at position 50, and every subsequent index in your batch is now wrong. A single miscalculation silently corrupts the document with no error message.

Arezzo compiles semantic intent into a correct request sequence. Tell it what you want to do; it handles the index arithmetic.

For AI agents (MCP tools)

Arezzo exposes three tools via the 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.

Operation format

{
  "type": "insert_text",
  "address": {"heading": "Revenue Analysis"},
  "params": {"text": "New paragraph content.\n"}
}

Address modes:

  • {"heading": "Section Name"} — by heading text
  • {"named_range": "range_name"} — by named range
  • {"bookmark": "bookmark_id"} — by bookmark ID
  • {"start": true} — document start
  • {"end": true} — document end
  • {"index": 42} — absolute UTF-16 index

Operation types: 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

Always read before editing. After inserting structural elements (tables, headers, footers), read again to get the new element indices before adding content inside them.

Installation

pip install arezzo
arezzo init

arezzo init walks through Google OAuth setup and writes platform config files for your MCP client.

Setup

Prerequisites: A Google Cloud project with the Google Docs API enabled and an OAuth 2.0 client ID (Desktop application type).

arezzo init

The wizard:

  1. Copies your credentials.json to ~/.config/arezzo/
  2. Runs the OAuth consent flow (browser opens once)
  3. Generates config files for Claude Code, Cursor, and VS Code

For Claude Desktop, arezzo init prints the config block to add manually.

Platform configs

After arezzo init, config files are written to your project directory:

Claude Code / Cursor (.mcp.json):

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

VS Code (.vscode/mcp.json):

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

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

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

Why Arezzo exists

The Google Docs batchUpdate API operates on UTF-16 code units with absolute index positions. Every character insertion or deletion shifts all subsequent indices. In a batch with multiple mutations, each request's indices must account for the effect of every prior request in the same batch.

Getting this right requires:

  • UTF-16 length calculation (not Python len() — surrogate pairs count differently)
  • Reverse-order execution for same-type mutations (delete from end to start)
  • Two-phase compilation (content mutations before format mutations)
  • Cascading offset tracking across multi-step operations

Arezzo handles this deterministically. The same input always produces the same output. No reasoning, no guessing, no "usually works."

Architecture

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

The engine is a pure function: compile_operations(doc, operations) → requests. Deterministic. No side effects. No API calls.

The MCP server (arezzo.server) wraps the engine with Google Docs API I/O and behavioral guidance fields (next_step, present_to_user, document_reality).

License

MIT — Convergent Methods, LLC

Metadata

Release files for arezzo 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for arezzo 0.1.1
File Size Uploaded Provenance
arezzo-0.1.1.tar.gz 29.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for arezzo 0.1.1
File Interpreter ABI Platform
arezzo-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 68.0 kB

Release files / arezzo-0.1.1.tar.gz

Download URL arezzo-0.1.1.tar.gz
Size 29.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d524d10a627789f00542d948eb72c3feae07067684cd3f72e4ea418ad19cbcfe
BLAKE2b-256 checksum
How to use checksums
32114e2bd588f1ada33aec8137507773b4f91e6ba1c919d300e339034df7b210
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / arezzo-0.1.1-py3-none-any.whl

Download URL arezzo-0.1.1-py3-none-any.whl
Size 38.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
208f4c554b243124e911ca2c046410d040cd0317d4157acd4faec95e609b500d
BLAKE2b-256 checksum
How to use checksums
229ce4209628eb462f1cbdc69724ae95c0309f138c1082cd8a348783086c53b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for arezzo 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page