Documentation

MCP Sheets for agents

How to connect an MCP client, what each tool does, and the patterns that let several agents share one workbook without stepping on each other.

MCP endpoint/mcp
On this page

Overview

MCP Sheets hosts shared spreadsheets, called workbooks, that AI agents read and write through the Model Context Protocol. People open the same workbook in the browser and see every change as it happens. Each workbook has sheets (tabs), each sheet is a grid with named, optionally typed columns, and every change is recorded with who made it, for whom, and why.

A good loop for an agent:

  1. list_workbooks or create_workbook, then check_in with your task. It returns a run id and a briefing: the sheets, columns, rules and recent changes, who else is working there and on what, and your connection’s previous run. Pass the run id as run on your edits.
  2. read with one or more queries. Rows come back as objects keyed by column name, with _row and _id.
  3. edit with every operation for one logical step in a single call, and a note explaining why.
  4. get_changes with since_revision to see what other agents and people did since your last call.

Connecting

The server speaks Streamable HTTP at /mcp. It accepts two kinds of credentials:

  • API key. Create one on the app's Agents page. Keys start with msk_ and are sent as Authorization: Bearer msk_… (an x-api-key header also works). Name the key after the tool that uses it, such as "Codex": the name appears in the changelog.
  • OAuth. Clients that support remote connectors (Claude.ai, ChatGPT) register themselves and send you through sign-in. No key to copy.

Either way the agent acts as you: it sees your workbooks and has your role in each one.

Claude CodeClaude Code

terminal
claude mcp add --transport http sheets "/mcp" \
  --header "Authorization: Bearer msk_your_key"

Then run /mcp inside Claude Code to check that the sheets server is connected.

CodexCodex CLI

Add the server to ~/.codex/config.toml and keep the key in an environment variable:

~/.codex/config.toml
[mcp_servers.sheets]
url = "/mcp"
bearer_token_env_var = "MCP_SHEET_KEY"
# edit is marked destructive; approve it once so agents don't stop to ask
default_tools_approval_mode = "approve"
shell
export MCP_SHEET_KEY=msk_your_key

CursorCursor and other clients

Most clients accept an mcpServers JSON block. For Cursor, put it in ~/.cursor/mcp.json (or .cursor/mcp.json in a project).

mcp.json
{
  "mcpServers": {
    "sheets": {
      "url": "/mcp",
      "headers": { "Authorization": "Bearer msk_your_key" }
    }
  }
}

ClaudeChatGPTClaude.ai and ChatGPT

Add MCP Sheets as a custom connector. The connector signs in with OAuth, so there is no key to manage.

  1. 1Open Settings → Connectors → Add custom connector.
  2. 2Paste /mcp as the server URL.
  3. 3Sign in to MCP Sheets and approve access.

One workbook only

Add ?workbook= with a workbook id (or its exact name) to the URL, for example /mcp?workbook=k3j2h1g0f9d8. The connection then works on that workbook alone: the tools drop their workbook argument, list_workbooks and create_workbook go away, and calls about any other workbook are refused, in code mode too. The Agents tab of a workbook gives you this URL, with a key that opens only that workbook. Quote it in a shell, since ? is special in zsh.

On its own the URL is a guard rail, not a permission: a key made for all workbooks, or a sign-in, still reaches all of your workbooks without ?workbook=.

One workspace only

Add ?workspace= with a workspace id to the URL, for example /mcp?workspace=Hq3XvT8mKc2LpZ9w. list_workbooks then shows only that workspace’s workbooks, create_workbook creates them there, and every other tool opens only workbooks in it. A key made for one workspace (Connect an agent on the Agents page offers “Everything in …” when you are in more than one workspace) does the same with any URL, and cannot be widened.

Concepts

TermMeaning
WorkbookA shared spreadsheet. Tools take its id (k3j2h1g0f9d8), its URL, or its exact name.
WorkspaceWhere workbooks live. Everyone in it can open and edit its workbooks; limits count per workspace. See Workspaces.
SheetA tab in a workbook, addressed by name (case-insensitive) or id.
ColumnHas a letter, an optional name and a type. Refer to it by name (Status) or letter (C); names win over letters.
RowAddressed by its 1-based number as shown in the UI, or by a stable id (r_k3j2h1g0f9) that survives inserts and deletes. Reads return both as _row and _id.
Key columnOptional per sheet. Identifies rows for upsert_rows and labels rows in the changelog.
RevisionA counter per workbook. Every edit that changes something becomes exactly one new revision. Reads and edits return the current one.

Column types

TypeAccepts
autoAnything. The default.
textStrings.
numberNumbers.
booleantrue or false.
dateISO dates (yyyy-mm-dd) or datetimes.
urlLinks. People see them as previews with title, favicon and image.
selectOne of the column's options.

Values

  • A cell holds a string, number or boolean. null or "" clears it.
  • There are no formulas. A string like =Tasks!B4 stores a live reference to another cell. It follows that cell when rows or columns move. Reads return it as { "ref": "=Tasks!B4", "value": … }. Start with ' to store a literal =.
  • Cells that contain URLs show as rich link previews in the browser.

Tools

Seven tools. The read tools carry the MCP read-only hint. Every result is JSON. Errors name the failing operation and list valid sheets and columns, so an agent can correct itself.

list_workbooks

The workbooks of your workspaces and the ones you were invited to as a guest (marked "guest": true), most recent activity first. Each says which workspace it is in. Also lists your workspaces with their limits.

arguments
{}
result
{
  "workbooks": [
    {
      "id": "k3j2h1g0f9d8",
      "name": "Sprint 14",
      "role": "owner",
      "revision": 128,
      "updated_at": "2026-10-15T09:12:44.000Z",
      "url": "/w/k3j2h1g0f9d8",
      "workspace": { "id": "Hq3XvT8mKc2LpZ9w", "name": "Dana’s workspace" },
      "created_by": "Dana"
    }
  ],
  "workspaces": [
    {
      "id": "Hq3XvT8mKc2LpZ9w",
      "name": "Dana’s workspace",
      "your_role": "owner",
      "workbooks_used": 3,
      "workbooks_limit": 15
    }
  ]
}

create_workbook

Creates a workbook in a workspace, and optionally its sheets, typed columns and first rows, in one call.

namestring
Workbook name.
sheetsarray
Up to 20 of { name, columns?, rows?, key_column? }. Default: one empty sheet.
notestring
Why it was created. Goes in the changelog.
workspacestring
Workspace id or exact name. Needed only when you are in more than one workspace and the connection is not limited to one.
arguments
{
  "name": "Sprint 14",
  "sheets": [
    {
      "name": "Tasks",
      "key_column": "ID",
      "columns": [
        "ID",
        "Title",
        { "name": "Status", "type": "select", "options": ["todo", "doing", "done"] },
        "Owner",
        { "name": "Points", "type": "number" },
        { "name": "Link", "type": "url" }
      ],
      "rows": [
        { "ID": "T-1", "Title": "Workbook schema in SQLite", "Status": "todo", "Points": 3 }
      ]
    }
  ],
  "note": "Planning board for sprint 14"
}

Returns { id, name, revision, url }.

check_in

Start work in a workbook: say what you are doing (task) and, if you like, a name for yourself. Returns a run id to pass on edit, wait_for_changes and run_code, and a briefing: the workbook as describe_workbook gives it, who else is working in it now and on what (here), and your connection’s previous run there (previous, with the revision it reached). A subagent passes its parent’s run id as parent. A run id works only on the connection that got it; if you lose it, check in again.

arguments
{ "workbook": "Sprint 14", "task": "Reconcile March invoices", "name": "researcher" }
result (trimmed)
{
  "run": "r_6v3kq2…",
  "name": "researcher",
  "task": "Reconcile March invoices",
  "here": [{ "name": "builder", "task": "Ship the login page", "via": "Claude Code", "last_seen": "…", "edits": 4 }],
  "previous": { "task": "Reconcile February invoices", "last_seen": "…", "edits": 31, "revision": 118 },
  "workbook": { "name": "Sprint 14", "revision": 128, "sheets": [ … ] }
}

describe_workbook

Sheets with their columns (letter, name, type, options), row counts, key columns, a few preview rows, the current revision and the five latest changes. Call it before working in an unfamiliar workbook.

arguments
{ "workbook": "Sprint 14", "preview_rows": 3 }
result (trimmed)
{
  "id": "k3j2h1g0f9d8",
  "name": "Sprint 14",
  "your_role": "owner",
  "revision": 128,
  "sheets": [
    {
      "name": "Tasks",
      "rows": 7,
      "key_column": "ID",
      "columns": [
        { "letter": "A", "name": "ID", "type": "auto" },
        { "letter": "C", "name": "Status", "type": "select", "options": ["todo", "doing", "done"] }
      ],
      "preview": [{ "_row": 1, "_id": "r_0c4k2m9x1a", "ID": "T-1", "Status": "done" }]
    }
  ],
  "recent_changes": [ … ]
}

read

Runs up to 20 queries in one call, for example a filtered view of one sheet plus a range from another. Each result carries the workbook revision. See Read queries for every option.

arguments
{
  "workbook": "Sprint 14",
  "queries": [
    {
      "sheet": "Tasks",
      "where": { "Status": "todo", "Points": { "gte": 2 } },
      "columns": ["ID", "Title", "Points"],
      "order_by": [{ "column": "Points", "desc": true }]
    },
    { "range": "Notes!A1:C10" }
  ]
}
result (first query)
{
  "sheet": "Tasks",
  "revision": 128,
  "total_rows": 2,
  "returned": 2,
  "rows": [
    { "_row": 5, "_id": "r_7hd02kq9zm", "ID": "T-5", "Title": "Link previews for URL cells", "Points": 3 },
    { "_row": 4, "_id": "r_p1x8c3n0va", "ID": "T-4", "Title": "Changelog export to Markdown", "Points": 2 }
  ]
}

edit

Applies a batch of operations atomically: all of them succeed as one revision, or nothing changes. Group everything for one logical step into one call.

workbookstring
Id, URL or exact name.
opsarray
1 to 200 operations, applied in order.
notestring
Why you are making the change. People and other agents read it in the changelog.
runstring
Your run id from check_in, so the edit shows under your task. The result has a hint when you left it out.
expected_revisionnumber
Fail with a conflict, listing the changes you missed, if the workbook has moved past this revision.
arguments
{
  "workbook": "Sprint 14",
  "run": "r_6v3k…",
  "note": "Key rotation was missing from the plan",
  "ops": [
    {
      "op": "append_rows",
      "sheet": "Tasks",
      "rows": [{ "ID": "T-7", "Title": "Rotate API keys", "Status": "todo", "Points": 2 }]
    },
    { "op": "update_rows", "sheet": "Tasks", "where": { "ID": "T-3" }, "set": { "Points": 5 } }
  ]
}
result
{
  "workbook": "k3j2h1g0f9d8",
  "revision": 127,
  "changed": true,
  "summary": "Tasks: appended row 7 {ID: \"T-7\", …}\nTasks: updated row 3 (\"T-3\") — Points: 3 → 5",
  "results": [
    { "op": "append_rows", "sheet": "Tasks", "rows": [{ "row": 7, "id": "r_v9t3b6w2qe" }] },
    { "op": "update_rows", "sheet": "Tasks", "matched": 1, "changed": 1,
      "rows": [{ "row": 3, "id": "r_m2k8f1s7dd" }] }
  ],
  "url": "/w/k3j2h1g0f9d8"
}

If the values were already as requested, the result has "changed": false and no revision is created.

get_changes

The changelog, oldest first. Pass the revision from your last read or edit to catch up on what others did.

workbookstring
Id, URL or exact name.
since_revisionnumber
Only changes after this revision. Without it you get the latest entries.
limitnumber
Default 20, max 200. has_more is set when more remain.
sheetstring
Only changes that touched this sheet.
include_cellsboolean
Add exact before → after values per cell (up to 100 per change).
arguments
{ "workbook": "Sprint 14", "since_revision": 126, "include_cells": true }
result
{
  "workbook": "k3j2h1g0f9d8",
  "revision": 128,
  "changes": [
    {
      "rev": 128,
      "at": "2026-10-15T09:12:44.000Z",
      "by": "builder [Codex] (agent via MCP, for Dana)",
      "note": "Claiming the next todo task",
      "summary": "Tasks: updated row 3 (\"T-3\") — Status: \"todo\" → \"doing\", Owner: ∅ → \"builder\"",
      "cells": [
        { "cell": "Tasks!C3", "column": "Status", "before": "todo", "after": "doing" },
        { "cell": "Tasks!D3", "column": "Owner", "before": null, "after": "builder" }
      ]
    }
  ]
}

wait_for_changes

Waits until a person or another agent changes the workbook, then returns those changes, so an agent can react instead of polling. Act on the result, then call it again with the revision it returned. It returns at once if there are already newer changes, and your own edits do not wake you. Each account can have 5 waits open at a time.

workbookstring
Id, URL or exact name.
since_revisionnumber
The last revision you saw.
timeout_snumber
Default 50, max 240. Then it returns timed_out: true with no changes: call it again.
sheetstring
Only wake for changes that touched this sheet.
include_ownboolean
Also wake for your own edits.
include_cellsboolean
Add exact before → after values per cell.

Many clients stop a tool call after 60 seconds, which is why the default wait is shorter. The result has the same shape as get_changes, plus timed_out.

run_code

Runs JavaScript you write in an isolated sandbox, for work that would otherwise take many calls: loops, aggregation, edits that depend on what you read. Details in Code mode.

arguments
{ "code": "const r = await sheets.read(\"Sprint 14\", { sheet: \"Tasks\", where: { Status: \"done\" } })\nreturn r.rows.reduce((sum, row) => sum + (row.Points ?? 0), 0)" }
result
{ "ok": true, "result": 5, "logs": [], "ms": 38 }

Edit operations

Each item in ops has an op field. sheet takes a sheet name or id; it is optional for set, set_range and clear when addresses include the sheet (Notes!A1).

opWhat it does
setsheet?, cellsWrite cells by A1 address, such as { "B4": "done" }. Grows the sheet as needed.
set_rangesheet?, start, valuesWrite a 2D block of rows starting at the top-left cell.
append_rowssheet, rows, create_missing_columns?Add rows at the bottom. Rows are objects keyed by column name, or arrays from column A.
insert_rowssheet, before, rows? | count?Insert rows before a row number. Rows below shift down.
update_rowssheet, rows? | where?, set, limit?Update listed rows, or rows matching a filter. With where and limit: 1 it is an atomic claim.
upsert_rowssheet, key?, rows, create_missing_columns?Update rows whose key matches and append the rest. key defaults to the sheet's key column.
delete_rowssheet, rows? | where?, limit?Delete rows. Rows below move up.
clearsheet?, rangeEmpty a range such as B2:D20, C:C or 5:5. Rows and columns stay.
add_sheetname, columns?, rows?, key_column?, position?Add a tab, optionally with typed columns and rows.
update_sheetsheet, name?, key_column?, position?Rename, set or clear (null) the key column, or move the tab.
delete_sheetsheetDelete a sheet.
add_columnssheet, columns, before?Add columns at the end, or before another column.
update_columnsheet, column, name?, type?, options?, width?Rename, change type (existing values are validated), set select options or width.
delete_columnssheet, columnsDelete columns.
set_rulesheet, name, description, code, on?, enabled?, position?Add a rule to a sheet, or update the one with that name. Owner only.
delete_rulesheet, nameDelete a rule. Owner only.

A column spec is either a name ("Owner", type auto) or { "name", "type"?, "options"?, "width"? }. Unknown column names in rows are an error unless create_missing_columns is true.

Read queries

Each query in read (and in sheets.read in code mode) accepts:

OptionDescription
sheetSheet name or id. Omit it only with search, to search every sheet.
rangeA1 range such as A1:D20 or Notes!A1:C10. Implies grid format.
columnsOnly return these columns (names or letters).
rowsOnly these rows (numbers or row ids).
whereFilter rows. All conditions must match. See operators below.
searchCase-insensitive text search across all cells.
changed_sinceOnly rows changed after this revision. Pair it with the revision from your last read.
order_by[{ "column": "Points", "desc": true }]. Sorts the result, not the sheet.
offsetPaging. Results include next_offset when more rows remain.
limitDefault 200, max 2000.
formatobjects (default): one { _row, _id, Column: value } per row, empty cells omitted. grid: 2D values. csv: compact text.

Filter operators

A plain value means equals, and null means empty: { "Status": "todo", "Owner": null }. For anything else use an operator object:

OperatorMatches
eqEqual to the value.
neNot equal to the value.
gt gte lt lteGreater / less than (numbers, or strings such as ISO dates).
containsCase-insensitive substring.
inAny of a list: { "in": ["todo", "doing"] }.
emptytrue for empty cells, false for cells with a value.
{ "where": { "Points": { "gte": 3 }, "Title": { "contains": "auth" }, "Owner": { "empty": true } } }

Coordinating agents

Each workbook is a single Cloudflare Durable Object, so edits are applied one at a time and every edit sees the result of the one before. Three patterns build on that.

Claim work atomically

Use update_rows with where and limit: 1. Two agents running this at the same moment never get the same row.

{
  "workbook": "Sprint 14",
  "run": "r_q8x2…",
  "note": "Claiming the next todo task",
  "ops": [{
    "op": "update_rows",
    "sheet": "Tasks",
    "where": { "Status": "todo", "Owner": null },
    "set": { "Status": "doing", "Owner": "builder" },
    "limit": 1
  }]
}

Check results[0].changed: 1 means you own the row listed in results[0].rows; 0 means nothing was left to claim.

Catch up instead of re-reading

Keep the revision from your last call. Later, ask for only what happened since:

{ "workbook": "Sprint 14", "since_revision": 126 }

Or read just the rows that changed, with { "sheet": "Tasks", "changed_since": 126 } as a read query.

Refuse to overwrite unseen changes

Pass expected_revision on edit. If someone wrote in the meantime, nothing is applied and the error lists what you missed:

Conflict: expected revision 126 but the workbook is at 128. Changes since then:
rev 127 by planner [Codex] (agent via MCP, for Dana): Tasks: appended row 7 {ID: "T-7", …}
rev 128 by builder [Codex] (agent via MCP, for Dana): Tasks: updated row 3 ("T-3") — Status: "todo" → "doing", …
Re-read what you need and retry.
Several agents on one connection each call check_in with their own task (and a name, such as planner or builder), and pass their run id on every edit. The changelog then shows which one did what, and why. A run id works only on the connection that got it, and a subagent passes its parent’s run id as parent.

Rules

A rule is a small JavaScript function attached to a sheet. It runs on every row an edit changes, before the write is saved, for agents and people alike. It can refuse the write with a message, or fill in cells on the same row. Use rules to make sure agents cannot skip a step, take over each other’s work, or mark something done with no evidence.

rule “done-needs-pr” on Tasks
if (row.Status === 'done' && !row.PR) return 'Add a PR link before marking a task done.'

An agent that tries to mark a task done without a PR gets back:

Refused by rule "done-needs-pr" (Tasks row 14): Add a PR link before marking a task done.
Nothing was applied (the batch is atomic).

Add one

Ask your own agent: “add a rule to Tasks that a task can’t be marked done without a PR link”. It writes the code and adds it with set_rule in an ordinary edit call. delete_rule removes one. A rule has a name (unique within its sheet), a one-sentence description, the code, the events it runs on and whether it is enabled. Updating a rule by name keeps the fields you leave out.

{
  "workbook": "Sprint 14",
  "note": "Tasks need evidence before they are done",
  "ops": [{
    "op": "set_rule",
    "sheet": "Tasks",
    "name": "done-needs-pr",
    "description": "A task marked done needs a PR link.",
    "code": "if (row.Status === 'done' && !row.PR) return 'Add a PR link before marking a task done.'"
  }]
}

Rule changes are in the changelog like any other edit, and describe_workbook lists each sheet’s rules with their code, so an agent can read what a sheet requires before it writes.

The function

code is the body of function (row, old, ctx). row is the row after the edit and old the row before. Both are objects keyed by column name, with null for an empty cell. For a new row every value of old is null; for a deleted row every value of row is null. Rows created blank (insert_rows with a count) run insert rules too, with ctx.changed empty. The code is modern JavaScript, run in a separate sandbox: no eval or Function, and globals and built-ins are frozen, so assigning to them throws and a rule cannot keep anything for the next write.

ctxValue
type"insert", "update" or "delete"
changedNames of the columns whose value changed.
sheetThe sheet’s name.
idThe row’s stable id (the _id that read returns).
numberThe row number.
actorWho is writing. kind is "user" or "agent". id is a stand-in id for that key or app together with the person using it, in this workbook (it looks like p_…): stable, and safe to store in a cell. Two people using the same app get different ids. userId is the same kind of id for the person, whether they edit themselves or their agent does. connection is an agent’s connection as its person named it (such as "Research bot"); agents cannot change it. Also name, user (the person an agent works for) and via (how the edit arrived, such as "mcp").
runWhat an agent said it is doing when it checked in: { id, name, task, parent }, or null. These are the agent’s own words: fine for agents working together (ctx.run?.name === 'researcher'), not to keep anyone out. For that, use actor.connection or actor.id.
noteThe edit’s note.
nowThe time of the edit, ISO 8601.
count(where)How many rows of the sheet match a filter (the same filters as read), counted after the edit, so the row itself is included. It counts the edit’s own changes and what rules set in the same edit, so a rule can count a column an earlier rule stamps.
actor.name is chosen by whoever writes: anyone can name their key after someone else. To tell writers apart, compare actor.id or actor.userId, and keep the name only for display.

What a rule returns

  • Nothing: the write goes ahead.
  • A string: the write is refused with that message. The whole edit is refused and nothing is saved.
  • { set: { Column: value } }: the write goes ahead, and those cells are written on the same row in the same revision, exactly as given (a leading = is text, not a formula). Name the column exactly, capitals included, and give the value as the column stores it: { set: { status: 'DONE' } } is a rule failure that says which.

A rule that throws, returns anything else, or cannot run also refuses the edit, and the message says the rules failed, not the edit. For example:

Rules on Tasks failed to run (they used more than their 100 ms of CPU time and were stopped). This is a problem in the rules, not in your edit.

The agent should tell its owner rather than retry.

When rules run

  • On insert and update by default. Deletes are opt-in: "on": ["insert", "update", "delete"].
  • Whenever a row changes, whatever column changed. Check ctx.changed to narrow a rule to one column.
  • In order (position moves a rule). A later rule sees what an earlier one set. Cells a rule sets do not trigger rules again.
  • On writes only. Adding a rule does not re-check the rows already in the sheet.
  • Before the write is applied, in a separate sandbox (a Cloudflare Dynamic Worker) with no network and a CPU time limit the platform enforces. The workbook is held while a write is checked, so nothing slips in between.

Who can change rules

Only the workbook’s owner, or an agent acting for the owner. The owner can also lock the rules in the app: a locked workbook refuses agents that try to change them, and only a person signed in to the app can.

On a sheet with rules, these need the same access as changing the rules (the owner, and a person if the rules are locked): deleting the sheet, renaming it, renaming or deleting its columns, and changing a column’s type or options. Each would change what the rules check. Editors can still read, add, change and delete rows, as far as the rules allow.

Cells of a sheet with rules take values, not references to other cells: writing =Scratch!A1 is refused, because a reference can change later without a rule running. Rules see any reference cells already there as their plain values. A rule cannot be added or enabled while the sheet has reference cells; the refusal lists them, and you replace them with their values first.

One edit can have at most 100,000 cells (rows times columns) checked against a sheet’s rules. A larger edit is refused: split it.

Not available: rules that run after a write and edit other rows or other sheets. A rule sees one row, plus ctx.count, and changes only that row.

Recipes

Each one is the whole code of a rule. Change the column names to match your sheet. A rule only sees the row being written, so some recipes do more than the obvious one-liner: rows inserted already in the forbidden state, or inserted blank and filled in later, and identities that are only names, are common ways around a rule. The line under a recipe says why it is as long as it is.

A field required before a status

Status is a choice column (todo, doing, done), so it can only hold exactly those values. Make PR a link column, so only a real URL counts.

if (row.Status === 'done' && !row.PR) return 'Add a PR link before marking a task done.'

Status moves in order

const next = { todo: ['doing'], doing: ['done', 'todo'], done: [] }
const from = old.Status || 'todo'
const to = row.Status || 'todo'
if (ctx.type === 'insert' && to !== 'todo') return 'New tasks start as todo.'
if (from !== to && !next[from].includes(to)) {
  return 'Status can go from ' + from + ' to ' + (next[from].join(' or ') || 'nowhere') + ', not to ' + to + '.'
}

Moving a todo straight to done is refused with “Status can go from todo to doing, not to done.”, so the agent knows what to do instead. A blank status counts as todo, and a new row must start as todo; otherwise a row could be created as done, or created blank and set to done.

A claim tied to the real identity

Needs columns Status, Owner, Owner id and Started at. Set "on": ["insert", "update", "delete"] on this one.

const mine = !old['Owner id'] || old['Owner id'] === ctx.actor.id
if (ctx.type === 'delete') return mine ? undefined : 'This task belongs to ' + old.Owner + '.'
const claiming = row.Status === 'doing' && old.Status !== 'doing'
const leaving = old.Status === 'doing' && row.Status !== 'doing'
if (!claiming && (ctx.changed.includes('Owner') || ctx.changed.includes('Owner id'))) {
  return 'Owner is set by moving a task to doing, not written directly.'
}
if (!mine && (claiming || leaving)) return 'This task belongs to ' + old.Owner + '.'
if (claiming) return { set: { Owner: ctx.actor.name, 'Owner id': ctx.actor.id, 'Started at': ctx.now } }
if (row.Status === 'todo') return { set: { Owner: null, 'Owner id': null } }

The rule stamps the name to show and the id to compare, because a name is chosen by the writer. Two agents of one person get different ids, so they cannot take over each other’s work. Owner and Owner id cannot be written directly: they are set only by moving a task to doing. Only the claimer can take it out of doing or delete it, and moving it back to todo clears both. Claim with update_rows, where and limit: 1 as in the example above and set only Status.

Only a person can approve

if (ctx.changed.includes('Approved') && ctx.actor.kind !== 'user') return 'Only a person can change Approved.'

A work-in-progress limit

if (row.Status === 'doing' && old.Status !== 'doing' && ctx.count({ Status: 'doing', 'Owner id': ctx.actor.id }) > 3) {
  return 'You already have 3 tasks in progress. Finish one first.'
}

Counts the id the claim recipe stamps, so no spelling of a name gets around it. Put it after the claim rule on the sheet (position), because it counts what that rule sets.

No duplicates

if (!ctx.changed.includes('Email')) return
const email = String(row.Email ?? '')
const clean = email.normalize('NFKC').replace(/[\s\u200b-\u200d\u2060\ufeff]/g, '').toLowerCase()
if (email !== clean) return 'Write the address as ' + clean + '.'
if (/[^\x20-\x7e]/.test(clean)) return 'Use plain ASCII letters in the address.'
if (clean && ctx.count({ Email: clean }) > 1) return clean + ' is already in the sheet.'

Addresses must be lowercase, without spaces or invisible characters, and plain ASCII: letters from other alphabets can look identical to Latin ones.

Finished rows cannot be deleted

Set "on": ["delete"] on this one.

if (ctx.type === 'delete' && old.Status === 'done') return 'Finished rows stay for the record.'

A finished row can still be reopened and then deleted. To prevent that, add "update" to on and refuse changes to a row whose old.Status is done.

A computed column

return { set: { Total: (row.Qty || 0) * (row.Price || 0) } }

Code mode

run_code runs your JavaScript in a fresh Cloudflare Dynamic Worker. The sandbox has no network access, a CPU budget of about 2 seconds, and one capability: the sheets API, scoped to the user the agent acts for. The code is the body of an async function.

available inside run_code
sheets.list()
sheets.describe(workbook, { preview_rows }?)
sheets.read(workbook, query)              // one query → one result
sheets.read(workbook, [query, query])     // an array → an array of results
sheets.edit(workbook, ops, { note, run, expected_revision }?)
sheets.changes(workbook, { since_revision, limit, sheet, include_cells }?)
console.log(…)                            // captured and returned in "logs"

Queries and operations are the same objects the read and edit tools take. Return any JSON-serializable value.

example
const r = await sheets.read("Sprint 14", { sheet: "Tasks", where: { Status: "todo" } })
const ops = r.rows.map((row) => ({
  op: "update_rows",
  sheet: "Tasks",
  rows: [row._id],
  set: { Priority: row.Points > 3 ? "high" : "low" },
}))
console.log(`prioritizing ${ops.length} tasks`)
return await sheets.edit("Sprint 14", ops, { note: "Prioritized todo tasks by points" })

The tool returns { ok: true, result, logs, ms }, or { ok: false, error, logs, ms } if the code threw. Edits made from code mode appear in the changelog as agent via code mode.

Changelog

Every edit, from an agent or a person, becomes one changelog entry with a revision number, a timestamp, who made it, the optional note, and a readable summary. Agents read it with get_changes. People see it live in the Activity panel.

Who

ActorShown as
Person in the browserDana (web app)
Agent with an API key or OAuthCodex (agent via MCP, for Dana), where "Codex" is the key name or OAuth client name
Agent that checked inbuilder [Codex, task: Ship the login page] (agent via MCP, for Dana)

Summary lines

One line per change, with ∅ for an empty cell. Large changes are summarized by count.

Tasks: updated row 3 ("T-3") — Status: "todo" → "doing", Owner: ∅ → "builder"
Tasks: appended row 7 {ID: "T-7", Title: "Rotate API keys", Status: "todo", Points: 2}
Tasks!E5 (Points): 2 → 3
Tasks: updated 12 rows matching {"Status":"todo"} (set Sprint="15")
Tasks: deleted row 6 ("T-6")

Markdown export

The Activity panel exports the log as Markdown, ready to paste into any AI chat as context:

changelog.md
# Changelog: Sprint 14

Workbook /w/k3j2h1g0f9d8 · current revision 128

## rev 128 · 2026-10-15 09:12:44Z · builder [Codex] (agent via MCP, for Dana)
> Claiming the next todo task
- Tasks: updated row 3 ("T-3") — Status: "todo" → "doing", Owner: ∅ → "builder"

Sharing

  • Every workbook lives in a workspace, and everyone in that workspace can open and edit it. To share one workbook with someone outside the workspace, invite them by email as a guest: editor or viewer. An invite to someone without an account applies when they sign up and confirm their email.
  • Every workbook is private: only the workspace and the guests invited to it can open it, and their agents. There are no public links.
  • Removing someone takes effect at once, even for people who have it open.
  • Agents get the role of the person they act for. A viewer's agent can read but not edit.
  • The person who created a workbook, and the workspace’s owners and admins, delete it from the ⋯ menu next to it in the workbook list. Guests leave one the same way. Keys made for that workbook stop working.
  • Each workspace holds 15 workbooks and room for 3 people (invitations not yet accepted count). list_workbooks reports each workspace’s usage.

Workspaces

Everyone gets a workspace when they sign up, named after them, and can own up to 3. A workspace holds workbooks and the people who work on them: everyone in it can open and edit all of its workbooks, and so can the agents they connect. Owners and admins invite people by email from the workspace’s People page; the invitation lasts 7 days, and the person accepts it signed in with that address, confirmed. Owners and admins also change roles, remove people and manage every workbook in it; only owners can delete the workspace, which deletes its workbooks. People outside the workspace can still be invited to a single workbook as guests. To keep an agent to one workspace, connect it with a key or URL for that workspace.

Limits

LimitValue
Workbooks per workspace15
People per workspace3, invitations not yet accepted included
Workspaces one person can own3
Agent keys per account25
Agents waiting for changes at once, per account5
Sheets per workbook50
Columns per sheet200
Rows per workbook (all sheets)100,000
Filled cells per workbook300,000
Text in a workbook’s cells10 MB (then only edits that shrink it)
Characters per cell10,000
Note per edit1,000 characters
Operations per edit call200
Cells written per edit call (clearing and deleting don’t count)20,000
Request size4 MB
What one read, get_changes or run_code call returns400,000 characters (about 100k tokens)
Queries per read call20
Rows per read query2,000 (default 200)
Changes per get_changes call200 (default 20); each before/after value cut at 2,000 characters
Rules per sheet20 (4,000 characters of code each, description up to 300)
Cells one edit can have checked by rules100,000 (rows times columns)
Code modeAbout 2 s CPU, 30 s in all, no network

Hitting a size limit fails the whole edit with a message that says which one. Split large imports into several edit calls.

There are also fair-use limits on how fast an account can call. Going over returns HTTP 429 with Retry-After: wait and retry. Batching keeps you well under them: one edit call can carry many operations, and one read call many queries.

Ready to connect an agent?

Create a workbook in the app, then add the MCP URL to your client.

Open app