Cotton code
2522 lines · 285.2 KB · RustRaw
//! The MCP tool catalogue — every tool an assistant can see, in declaration order.//!//! Adding a tool here without a handler, or a handler without an entry here, is caught both ways by the catalogue-handler totality tests; every name, title, description and parameter is swept by `mcp::language`.//!//! The tool catalogue as DATA — ORDINARY SOURCE, hand-maintained here since//! step 5i; nothing generates it. Every `ToolDef` was READ FROM//! `packages/server/src/mcp/protocol.ts`, in its declaration order.//!//! The descriptions are the ASSISTANT-FACING API, which is why they were//! carried over byte for byte rather than paraphrased: they are the sentences a model reads to//! choose between its tools, and a port that drifted by a character//! would change what an assistant does with somebody's database. Argument//! VALIDATION is not here — `validateX` is hand-written control flow with its//! own refusal sentences, and it is ported per tool group.//!//! The count is an ASSERTION and not a sentence here — `tool_surface_tests.rs` holds//! `TOOLS.len()` and prints what moved, which is the one number that cannot go stale.use crate::mcp::protocol::{Annotations, McpScope, ToolDef};/// The MCP revision this server implements (streamable HTTP, tools, prompts).pub const PROTOCOL_VERSION: &str = "2025-06-18";/// `serverInfo`, as `initialize` answers it.pub const SERVER_NAME: &str = "cotton";pub const SERVER_TITLE: &str = "Cotton";pub const SERVER_VERSION: &str = "1.0.0";pub static TOOLS: &[ToolDef] = &[    ToolDef {        name: "archive_database", title: "Archive a database", description: "Stop serving a database you own and retain its file and bytes in the archive. Personal cannot be archived. Optional to sets the archive root for this act.",        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: true, idempotent_hint: Some(true), open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string"},"to":{"type":"string"}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: true,    },    ToolDef {        name: "list_databases", title: "List databases", description: "List your live databases. With includeArchived, also list retained databases and their archive facts.",        scope: McpScope::Read,        annotations: Annotations { read_only_hint: true, destructive_hint: false, idempotent_hint: Some(true), open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"includeArchived":{"type":"boolean"}},"required":[],"additionalProperties":false}"#,        outside_write_lock: true,    },    ToolDef {        name: "parse_phrase",        title: "Parse a phrase",        description: "Extract English dates, times, supplied project and person names, and an initial imperative verb. Pure: now is RFC3339 with an offset and time_zone is an IANA zone. Each understood field is null or {text, span: {start,end}, candidates: [string,...]}, ranked best first. Spans are half-open UTF-8 byte offsets. Dates are YYYY-MM-DD, times HH:MM; unqualified hours retain both AM/PM candidates, preferring waking hours 07–21. remainder contains unknown text; remainder_spans preserves its original segments. Does not edit records.",        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"text":{"type":"string"},"now":{"type":"string"},"time_zone":{"type":"string"},"projects":{"type":"array","items":{"type":"string"}},"people":{"type":"array","items":{"type":"string"}}},"required":["text","now","time_zone","projects","people"],"additionalProperties":false}"#,        outside_write_lock: true,    },    ToolDef {        name: "search_records",        title: "Search records",        description: r#"Search also matches the title, text and longtext columns of every defined table in the generic records store, including imported and orphaned tables. Each hit carries table, id, title and snippet as well as its existing kind fields. Generic table hits rank title matches before text matches, within each table; follow up with get_record_by_table. An archived record is found too, marked `archived: true` and ranked after every live hit of its kind; a record in the bin is never found. An absent or empty kinds filter includes every table. Ranked full-text search across EVERYTHING in the user's database — todos, calendar events, notes, journal pages, people, saved locations, meetings, filed documents (including inside their extracted pages), saved articles (their titles and their kept text), memory entries, chat messages, chats by name, archived emails, email conversations by subject or participant, past assistant sessions, money transactions and goals. Use this first when you need something the user mentioned but did not give you an id for; it runs the same engine as the owner's own in-app search. Hits are ranked best-first WITHIN each kind (never across kinds) and carry a snippet around the match; `totals` says how many each kind holds beyond the limit. Follow up by kind: get_record expands most kinds including a transaction; a `message` hit carries threadId + sentAt for read_message_thread (open the thread anchored at that message); a `thread` hit is a whole chat (read_message_thread); an `email` hit carries threadId for read_email_thread and an `email_thread` hit is a whole email conversation; a `document` hit's `page` names the matched page (get_document for the profile); a `session` is a past assistant session (list_sessions); a `page` is a saved article, matched on its title and on the text Cotton kept of it — get_record_by_table with table `page` opens it, text included. A `photo` or a `video` hit matches on its caption and its description — get_photo and get_video expand one, and get_photo_bytes hands you the picture itself. A `connection` hit is something Cotton reads from outside — a WhatsApp number, a Google account, a mailbox — matched on its name, the number or address it reaches, and its kind (get_record_by_table with table `connection` opens it). A meeting matches on its title and summary only, so a phrase somebody merely SAID is not findable here — open the transcript with get_transcript. `mode` adds a second lane: the default 'text' finds the words the user actually typed, while 'meaning' finds records that are ABOUT what you asked even when they share no word with it, and 'both' returns the exact hits first and the related ones after, still grouped within each kind. A hit found the second way carries `matchedBy: "meaning"` and its `detail` is the start of the passage that matched, not a quotation of your query. Searching by meaning is OFF unless the user turned it on, and it only covers notes, journal pages, messages, emails, document pages, meeting summaries, memory entries and the summaries kept about people — never todos, events, places, money or goals. When it is unavailable the call still succeeds: `records` holds whatever the text lane found and `meaning` says in one line why the second lane did not answer. Do not retry on that; tell the user instead."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"query":{"type":"string","description":"Text to look for in titles, bodies and names."},"kinds":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_]*$"},"description":"Restrict to these built-in kinds or user table ids. Omit to search everything."},"limit":{"type":"integer","minimum":1,"maximum":50,"description":"Maximum records PER KIND to return (default 20)."},"mode":{"type":"string","enum":["text","meaning","both"],"description":"Which lanes answer. 'text' (the default) matches the words the user wrote. 'meaning' finds records that are about what you asked even when they use none of your words — reach for it when a plain search came back empty and you know the user has written about this. 'both' runs the two and returns exact hits first. The meaning lane is off unless the user turned it on, and it covers only notes, journal pages, messages, emails, document pages, meeting summaries, memory entries and the summaries kept about people."}},"required":["query"],"additionalProperties":false}"#,        outside_write_lock: true,    },    ToolDef {        name: "get_record",        title: "Get one record",        description: r#"Fetch a single record in full by its kind and id, or give table and id for its generic engine view (with today for day-dependent views), including fields search omits (notes body, event location, a person's details). `transaction` answers one actual or expected Money row; a monthly occurrence id returned by list_money_transactions opens that occurrence of its stored row. `meeting` returns the summary side only; its transcript is get_transcript's job. A `note`, `journal` or `thought` also carries `attachments` — the photos, videos and documents it shows, in the record's own order, each with its size, the object key the app draws it from and the call that hands you the thing itself (`bytes`). TWO captions, never collapsed: `caption` is the note's own words for that attachment (null where it gave none) and `recordCaption` is what the picture or document already calls itself — send `caption` straight back to update_note and nothing the owner wrote is lost. One whose record has since been removed is still listed, with `missing: true`: the note said the picture was there. With table, the answer also carries `page`: the record page in one read — what it opens on, its head lines, its fact slips, every list that links to it with its count and newest few, its views and its acts."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"table":{"type":"string","description":"Read a generic table engine view; use table or kind."},"view":{"type":"string","description":"With table: the id of one of the record's views (from its page's views) for the page to stand on; absent, Overview."},"today":{"type":"string","description":"The caller calendar day, YYYY-MM-DD. Money engine views default from a known workspace timezone; send this when the workspace has no known timezone."},"kind":{"type":"string","enum":["todo","event","note","journal","person","document","memory","transaction"]},"id":{"type":"string","description":"The record UUID, or a monthly Money occurrence identity returned by its runway read."},"from":{"type":"string","format":"date","description":"For a monthly Money runway view, the first calendar day of its window, YYYY-MM-DD; defaults to the reader day."},"to":{"type":"string","format":"date","description":"For a monthly Money runway view, the last calendar day of its window, inclusive, YYYY-MM-DD; defaults to the view's horizon in calendar months from the first day (three where its definition names none), exclusive."}},"required":["id"],"anyOf":[{"required":["table"]},{"required":["kind"]}],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_summary",        title: "Update a summary",        description: r#"Write the summary a person reads at the top of a record — what this person, chat or email conversation is about, in a paragraph. Use it when you have just read enough of one to say something useful the user would otherwise have to reconstruct. At most 1200 characters. It is stamped with YOUR name, so the user always sees who wrote it and when, and the record's page shows how much has arrived since. Sending the same paragraph back unchanged does nothing at all — the stamp holds, so the "since" count keeps measuring from when the words were actually written. Pass null to clear it. A project's summary is update_project's `description`; a filed document's is written by Cotton's own document pipeline and is not yours to change."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"kind":{"type":"string","enum":["person","thread","email_thread"],"description":"person (from search_records or get_record), thread (a chat, from list_message_threads), or email_thread (from list_email_threads)."},"id":{"type":"string","description":"The record's id."},"summary":{"type":["string","null"],"maxLength":1200,"description":"The paragraph, in the user's own register — plain, specific, no preamble. null clears it."}},"required":["kind","id","summary"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "today_agenda",        title: "Today's agenda",        description: r#"What is left of the user's day: todos due today or overdue, plus today's calendar events in time order. The fastest way to answer 'what do I have on' without composing a search."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"timezone":{"type":"string","description":"IANA zone deciding where 'today' falls (e.g. Asia/Kolkata). Omit it and the user's own zone is used — pass one only to ask about a different place."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "create_todo",        title: "Create a todo",        description: r#"Add a todo to the user's default list. To sort it with others, put it in a group (create_group / update_group, table todo). Give a due only when the user named a day or a time; a todo with no due date is filed, not scheduled. A todo can be due on a DAY (dueDate alone — 'a day is enough') or at a time on that day (dueDate + dueTime); dueAt is the raw-instant alternative. For a REPEATING todo ('payment on the 2nd of every month') pass rrule — a due is then required and is the first occurrence; later occurrences appear as their time comes."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"title":{"type":"string"},"dueDate":{"type":"string","description":"The day it is due, YYYY-MM-DD in the user's zone. On its own this is a date-only todo; add dueTime for an hour. Not with dueAt."},"dueTime":{"type":"string","description":"The clock time on dueDate, HH:mm (24-hour) in the user's zone. Needs dueDate."},"timezone":{"type":"string","description":"IANA zone dueDate/dueTime are read in (e.g. Asia/Kolkata). Omit it and the user's own zone is used."},"dueAt":{"type":"string","description":"ISO 8601 instant, when you already hold the exact moment. Prefer dueDate/dueTime. Not with dueDate."},"notes":{"type":"string"},"rrule":{"type":"string","description":"iCal RRULE to repeat the todo (FREQ=DAILY/WEEKLY/MONTHLY/YEARLY, with INTERVAL/COUNT/UNTIL/BYDAY). Monthly/yearly recur on dueAt's day; months without it are skipped."}},"required":["title"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "complete_todo",        title: "Complete a todo",        description: r#"Mark a todo done by id. On a repeating todo, the earlier occurrences still open are marked missed, never done. Find the id with search_records first; never guess one."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string"}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_todos",        title: "List todos",        description: r#"Browse the user's todos directly — each with the projects it is filed under — including undated ones, which today_agenda never shows (an undated todo is filed, not scheduled). Defaults to every open todo; filter by status, a due window, one project's slug, or unfiled for the todos in no project. The list PAGES: when more is true the answer carries nextCursor, and passing it back as cursor with the same filters reads the next page — walk it to the end rather than reporting the first page as the whole list. Use search_records instead when you are looking for a todo by its words."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"status":{"type":"string","enum":["open","done","dropped","missed","all"],"description":"Which todos to list (default open). 'missed' is an earlier occurrence of a repeating todo left open when a later one was done."},"dueAfter":{"type":"string","description":"Only todos due at or after this ISO 8601 timestamp."},"dueBefore":{"type":"string","description":"Only todos due before this ISO 8601 timestamp."},"includeUndated":{"type":"boolean","description":"Include todos with no due date (default true). A due window filters them out unless this is set explicitly."},"project":{"type":"string","description":"Only todos filed under this project's slug; 'none' means the todos in no project."},"unfiled":{"type":"boolean","description":"Only todos in no project — the same question as project 'none'. Not with a project slug."},"cursor":{"type":"string","description":"nextCursor from the previous page, passed back unchanged with the same filters. Omit it for the first page."},"limit":{"type":"integer","minimum":1,"maximum":5000}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_todo",        title: "Update a todo",        description: r#"Change an existing todo by id: retitle it, rewrite its notes, move its day, set or drop its time, clear its due, set or clear its high priority, snooze it, or set its status — 'dropped' cancels a todo without pretending it got done, 'open' reopens one. The due is a DAY plus an optional TIME: dueDate moves the day and keeps the hour, dueTime sets the hour and keeps the day, dueTime null keeps the day and drops the hour, dueDate null clears the due. Rescheduling is done here, never complete-and-recreate. Editing one occurrence of a repeating todo changes that occurrence only. Several todos at once: update_todos. Find the id with list_todos or search_records first; never guess one."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The todo's uuid."},"title":{"type":"string"},"notes":{"type":["string","null"],"description":"Replacement notes; null clears them."},"dueDate":{"type":["string","null"],"description":"The day, YYYY-MM-DD in the user's zone. Moves the day and keeps any hour; null clears the whole due (filed, not scheduled). Not with dueAt."},"dueTime":{"type":["string","null"],"description":"The clock time on the todo's day, HH:mm (24-hour) in the user's zone. Sets the hour and keeps the day; null KEEPS the day and drops the hour — a date-only todo. Not with dueAt."},"timezone":{"type":"string","description":"IANA zone dueDate/dueTime are read in (e.g. Asia/Kolkata). Omit it and the user's own zone is used."},"dueAt":{"type":["string","null"],"description":"The exact due instant as ISO 8601, when you already hold it; null clears the due. Prefer dueDate/dueTime. Not with dueDate/dueTime."},"priority":{"type":"string","enum":["high","none"],"description":"Set or clear the todo's high-priority flag."},"snoozedUntil":{"type":["string","null"],"description":"Hide the todo until this ISO 8601 timestamp; null un-snoozes it."},"status":{"type":"string","enum":["open","done","dropped"],"description":"'open' reopens, 'done' completes (same as complete_todo, and marks a repeating todo's earlier open occurrences missed), 'dropped' cancels without pretending it got done."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_todos",        title: "Update several todos",        description: r#"Change several todos by id with ONE patch — the same fields update_todo takes, minus title (a title names one todo). Reschedule a batch onto a day, drop the time from every one of them (dueTime null keeps each todo's own day), clear their dues, set their priority, snooze them, or complete or drop them together. Each todo resolves the due change against its own current day. A todo whose id is not found is reported under missing and the rest still change; nothing errors, so a re-run is safe. To put a batch into a project use link_to_project, which already takes many records. Find ids with list_todos or search_records first; never guess one."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"ids":{"type":"array","minItems":1,"maxItems":100,"items":{"type":"string","description":"A todo's uuid."},"description":"The todos to change — up to 100 per call."},"notes":{"type":["string","null"],"description":"Replacement notes on every one; null clears them."},"dueDate":{"type":["string","null"],"description":"The day, YYYY-MM-DD in the user's zone. Moves the day and keeps any hour; null clears the whole due (filed, not scheduled). Not with dueAt."},"dueTime":{"type":["string","null"],"description":"The clock time on the todo's day, HH:mm (24-hour) in the user's zone. Sets the hour and keeps the day; null KEEPS the day and drops the hour — a date-only todo. Not with dueAt."},"timezone":{"type":"string","description":"IANA zone dueDate/dueTime are read in (e.g. Asia/Kolkata). Omit it and the user's own zone is used."},"dueAt":{"type":["string","null"],"description":"The exact due instant as ISO 8601, when you already hold it; null clears the due. Prefer dueDate/dueTime. Not with dueDate/dueTime."},"priority":{"type":"string","enum":["high","none"],"description":"Set or clear the high-priority flag on every one."},"snoozedUntil":{"type":["string","null"],"description":"Hide them all until this ISO 8601 timestamp; null un-snoozes them."},"status":{"type":"string","enum":["open","done","dropped"],"description":"'open' reopens, 'done' completes, 'dropped' cancels without pretending they got done."}},"required":["ids"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "create_note",        title: "Create a note",        description: r#"Write a note into the user's default notebook. For a dated diary entry use append_journal instead — the journal is one page per day, not a pile of notes. The body is Markdown by convention, and `attachments` names the photos, videos and documents the note shows — each one a record that already exists (list_photos, list_videos, list_documents), never a copy, in the order you give. Refer to one inside the body with `![caption](photo:3f9a…)`, its own id, which is the one address Cotton Notes draws (and a picture both written in the body and listed shows once); the attachments list is what decides, so a reference to something not in it is left as plain text. Each one's `caption` is the note's own words for it; leave the key out and the picture's own caption or the document's title is what reads."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"title":{"type":"string"},"body":{"type":"string"},"attachments":{"type":"array","maxItems":500,"description":"The pictures, videos and documents this note shows, in order. At most 500.","items":{"type":"object","properties":{"kind":{"type":"string","enum":["photo","video","document"]},"id":{"type":"string","description":"A photo's or video's id — `photo:` or `video:` and its content hash — or a document's uuid."},"caption":{"type":"string","description":"The note's own words for this one, at most 500 characters. Leave it out to use the picture's own caption or the document's title."}},"required":["kind","id"],"additionalProperties":false}}},"required":["body"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "create_event",        title: "Create a calendar event",        description: r#"Add an event to the user's default calendar. startsAt is required; give endsAt when the user said how long it runs. `rrule` makes it repeat, and the row then IS the series — list_events with expand:true draws its occurrences, and update_event / delete_event change one of them or all of them. `allDay` has to know which day the event covers, so it needs a timezone: pass one, or set the database's timezone once in the app. Nothing is written to Google Calendar today: an event made here stays in Cotton, and no invitation is sent to its attendees."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"title":{"type":"string"},"startsAt":{"type":"string","description":"ISO 8601 timestamp."},"endsAt":{"type":"string","description":"ISO 8601 timestamp."},"location":{"type":"string"},"notes":{"type":"string","description":"Free text kept with the event."},"allDay":{"type":"boolean","description":"True for a whole-day event: startsAt and endsAt are widened to cover those days in the timezone below."},"rrule":{"type":"string","description":"An iCalendar repeat rule without the RRULE: prefix, e.g. FREQ=WEEKLY;BYDAY=TU. Omit for a one-off event."},"timezone":{"type":"string","description":"IANA zone (Asia/Kolkata, Europe/London) used to work out which day an all-day event covers. Defaults to the database's own timezone; needed only when allDay is true."},"onGoogle":{"type":"boolean","description":"Put this event on Google Calendar. A Cotton event with only the owner on it stays in Cotton unless this is true; one with guests goes to Google anyway; one that came from Google keeps syncing either way."},"attendees":{"type":"array","description":"Guests to invite. An event with guests goes to Google, and the serving Mac's first insert there emails them the invitation — once, never on a later edit.","items":{"type":"object","properties":{"email":{"type":"string","description":"Their email address — what the invitation is sent to."},"displayName":{"type":"string","description":"The name shown on the chip."},"personId":{"type":"string","description":"The uuid of the person in this file, when the guest is one of them."}},"additionalProperties":false}}},"required":["title","startsAt"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_events",        title: "List calendar events",        description: r#"The user's calendar over a date window — what today_agenda answers for today, over any range. Defaults to the next 14 days. `synced` marks an event read from Google Calendar: its time and title are Google's and are changed in Google (update_event refuses them); nothing here writes to Google. Two shapes: by default a repeating event appears ONCE as its series row (`repeats` carries the rule, `skips` the instants it does not produce, `exceptions` how many of its occurrences were moved or given their own details) and a moved occurrence is not listed on its own; with `expand: true` you get the concrete occurrences inside the window instead, each carrying `occurrenceAt` — the address update_event and delete_event take to change ONE occurrence. Deleted events are in neither shape."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"from":{"type":"string","description":"Window start, ISO 8601 timestamp (default: now)."},"to":{"type":"string","description":"Window end, ISO 8601 timestamp (default: 14 days after from)."},"expand":{"type":"boolean","description":"True to list the occurrences inside the window rather than the series rows. Ask for this whenever the user is talking about a particular date of a repeating event."},"limit":{"type":"integer","minimum":1,"maximum":5000}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_event",        title: "Update a calendar event",        description: r#"Change an existing event by id: retitle it, move it (startsAt/endsAt), set or clear its location or notes, flip all-day, or set and clear its repeat rule (`rrule`; null makes it a one-off again). An event from Google Calendar is read only here: its time, title, place, notes and repeat are refused with "This event is from Google Calendar. Change its time and title in Google." (nothing writes to Google today); the person's own mark, note (your_note) and alert on it are written with update_record and survive the next pull (alert is minutes before it starts; -1 is no alert at all, and empty is the ten minutes before). Find the id with list_events, today_agenda or search_records first; never guess one. ON A REPEATING EVENT you must say which occurrences you mean: pass `occurrenceAt` — the instant list_events {expand:true} returned for that occurrence — together with `scope`. `this` gives that one occurrence a row of its own with its own time, title and notes and leaves the rest of the series alone (editing the same occurrence again changes that row rather than making a second one); `all` changes the series itself, and moving the series' startsAt moves every occurrence with it, which is Google Calendar's own behaviour. There is no "this and following": it splits one series into two, which Cotton does not do yet — change the occurrences you mean one at a time, or end this series and create another. onGoogle is kept on the event but sends nothing: nothing writes to Google Calendar today."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The event's uuid. On a repeating event this is the series, even when you are changing one occurrence."},"title":{"type":"string"},"startsAt":{"type":"string","description":"ISO 8601 timestamp."},"endsAt":{"type":["string","null"],"description":"ISO 8601 timestamp; null clears the end time."},"allDay":{"type":"boolean"},"location":{"type":["string","null"],"description":"Replacement location; null clears it."},"notes":{"type":["string","null"],"description":"Replacement notes; null clears them."},"rrule":{"type":["string","null"],"description":"An iCalendar repeat rule without the RRULE: prefix, e.g. FREQ=WEEKLY;BYDAY=TU. null stops the event repeating. Not accepted together with occurrenceAt: one occurrence does not carry a rule."},"occurrenceAt":{"type":"string","description":"Which occurrence of a repeating event, as the ISO instant list_events {expand:true} gave under occurrenceAt. Requires scope. Meaningless on an event that does not repeat."},"scope":{"type":"string","enum":["this","all"],"description":"this = that one occurrence only; all = the whole series. Required whenever occurrenceAt is given."},"timezone":{"type":"string","description":"IANA zone used to work out which day an all-day event covers. Defaults to the database's own timezone; needed only when allDay is true."},"onGoogle":{"type":"boolean","description":"Put this event on Google Calendar. A Cotton event with only the owner on it stays in Cotton unless this is true; one with guests goes to Google anyway; one that came from Google keeps syncing either way."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_events",        title: "Update several calendar events",        description: r#"The batch form of update_event: up to 50 events changed in one call, each answering for itself. Pass exactly ONE of `patch` (the same fields update_event takes, applied to every id), `shift` (every event moves by a number of minutes, keeping its length) or `moveTo` (every event keeps its clock time and lands on a different date). Occurrence instants are not accepted here — a repeating event among the ids takes the whole series, update_event's `all`; to change one occurrence, call update_event. The answer is one row per id with ok and, where it failed, the reason: a bad id never stops the rest."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"ids":{"type":"array","minItems":1,"maxItems":50,"items":{"type":"string"},"description":"Event uuids, from list_events or search_records."},"patch":{"type":"object","properties":{"title":{"type":"string"},"startsAt":{"type":"string","description":"ISO 8601 timestamp."},"endsAt":{"type":["string","null"],"description":"ISO 8601 timestamp; null clears the end time."},"allDay":{"type":"boolean"},"location":{"type":["string","null"],"description":"Replacement location; null clears it."},"notes":{"type":["string","null"],"description":"Replacement notes; null clears them."},"rrule":{"type":["string","null"],"description":"An iCalendar repeat rule without the RRULE: prefix; null stops the events repeating."}},"additionalProperties":false},"shift":{"type":"object","properties":{"minutes":{"type":"integer","description":"How far each event moves. Negative brings it earlier; each event keeps its length."}},"required":["minutes"],"additionalProperties":false},"moveTo":{"type":"object","properties":{"date":{"type":"string","description":"The day to move them to, YYYY-MM-DD."},"timezone":{"type":"string","description":"IANA zone the clock time is read in. Defaults to the database's own timezone."}},"required":["date"],"additionalProperties":false},"timezone":{"type":"string","description":"IANA zone for patch.allDay, and for moveTo when moveTo does not name one. Defaults to the database's own timezone."}},"required":["ids"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "delete_event",        title: "Delete a calendar event",        description: r#"Delete an event: it goes to the bin, hidden from every read here, and restore_from_bin {kind: "event"} brings it back. One from Google Calendar is removed here only: Google Calendar still has it. ON A REPEATING EVENT you must say which occurrences you mean: pass `occurrenceAt` — the instant list_events {expand:true} returned — together with `scope`. `this` cancels that one occurrence and leaves the rest of the series; `all` deletes the whole series, moved occurrences included. There is no "this and following": it splits one series into two, which Cotton does not do yet."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The event's uuid. On a repeating event this is the series, even when you are cancelling one occurrence."},"occurrenceAt":{"type":"string","description":"Which occurrence of a repeating event, as the ISO instant list_events {expand:true} gave under occurrenceAt. Requires scope. Meaningless on an event that does not repeat."},"scope":{"type":"string","enum":["this","all"],"description":"this = that one occurrence only; all = the whole series. Required whenever occurrenceAt is given."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "delete_events",        title: "Delete several calendar events",        description: r#"The batch form of delete_event: up to 50 events deleted in one call, each by the same rule — every one goes to the bin; one from Google Calendar is removed here only, and Google still has it. A repeating event among the ids goes as a whole series; cancelling ONE occurrence is delete_event's job, since a single occurrence instant cannot mean the same thing to fifty different events. The answer is one row per id with ok and, where it failed, the reason: a bad id never stops the rest."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"ids":{"type":"array","minItems":1,"maxItems":50,"items":{"type":"string"},"description":"Event uuids, from list_events or search_records."}},"required":["ids"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "append_journal",        title: "Append to the journal",        description: r#"Add text to a day's journal page, creating the page if it does not exist yet. There is one page per day per context: the journal of the database the call runs in by default (each database keeps its own), or a project's journal when project is given — and when project names a database (its id or name), that database's own journal. Appending twice adds two paragraphs to the same page rather than making a second one. Write to a project's journal for progress entries; the owner's own journal is theirs, so only write to it when they asked for exactly that."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"text":{"type":"string"},"date":{"type":"string","description":"YYYY-MM-DD. Defaults to today in the workspace's own time zone, not the server's."},"project":{"type":"string","description":"The project's slug, from list_projects. With it, the text lands on that project's journal page for the day — the entries get_project reads back as journal.recent — instead of the owner's own journal."}},"required":["text"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_note",        title: "Update a note",        description: r#"Rewrite the title and/or body of an existing note or journal page, and say which pictures it shows. Give the whole new body, not a fragment — this replaces, it does not append (append_journal is the appending one). The previous text is kept in the note's history, so an edit is recoverable but never invisible. `attachments` works the same way: the list you send REPLACES the whole set, in the order you give it, so send the note's current attachments (get_record lists them) plus whatever you are adding; `[]` takes every one off, and leaving the argument out changes none of them. Only the ones that actually moved are rewritten. A `caption` key you leave out on an entry LEAVES THAT ATTACHMENT'S CAPTION AS IT IS — send `caption: null` to take a caption off, and a string to set one. A picture whose record has since been removed stays sendable: keep it in the list (get_record shows it as `missing`) and the note keeps saying it was there."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The note's uuid."},"title":{"type":"string"},"body":{"type":"string","description":"The complete replacement text."},"pinned":{"type":"boolean","description":"Pin the note (true) or unpin it (false); leave it out to leave it as it is."},"attachments":{"type":"array","maxItems":500,"description":"The WHOLE list this note shows, in order — it replaces what is there. [] takes them all off; omit it to leave them alone. At most 500.","items":{"type":"object","properties":{"kind":{"type":"string","enum":["photo","video","document"]},"id":{"type":"string","description":"A photo's or video's id — `photo:` or `video:` and its content hash — or a document's uuid."},"caption":{"type":["string","null"],"description":"The note's own words for this one, at most 500 characters. LEAVE THE KEY OUT to keep whatever caption this attachment already has; pass null to take it off; pass a string to set one."}},"required":["kind","id"],"additionalProperties":false}}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "archive_note",        title: "Archive a note",        description: r#"Hide a note from every list while keeping it, its history and its comment threads intact. Prefer this over asking the user to delete something: archiving is reversible and destroys nothing."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The note's uuid."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "unarchive_note",        title: "Unarchive a note",        description: r#"Bring an archived note back into every list — the reverse of archive_note. It returns exactly as it was; nothing was lost while it was archived."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The note's uuid."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "upsert_managed_note",        title: "Publish a managed note",        description: r#"File a note whose source of truth lives OUTSIDE Cotton (a mirrored file, an export), keyed by your own stable externalId. Re-sending unchanged content is free — pass the same sourceHash and nothing is written. Managed notes are read-only in the app; the user comments on them instead of editing them."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"externalId":{"type":"string","description":"Your stable key for this source, e.g. a file path."},"managedBy":{"type":"string","description":"Which manager owns these notes, e.g. claude-code-memory-mirror. Scopes externalId and list_managed_notes."},"title":{"type":"string"},"body":{"type":"string"},"sourceHash":{"type":"string","description":"Content fingerprint. When it matches what is stored, the note is left untouched and the result says unchanged."}},"required":["externalId","managedBy","body"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_managed_notes",        title: "List managed notes",        description: r#"The index of notes you previously published under one managedBy key: id, externalId, sourceHash and whether it is archived. Call this before a sync run to work out what changed and what has disappeared at the source."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"managedBy":{"type":"string"},"limit":{"type":"integer","minimum":1,"maximum":1000}},"required":["managedBy"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_people",        title: "List people",        description: r#"Enumerate the user's people — the whole contact book, paged. Each row carries id, name, phones, emails, org, roleTitle and city, and the answer states the total, so "how many people do I have" is one call. Rows come in People's own order: the people the user reached most recently by message, call or mail first, those never reached after them by name. The answer also names ownPersonId, the person who is this database's own ("You"), when one is set. q narrows by NAME SUBSTRING, case-insensitive — unlike search_records, which matches whole words only, so this is the tool for sweeps and cleanups ("everyone whose name contains 'dr'"). Page with offset; archived people are excluded unless includeArchived asks for them. For one person's full context (notes, links, summary), get_record."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"q":{"type":"string","description":"Substring of the name, case-insensitive. Omit for everyone."},"includeArchived":{"type":"boolean","description":"Also list archived people (marked archived). Default false."},"source":{"type":"string","enum":["import","manual","apple_library"],"description":"Where the person's record came from: `import` the phone's Contacts, `manual` typed by hand, `apple_library` a named person read out of the Mac's Photos library. Omit for every source."},"limit":{"type":"integer","minimum":1,"maximum":5000},"offset":{"type":"integer","minimum":0,"description":"Rows to skip, for paging. The sort is stable (name, then id)."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "create_person",        title: "Add a person",        description: r#"File a new person the user mentioned — a name plus whatever is known: phones, emails, where they work, where they live. The summary — what this person is about, in a paragraph — is written with update_summary once they exist, not here. Search first (search_records, kinds:['person']): most people the user talks about already exist, and update_person is the verb for someone found. Same-name creation is refused unless allowDuplicateName says two different people really share it."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"fullName":{"type":"string","description":"The person's name as the user says it."},"phones":{"type":"array","items":{"type":"string"},"description":"Phone numbers, digits as given. Matching against chat imports uses exact names, not numbers."},"emails":{"type":"array","items":{"type":"string"}},"instagram":{"type":"array","items":{"type":"string"},"description":"Instagram handles (a name, @name or profile URL). A handle names one person: one another person already carries is refused."},"facebook":{"type":"array","items":{"type":"string"},"description":"Facebook handles (a name, @name or profile URL). A handle names one person: one another person already carries is refused."},"linkedin":{"type":"array","items":{"type":"string"},"description":"LinkedIn handles (a name, @name or profile URL). A handle names one person: one another person already carries is refused."},"org":{"type":"string","description":"Company or organisation."},"roleTitle":{"type":"string","description":"What they do there."},"city":{"type":"string"},"timezone":{"type":"string","description":"IANA zone like Asia/Kolkata."},"birthday":{"type":"object","description":"People know the day, not always the year — year is optional.","properties":{"month":{"type":"integer","minimum":1,"maximum":12},"day":{"type":"integer","minimum":1,"maximum":31},"year":{"type":"integer"}},"required":["month","day"],"additionalProperties":false},"allowDuplicateName":{"type":"boolean","description":"Pass true only when a person with this exact name already exists and this is genuinely a second person."}},"required":["fullName"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_person",        title: "Update a person",        description: r#"Change an existing person by id: rename them, replace their phones or emails (the arrays replace whole, they do not merge; addPhones/addEmails add to what they hold instead), correct where they work or live, set or clear their birthday or timezone, or remove their photograph (avatarKey:null — a photograph is only ever SET in the owner's app, which is where the image file is). The summary — what this person is about, in a paragraph — is written with update_summary, not here. Find the id with search_records (kinds:['person']) or get_record first; never guess one. A rename onto a name another person already carries is refused unless allowDuplicateName says they really share it. Edits earn history the owner can read."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The person's uuid."},"fullName":{"type":"string"},"phones":{"type":"array","items":{"type":"string"},"description":"Replacement list — send the full set, not the delta."},"emails":{"type":"array","items":{"type":"string"},"description":"Replacement list — send the full set, not the delta."},"addPhones":{"type":"array","items":{"type":"string"},"description":"Phones added after the ones the person already has — nothing is removed. Not with phones."},"addEmails":{"type":"array","items":{"type":"string"},"description":"Emails added after the ones the person already has — nothing is removed. Not with emails."},"instagram":{"type":"array","items":{"type":"string"},"description":"Instagram handles — replacement list, the full set, not the delta. A handle another person carries is refused."},"facebook":{"type":"array","items":{"type":"string"},"description":"Facebook handles — replacement list, the full set, not the delta. A handle another person carries is refused."},"linkedin":{"type":"array","items":{"type":"string"},"description":"LinkedIn handles — replacement list, the full set, not the delta. A handle another person carries is refused."},"org":{"type":["string","null"],"description":"null clears it."},"roleTitle":{"type":["string","null"],"description":"null clears it."},"city":{"type":["string","null"],"description":"null clears it."},"timezone":{"type":["string","null"],"description":"null clears it."},"birthday":{"type":["object","null"],"description":"Replacement birthday; null clears it. Year stays optional.","properties":{"month":{"type":"integer","minimum":1,"maximum":12},"day":{"type":"integer","minimum":1,"maximum":31},"year":{"type":"integer"}},"required":["month","day"],"additionalProperties":false},"avatarKey":{"type":"null","description":"Only null, which removes the person's photograph. A photograph is set in the owner's app, which is where the image file is."},"allowDuplicateName":{"type":"boolean","description":"Pass true only when the new name is already another person's and the two really share it."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "merge_people",        title: "Merge two people",        description: r#"Fold a duplicate person into the one that stays, as one ordered operation. The survivor gains the union: phones and emails are combined, and any field the survivor lacks (org, roleTitle, city, timezone, birthday, summary) is filled from the duplicate. Everything that pointed at the duplicate — comments, project memberships, record links, person notes, money references — is repointed to the survivor, a comment on the survivor preserves the duplicate's original card first, and the duplicate is then archived, never erased. You must name the exact pair; nothing is matched by similarity here — decide who survives before calling. Refused when both people hold the same money claim (a receivable, payable, loan or lent-out account): that is real accounting and must be resolved in the app first. Cotton-side only: the iPhone contact mirror never deletes from the phone, so a duplicate's mirrored iPhone contact stays until the owner removes it by hand — the answer's deviceCard says what happened (when only the duplicate was linked to an iPhone contact, the link moves to the survivor and the next mirror pass rewrites that contact with the merged details)."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"survivorId":{"type":"string","description":"The person who stays — the uuid every reference will point at."},"duplicateId":{"type":"string","description":"The person folded in and then archived."}},"required":["survivorId","duplicateId"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "archive_person",        title: "Archive a person",        description: r#"Hide a person from lists while keeping them, their history, notes, comments and every money reference intact — nothing is erased, and unarchive_person reverses it. Prefer merge_people when the person is a duplicate of someone else: archiving alone repoints nothing. Cotton-side only: an iPhone contact mirrored for this person is untouched — the contact mirror never deletes from the phone."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The person's uuid."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "unarchive_person",        title: "Unarchive a person",        description: r#"Bring an archived person back into every list — the reverse of archive_person. They return exactly as they were; nothing was lost while they were archived."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The person's uuid."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_message_threads",        title: "List message threads",        description: r#"The user's message inbox — every conversation, 1:1 and group, newest activity first, each with its name, a one-line preview, which transports it holds (`channels`: cotton, whatsapp, imessage, sms) and, for groups, how many people are in it. One row is ONE PERSON by default: somebody the user messages on two numbers has two threads in the file and one conversation here, so a merged row carries `personId` and `threadIds` and no single `id` — open it with read_message_thread { personId }. A row that is exactly one thread carries `id`, and that is what read_message_thread { threadId } takes. Groups never merge: a WhatsApp group and an iMessage group are different groups. Pass groupBy: "thread" for the raw threads instead. Includes imported archives — this inbox is the user's own copy of their real conversations. In a SHARED database this lists the chats filed there and nothing else: pass `database`."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"groupBy":{"type":"string","enum":["person","thread"],"description":"person (default) folds every 1:1 thread with the same person into one conversation; thread lists the threads as stored."},"limit":{"type":"integer","minimum":1,"maximum":5000,"description":"Maximum conversations to return (default 50)."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "read_message_thread",        title: "Read a message thread",        description: r#"One conversation's messages in time order — who said what, when, over which transport (`channel`), with attachments as URLs. Address it EITHER way: `threadId` reads one thread, `personId` reads everything the user and that person said to each other across every number and app, interleaved by when it was sent. Pass exactly one. An imported message also carries `source` — the service it came from, the machine that read it, and that source's own id. Group messages carry the sender's name; system lines (renames, member changes) are flagged. Pages backwards through history: pass the returned nextBefore as `before` to read older messages. Ids come from list_message_threads or search_messages. In a SHARED database the conversation is a filed copy: every line is signed with the person who said it, and `direction: "out"` marks the lines of whoever filed the chat, never "the user"."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"threadId":{"type":"string","description":"One thread's uuid. Not with personId."},"personId":{"type":"string","description":"A person's uuid — every 1:1 thread they hold, merged into one timeline. Not with threadId."},"before":{"type":"string","description":"ISO timestamp — return messages sent strictly before this instant. Omit for the newest page. Pass nextBeforeId with it."},"beforeId":{"type":"string","description":"The nextBeforeId from the previous page. Pass it with before: messages that share one instant are otherwise split across pages and the tail is lost."},"limit":{"type":"integer","minimum":1,"maximum":100,"description":"Messages per page (default 50)."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "search_messages",        title: "Search messages",        description: r#"Find messages by their text, across every conversation or inside one thread. Returns the matching lines newest-first with who said them, when, which transport they arrived over (`channel`), and which thread they live in — expand the surrounding conversation with read_message_thread."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"query":{"type":"string","description":"Text to look for in message bodies."},"threadId":{"type":"string","description":"Restrict to one thread. Omit to search everything."},"limit":{"type":"integer","minimum":1,"maximum":50,"description":"Maximum matches to return (default 20)."}},"required":["query"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "ingest_emails",        title: "Ingest emails",        description: r#"Add emails to the user's Cotton archive, in batches of up to 100 per call. Cotton keeps email as an append-only archive: the user replies in their own mail client, Cotton remembers what was said. Each email names its conversation with `threadKey` — any key stable across re-imports from the same source (a provider thread id like "gmail:1899...", or the reply chain's root Message-ID); Cotton groups emails into threads by it, sets the thread's subject from the earliest email, and maintains the participant set with from/to/cc roles. IDEMPOTENT: an email whose Message-ID (or content fingerprint, when it has none) was ingested before is skipped and reported, so re-sending the same mail is always safe. Bodies must be PLAIN TEXT (strip HTML before calling); a body over 65536 characters is stored truncated with a visible marker and reported. Returns per-thread threadId, subject, added and skipped counts — link a thread to a project with link_to_project { kind: "email_thread" }. PHOTOS: an image attachment (jpeg/png/webp/heic, 32 KiB or more — signature logos and tracking pixels are skipped) whose bytes were uploaded first and named by `key` is ALSO filed as a photo, addressed by its bytes so a forwarded copy is one photo with one more sighting; the result carries `photos: { added, merged, failed }` when any were in play."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"emails":{"type":"array","minItems":1,"maxItems":100,"items":{"type":"object","properties":{"threadKey":{"type":"string","description":"Stable conversation key — provider thread id or reply-chain root. Emails sharing it land in one thread."},"subject":{"type":"string","description":"The email's subject line."},"sentAt":{"type":"string","description":"When it was sent, ISO 8601."},"body":{"type":"string","description":"The email's body as plain text (strip HTML first)."},"messageId":{"type":"string","description":"The RFC 5322 Message-ID header, when the source has it — the strongest dedupe key."},"from":{"type":"object","properties":{"email":{"type":"string","description":"Sender address."},"name":{"type":"string","description":"Sender display name."}},"required":["email"],"additionalProperties":false},"to":{"type":"array","items":{"type":"object","properties":{"email":{"type":"string"},"name":{"type":"string"}},"required":["email"],"additionalProperties":false},"description":"Direct recipients."},"cc":{"type":"array","items":{"type":"object","properties":{"email":{"type":"string"},"name":{"type":"string"}},"required":["email"],"additionalProperties":false},"description":"CC recipients — kept as first-class data, never flattened."},"bcc":{"type":"array","items":{"type":"object","properties":{"email":{"type":"string"},"name":{"type":"string"}},"required":["email"],"additionalProperties":false},"description":"BCC recipients, when the source shows them."},"snippet":{"type":"string","description":"One-line preview. Omit to derive from the body."},"attachments":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","description":"File name."},"mime":{"type":"string"},"size":{"type":"integer","minimum":0,"description":"Bytes."},"key":{"type":"string","description":"Optional media-store key for uploaded bytes; must sit inside this workspace's media prefix. An image under this key is also filed as a photo."}},"required":["name"],"additionalProperties":false},"description":"Attachment metadata; bytes are optional in this phase."}},"required":["threadKey","subject","sentAt","body","from"],"additionalProperties":false}}},"required":["emails"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_email_threads",        title: "List email threads",        description: r#"The user's email conversations, newest activity first — each with its subject, participants (matched to the user's saved people by address where possible), date range, email count and the state the mailbox is in: unread, starred, whether any of it is still in the inbox, and when the whole conversation went to the bin. Call this to find a thread's id before read_email_thread, or to see what mail the archive holds. `folder` slices the mailbox the way the user's own mail app does: 'inbox' is what has not been dealt with, 'archived' is what was filed away, 'bin' is what they threw out, and 'all' (the default) is everything except the bin. A thread's state is the fold over its messages — unread means one of them is — because that is Gmail's own model and Cotton keeps the state on the message."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"folder":{"type":"string","enum":["inbox","archived","bin","all"],"description":"Which slice of the mailbox. Default 'all' — everything except the bin."},"unreadOnly":{"type":"boolean","description":"Only conversations with something unread in them."},"sender":{"type":"string","description":"Only conversations this address SENT into — the By-sender question. Use list_email_senders to find who is writing."},"participant":{"type":"string","description":"Only threads this address takes part in, as sender or recipient (exact, case-insensitive)."},"limit":{"type":"integer","minimum":1,"maximum":5000,"description":"Maximum threads to return (default 50)."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_email",        title: "Change an email's state",        description: r#"Mark one email — or a whole conversation — read or unread, starred or not, in the inbox or archived, in the bin or back out of it. This is the user's own filing and it REACHES THEIR MAILBOX: a message archived here is archived in Gmail on their phone within a few minutes. The bin reaches Gmail only where the user switched on "Deleting here also deletes in Gmail" on that Google account's connection (off unless they did): off, mail put in the bin here stays in Gmail where it was. Pass `id` for one message or `threadId` for every message of a conversation (which is what a person means by archiving a thread). `inbox: false` archives — the mail stays, it simply leaves the inbox; `bin: true` is the softer delete, and nothing is erased until the user empties the bin (empty_bin). Nothing here edits what an email SAYS: the archive is what was written, and only its filing is the user's to change."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"One email's id, from read_email_thread or search_records."},"threadId":{"type":"string","description":"A conversation's id, from list_email_threads — applies to every message in it."},"read":{"type":"boolean","description":"true marks it read, false marks it unread."},"starred":{"type":"boolean"},"inbox":{"type":"boolean","description":"true puts it back in the inbox, false archives it."},"bin":{"type":"boolean","description":"true moves it to the bin, false restores it out of the bin."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_emails",        title: "Change many emails' state",        description: r#"update_email over up to 100 messages or conversations at once — the batch form of the same verb, for a clear-out. Pass `ids` (messages) or `threadIds` (conversations) and the same patch update_email takes. Each id gets its own outcome in the answer, so one id the user got wrong never fails the rest. Like update_email, this reaches the user's real mailbox."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":100},"threadIds":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":100},"read":{"type":"boolean"},"starred":{"type":"boolean"},"inbox":{"type":"boolean","description":"false archives."},"bin":{"type":"boolean","description":"true bins, false restores."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_email_senders",        title: "Who is writing",        description: r#"The user's mail grouped by SENDER — one row per address, with how many they sent, how many are unread, when the last one came, whether the address is blocked and what Cotton's reader takes them for (kind: person — in People or written to by the user; service — machine mail kept; junk — blocked), busiest first. This is the tool for "who is filling my inbox" and for a clear-out: find the newsletter that sends forty a week, then list_email_threads { sender } to see them or update_emails to bin them. Grouped by the address as it was sent, so two addresses belonging to one person stay two rows — blocking is per address, and folding them would offer a block that could not be honoured."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"folder":{"type":"string","enum":["inbox","archived","bin","all"],"description":"Which slice to count over. Default 'all' — everything except the bin."},"limit":{"type":"integer","minimum":1,"maximum":5000,"description":"Default 50."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "block_sender",        title: "Block a sender",        description: r#"Stop hearing from an address: the sender becomes junk, and their mail — what is here and anything they send from now on — files into Junk: Comms shows it only in its one Blocked place (People › Blocked), never in Mail or a person's chat, and never as a notice; there it is erased from Cotton thirty days after the block, or after it came if later (SENDERS.md). Nothing changes at the mail provider: moving their mail to the provider's Trash is the owner's own act, in Comms. Blocks an ADDRESS, never a person: most of these belong to nobody in the user's contact book, and the ones that do are still someone they may want a person page for. The answer says how many conversations went into Junk. Refused, by hard rule, for someone in People, someone the user has written to, or a sender whose mail carries an amount, an invoice or receipt, a ticket or booking, a one-time code or a delivery — those are the user's own to block, in the app. Ask the user before blocking anyone who is not obviously a machine."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"address":{"type":"string","description":"The email address to block."}},"required":["address"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "unblock_sender",        title: "Unblock a sender",        description: r#"Lift a block: the sender's mail comes out of Junk and back into the mail list, and new mail from them arrives normally. Idempotent: unblocking an address that is not blocked does nothing."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"address":{"type":"string","description":"The email address to unblock."}},"required":["address"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "add_sender_to_people",        title: "Add a sender to People",        description: r#"The owner's Add to People on a mail sender, in the app: links the address to the one person who already carries it as an email handle (bringing an archived one back), or makes a person with the sender's name and the address as their handle when nobody does — never a second person for a handle already held. The sender becomes a person and their conversations move to the People stack. The owner's act only; an assistant asks the user."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"address":{"type":"string","description":"The sender's email address."}},"required":["address"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "empty_junk",        title: "Empty Junk",        description: r#"The owner's Empty Junk now, in the app: every conversation in the Junk stack goes to the bin at once, where it can still be read and brought back until the bin is emptied. Gmail's copy follows only when the account's "Deleting here also deletes in Gmail" is on. Without it Junk empties itself, a conversation thirty days after its sender was blocked or last wrote. The owner's act only."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_blocked_senders",        title: "List blocked senders",        description: r#"Every address the user has blocked, and when. Read this before block_sender if you are about to suggest one, and before telling them mail from someone is missing — a blocked sender's mail is in Junk, which Comms shows as its Blocked place, and is erased from Cotton thirty days after the block, or after it came if later (SENDERS.md); until then it is not lost, and Unblock brings it back. Nothing changes at the mail provider."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_bin",        title: "What is in the bin",        description: r#"Everything the user has thrown away and not yet erased, newest first, across every kind that has a bin — todos, notes, events, passwords, photos, videos, documents, emails and email conversations, and the deleted records of tables the user defined (kind `record`, with the `table` it belongs to). Each row carries its kind, its id, what it is called and when it went in, and the answer counts what is waiting per kind. A few kinds have a better answer than the bin: a person or a place is archived. Restore one with restore_from_bin; erase with empty_bin."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"kind":{"type":"string","enum":["email","email_thread","secret","note","event","photo","video","document","message","todo","record"],"description":"One kind only. Omit for everything in the bin."},"limit":{"type":"integer","minimum":1,"maximum":5000,"description":"Per kind. Default 50."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "restore_from_bin",        title: "Take something out of the bin",        description: r#"Put one record back where it was. For an email that Gmail holds in its bin, that also takes it out of Gmail's bin. Get the kind and id from list_bin. Restoring something that is not in the bin is not an error — the answer says it was already out."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"kind":{"type":"string","enum":["email","email_thread","secret","note","event","photo","video","document","message","todo","record"]},"id":{"type":"string"}},"required":["kind","id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "empty_bin",        title: "Empty the bin",        description: r#"ERASE what is in the bin. This is the one verb in the whole email surface that destroys anything, and it cannot be undone from Cotton — so say what you are about to erase and how much of it, and let the user answer before you call it. For an email it erases COTTON'S copy: Gmail keeps its own bin for about 30 days, so a message erased here may still be recoverable in their mail app for a while. `olderThanDays` is the safer form — clear out what has been sitting there a month and keep this morning's mistake within reach."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"kind":{"type":"string","enum":["email","email_thread","secret","note","event","photo","video","document","message","todo","record"],"description":"One kind only. Omit to empty the whole bin."},"olderThanDays":{"type":"integer","minimum":1,"maximum":3650,"description":"Only erase what went into the bin longer ago than this."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "read_email_thread",        title: "Read an email thread",        description: r#"One email conversation in time order — who wrote, to whom (to/cc kept as sent), when, the full plain-text bodies, and attachments with download URLs where bytes were stored. Participants are matched to the user's saved people by exact address, so identified senders read by name. Pages backwards through history: pass the returned nextBefore as `before` to read older emails. Get the thread id from list_email_threads or search_records."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"threadId":{"type":"string","description":"The thread's id."},"before":{"type":"string","description":"ISO timestamp — return emails sent strictly before this instant. Omit for the newest page. Pass nextBeforeId with it."},"beforeId":{"type":"string","description":"The nextBeforeId from the previous page. Pass it with before: emails that share one instant are otherwise split across pages and the tail is lost."},"limit":{"type":"integer","minimum":1,"maximum":50,"description":"Emails per page (default 20)."}},"required":["threadId"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_money_accounts",        title: "List money accounts",        description: r#"Bank, card, cash, wallet and loan accounts, their currencies, current balances in integer minor units, and whether they are pooled for Ahead. Account numbers answer only their identifying ending. Use these account ids when recording a money row. Loan balances are what is still owed."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"includeArchived":{"type":"boolean","description":"Include accounts the user has put away. Defaults to false."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_money_transactions",        title: "List money rows",        description: r#"Supply to (and optional from) to read every monthly expected occurrence in that window; monthly rows carry storedId and occurrenceIndex. Money rows, actual and expected, newest first. Each row carries its one account, amount, direction, date, person and tag. Open its record to read attached evidence. An unknown amount is answered as amountKnown false, never as zero."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"from":{"type":"string","description":"YYYY-MM-DD, inclusive."},"to":{"type":"string","description":"YYYY-MM-DD, inclusive."},"personId":{"type":"string"},"accountId":{"type":"string"},"status":{"type":"string","enum":["actual","expected"]},"limit":{"type":"integer","minimum":1,"maximum":100}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "record_transaction",        title: "Record a money row",        description: r#"Record one actual or expected money row. Amounts are positive whole minor units. Set amountKnown false when the amount is not known; omit amountMinor rather than using zero. Give currency unless accountId names an existing account, whose currency is used."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"occurredOn":{"type":"string"},"description":{"type":"string"},"payeeText":{"type":["string","null"]},"amountMinor":{"type":"integer","minimum":1},"amountKnown":{"type":"boolean"},"direction":{"type":"string","enum":["in","out"]},"currency":{"type":"string"},"accountId":{"type":"string"},"forPeriod":{"type":"string"},"status":{"type":"string","enum":["actual","expected"]},"certainty":{"type":"string","enum":["fixed","expected","estimate"]},"repeat":{"type":"string","enum":["none","monthly"]},"repeatDay":{"type":"integer","minimum":1,"maximum":31},"betweenUs":{"type":"boolean"},"movesMoney":{"type":"boolean"},"tag":{"type":["string","null"]},"personId":{"type":["string","null"]},"dueDate":{"type":["string","null"]},"notes":{"type":["string","null"]}},"required":["occurredOn","description","direction"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_transaction",        title: "Update a money row",        description: r#"Change one money row's fields. A booked statement row cannot be deleted, but it can carry the same ordinary information as another row."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string"},"occurredOn":{"type":"string"},"description":{"type":"string"},"payeeText":{"type":["string","null"]},"amountMinor":{"type":["integer","null"],"minimum":1},"amountKnown":{"type":"boolean"},"direction":{"type":"string","enum":["in","out"]},"currency":{"type":"string"},"accountId":{"type":["string","null"]},"forPeriod":{"type":"string"},"status":{"type":"string","enum":["actual","expected"]},"certainty":{"type":["string","null"],"enum":["fixed","expected","estimate",null]},"repeat":{"type":"string","enum":["none","monthly"]},"repeatDay":{"type":["integer","null"],"minimum":1,"maximum":31},"betweenUs":{"type":"boolean"},"movesMoney":{"type":"boolean"},"tag":{"type":["string","null"]},"personId":{"type":["string","null"]},"dueDate":{"type":["string","null"]},"notes":{"type":["string","null"]}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "delete_transaction",        title: "Delete a transaction",        description: r#"Put a handmade money row in the bin by id. A row booked from a statement is permanent and this call refuses it; correct its ordinary fields with update_transaction instead. Restore a binned row with restore_from_bin."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The transaction's uuid."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "settle_expected",        title: "Settle an expected row",        description: "A monthly read-occurrence identity settles its stored expected row; settlement still materializes only one next row. Link a real money row to the expected row it settles.",        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: true, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"expectedId":{"type":"string"},"actualId":{"type":"string"}},"required":["expectedId","actualId"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "set_period",        title: "Set the month a row is for",        description: "Set the month a money row is for.",        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: true, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string"},"forPeriod":{"type":"string","description":"YYYY-MM."}},"required":["id","forPeriod"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "set_tag",        title: "Set a money tag",        description: "Set or clear one money row's optional tag.",        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: true, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string"},"tag":{"type":["string","null"]}},"required":["id","tag"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "set_person",        title: "Set a person on a money row",        description: "Set or clear the person linked to one money row.",        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: true, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string"},"personId":{"type":["string","null"]}},"required":["id","personId"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "mark_transfer",        title: "Mark two money rows as a transfer",        description: "Link the two rows that are the same transfer between accounts.",        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: true, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"firstId":{"type":"string"},"secondId":{"type":"string"}},"required":["firstId","secondId"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "read_statement",        title: "Read a filed statement",        description: r#"Queue the SERVER's own reader for a bank or card statement the user has already filed in Documents. That reader runs only on the user's own API key stored on this server — never on a shared budget — so the answer says which of two things happens: the statement is read on the server's clock (poll get_statement), or the server has no key of the user's and the statement waits. An assistant that can read the paper itself should do that instead: get_document_bytes gives you the file, and submit_statement_reading takes your reading — it costs the user nothing beyond the plan they already have. Either way Cotton then checks the total against the statement's printed opening and closing balance, matches or creates the account it is for, and records each entry with the statement line it came from as its evidence. Call this for a statement filed before reading was switched on, or when the READING itself was wrong. It is not the way to fix one entry: a re-read replaces every entry it read, so any hand correction to an entry not yet in their money is discarded — correct an entry with update_statement_line instead. Only documents typed bank_statement or card_statement can be read."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"documentId":{"type":"string","description":"The filed document's uuid, from list_documents or search_documents."}},"required":["documentId"],"additionalProperties":false}"#,        outside_write_lock: true,    },    ToolDef {        name: "list_statements",        title: "List statements",        description: r#"The bank and card statements Cotton has read, newest period first: which account each is for, the period it covers, whether its totals agreed with the entries read from it, how many entries it holds and how many of those are already in the user's money. A statement still waiting to be read has no period yet, so it is ordered by the day it was filed instead. Use it to answer "do we have March for the Meridian account" and to find the statements that need attention — anything whose totals did not agree is listed with its check (balanceCheck), and a reading that broke carries its readError."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"accountId":{"type":"string","description":"Only statements for this account (its uuid, from list_money_accounts)."},"readStatus":{"type":"string","enum":["pending","read","mismatch","failed"],"description":"pending: waiting to be read. read: read and its entries recorded. mismatch: the totals did not agree, so nothing was recorded. failed: the reading itself broke."},"from":{"type":"string","description":"YYYY-MM-DD — statements whose period ends on or after this."},"to":{"type":"string","description":"YYYY-MM-DD — statements whose period starts on or before this."},"limit":{"type":"integer","minimum":1,"maximum":5000}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "get_statement",        title: "Open one statement",        description: r#"One statement in full: which account and period it covers, the opening and closing balance it printed, whether those agreed with its entries, and — with includeLines — every entry exactly as the paper prints it, in order, each saying whether it is already in the user's money and which record it became. An entry Cotton deliberately did not record (an opening-balance row, a totals line) says why. This is where you look when the totals did not agree: find the entry that is wrong, fix it with update_statement_line, then call book_statement."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The statement's uuid, from list_statements."},"includeLines":{"type":"boolean","description":"Include every entry (default true). Pass false for the header alone."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_statement_line",        title: "Correct one entry on a statement",        description: r#"Fix one entry Cotton read wrongly — the date, the amount, which way the money went, or mark it as an entry that should not become money at all (an opening-balance row, a totals line). The statement's totals are checked again straight away and the answer says whether they agree now. This does not change anything already recorded in the user's money: correct the entry, then call book_statement. A statement whose reading failed keeps that status — read_statement is what reads it again. amountMinor is whole minor units (245000 for 2450.00 in a currency with two decimal places); a value with a decimal is refused rather than rounded."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The entry's uuid, from get_statement."},"postedOn":{"type":"string","description":"YYYY-MM-DD, the date the statement prints."},"amountMinor":{"type":"integer","minimum":1,"description":"Positive whole minor units."},"direction":{"type":"string","enum":["in","out"],"description":"in or out, from the account's point of view. On a card a purchase is out and a payment is in."},"ignoredReason":{"type":["string","null"],"description":"Why this entry is not money moving — \"opening balance row\", \"statement summary\". Null makes it an ordinary entry again."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "book_statement",        title: "Record a statement's entries",        description: r#"Record every entry on a statement that is not already in the user's money and is not marked as an entry to leave out. Use it after correcting an entry with update_statement_line, or when a statement's totals did not agree and the user wants it recorded anyway. Safe to call twice: an entry already in their money is left exactly as it is. Each entry becomes one record carrying the statement line as its evidence: a payee Cotton already knows is recognised straight away, and anything else stays unaccounted for you or the next reading to name."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The statement's uuid, from list_statements."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: true,    },    ToolDef {        name: "submit_statement_reading",        title: "Hand in a statement you read yourself",        description: r#"Hand in your own reading of a filed bank or card statement — its header and every entry, in the reader's contract — after reading the paper in your session (get_document_bytes gives you the file). This is how a statement gets read on a server that holds no API key of the user's own: the server's reader runs only on that key, so read_statement alone would leave the statement waiting. Cotton then does everything it does after its own reading: checks that opening + money in − money out = closing (for a card, the amount owed), matches or creates the account, records each entry with its line as evidence, pairs transfers between the user's own accounts and names what it already recognises. When the totals do not agree NOTHING is recorded: the entries are saved, the statement is marked mismatch, and the answer carries the printed closing balance, the closing balance the entries add up to, the sums in and out and the first line whose running balance breaks — read those lines again and call this again with the whole reading. Check the arithmetic yourself BEFORE submitting. Every amount is whole minor units (245000 for 2450.00 in a currency with two decimal places) and always positive, with direction carrying the sign from the account's side (on a card a purchase is out, a payment is in); text is the line exactly as printed, whitespace collapsed; a row that is not money moving (an opening-balance row, a totals line) is still a line, with ignored_reason set. Submitting again over a statement already recorded is safe: an entry already in the user's money keeps its record and its words, and only new entries are added."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"statementId":{"type":"string","description":"The statement's uuid, from list_statements. Pass this OR documentId."},"documentId":{"type":"string","description":"The filed document's uuid, from list_documents — for a bank_statement or card_statement that has no statement row yet. Pass this OR statementId."},"readBy":{"type":"string","maxLength":80,"description":"Who read the paper, recorded on the statement — \"claude-code session\". Default \"assistant\"."},"header":{"type":"object","properties":{"institution":{"type":"string","minLength":1,"maxLength":120,"description":"The institution as printed, in title case: \"Meridian Bank\"."},"number_mask":{"type":["string","null"],"minLength":1,"maxLength":24,"description":"The last digits of the account or card as printed, digits only. Null when the paper shows none — never an empty string."},"kind":{"type":"string","enum":["bank","credit_card"]},"period_start":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$","description":"YYYY-MM-DD, the first day the statement covers."},"period_end":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$","description":"YYYY-MM-DD, the last day the statement covers."},"opening_balance_minor":{"type":["integer","null"],"description":"WHOLE MINOR UNITS — an integer in the printed currency, never a decimal. For a card this is what was OWED at the start. Null when no balance is printed."},"closing_balance_minor":{"type":["integer","null"],"description":"WHOLE MINOR UNITS — an integer in the printed currency, never a decimal. For a card this is what is OWED at the end. Null when no balance is printed."},"currency":{"type":"string","minLength":3,"maxLength":3,"description":"The ISO currency code, EXACTLY three letters and nothing else, for example USD. Never a symbol and never a word."},"account_name":{"type":"string","minLength":1,"maxLength":80,"description":"What a person would call this account: \"Meridian savings\", \"Kestrel Bank credit card\". Never empty — fall back to the institution and the kind."}},"required":["institution","number_mask","kind","period_start","period_end","opening_balance_minor","closing_balance_minor","currency","account_name"],"additionalProperties":false},"lines":{"type":"array","items":{"type":"object","properties":{"page":{"type":"integer","minimum":1,"description":"The page this line is printed on, counting from 1."},"posted_on":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$","description":"YYYY-MM-DD as printed. Use the value date only when it is the only date given."},"text":{"type":"string","minLength":1,"maxLength":500,"description":"The line's description verbatim, whitespace collapsed. Nothing added, nothing summarised. Never empty — a row that prints no words takes what the column says it is, e.g. \"opening balance\"."},"amount_minor":{"type":"integer","minimum":1,"description":"WHOLE MINOR UNITS: an integer in the printed currency. For a currency with two decimal places, 2450.00 is 245000. Never a decimal. Always POSITIVE — direction carries the sign."},"direction":{"type":"string","enum":["in","out"],"description":"From the account's point of view. On a card a purchase is out and a payment or refund is in."},"balance_after_minor":{"type":["integer","null"],"description":"The running balance printed on this line, in WHOLE MINOR UNITS — an integer in the printed currency, never a decimal. Null when the paper prints none."},"reference":{"type":["string","null"],"maxLength":120,"description":"The cheque or reference number when one is printed."},"ignored_reason":{"type":["string","null"],"maxLength":120,"description":"Set when this row is not money moving — \"opening balance row\", \"statement summary\", \"carried forward\". Null for a real entry."}},"required":["page","posted_on","text","amount_minor","direction","balance_after_minor","reference","ignored_reason"],"additionalProperties":false}}},"required":["header","lines"],"additionalProperties":false}"#,        outside_write_lock: true,    },    ToolDef {        name: "attach_evidence",        title: "Attach evidence to a transaction",        description: r#"Point a money row at something that proves it — a statement entry, a filed document, a chat message, an archived email, or a row from another system. Give the exact words the evidence carries in `excerpt`."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"transactionId":{"type":"string","description":"The money record's uuid."},"kind":{"type":"string","enum":["statement_line","document","message","email","external"],"description":"statement_line, document, message and email each need refId — the id of the thing. external is for a row from another system and takes sourceLabel instead."},"refId":{"type":"string","description":"The statement entry, document, message or email's uuid."},"excerpt":{"type":"string","description":"The exact words the evidence carries. This is what the user reads."},"sourceLabel":{"type":"string","description":"For external evidence: where the row came from — \"Splitwise CSV\", \"Khatabook sheet 2026-09-02\"."}},"required":["transactionId","kind","excerpt"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "remove_evidence",        title: "Remove evidence",        description: r#"Take one piece of evidence off a money row when it pointed at the wrong thing. Removing a statement entry's evidence frees that entry to be recorded again."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The evidence row's uuid, from get_record."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "match_external",        title: "Import rows from another money service",        description: r#"Unresolved person names are returned without creating a row; resolve the person and retry. Import rows from another money service as new, accountless money rows. Each imported row is actual and does not move bank money; it may link to a person and carry a tag. `personId` is preferred; `person` is an exact full-name lookup and an ambiguous name refuses. `externalId` is the source's stable row id and makes repeated imports idempotent."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"sourceLabel":{"type":"string","description":"Where these rows came from."},"rows":{"type":"array","minItems":1,"maxItems":500,"items":{"type":"object","properties":{"date":{"type":"string","description":"YYYY-MM-DD."},"amountMinor":{"type":"integer","minimum":1,"description":"Positive whole minor units."},"direction":{"type":"string","enum":["in","out"]},"text":{"type":"string","description":"The source row's text."},"currency":{"type":"string","pattern":"^[A-Z]{3}$","description":"ISO 4217 currency."},"externalId":{"type":"string","description":"Stable id of this row in the source."},"personId":{"type":"string","description":"Person uuid, preferred when known."},"person":{"type":"string","description":"Exact full name when no person uuid is available."},"tag":{"type":"string","description":"Optional source tag."}},"required":["date","amountMinor","direction","text","currency"],"additionalProperties":false}}},"required":["sourceLabel","rows"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "create_money_account",        title: "Add a place money sits",        description: r#"Add one of the user's real accounts — a bank account, credit card, cash, wallet or loan — named the way they say it. Give institution and numberMask when a statement prints them so Cotton recognises the account next time. A loan statement is booked like a bank statement and its balance is what is still owed."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"name":{"type":"string","description":"What the user calls it."},"kind":{"type":"string","enum":["bank","credit_card","cash","wallet","loan"]},"institution":{"type":"string","description":"The institution as a statement prints it."},"numberMask":{"type":"string","description":"The last digits a statement prints, digits only."},"currency":{"type":"string","description":"ISO 4217 currency."}},"required":["name","kind"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_money_account",        title: "Rename, put away or make usual an account",        description: r#"Change what the user calls one of their accounts, put it away when it is closed, make it usual, or mark whether it is pooled. At most one open bank, cash or wallet account is usual. Putting an account away keeps every record that ever moved through it."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The account's uuid."},"name":{"type":"string"},"archived":{"type":"boolean","description":"true puts it away; false brings it back."},"usual":{"type":"boolean","description":"true makes it the usual account; false turns it off, so none is usual."},"isPooled":{"type":["boolean","null"],"description":"Whether this account is pooled; null clears the setting."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "export_tool", title: "Share a tool",        description: r#"Export a tool as a .cottontool zip signed by this device. bytes is standard base64."#,        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: false, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"tool_id":{"type":"string"}},"required":["tool_id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "import_tool", title: "Add a tool",        description: r#"Import a .cottontool zip (bytes as standard base64). Verifies its signature and refuses connections, engine bindings and code. Definitions sync as records. A package may carry sample rows (records/<table>.json); they are created only when `with_samples` is true, each as an ordinary record under the byline "sample", and the answer's `sample_records` counts them. A tool already installed under the package's id is upgraded in place, and a table no live tool lists is re-attached: the table takes the package's definition when every column that stays keeps its type (a changed type is refused naming the column); rows stay, a dropped column's values still in their data. A table another tool lists cannot be redefined."#,        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: false, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"bytes":{"type":"string"},"with_samples":{"type":"boolean","description":"Create the package's sample rows too (default false)."}},"required":["bytes"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_definition", title: "Change how a table's records look",        description: r#"Change every present or future look key of a table as data, including built-ins (Devices, Todos). Table identity, engines, commands, connections and shipped column types stay fixed. Look keys include: `slip` (a row in its list), `tile` (its tile on a board), `page` (the sections of a record's page), `page_parts` (the page's parts in order: title, facts, grid, content, messages, script, sections, strip), `parts`, `picture` (the tool card's picture: an object name or {"photo": "photo:<sha256>"}), `group`, `sort` and `empty` (the list's sections, order and empty words), `links` and `menu` (the acts its list's menu offers: send the table's own entries in the order wanted, leaving out the ones to hide — an act the table does not offer is refused), `groups` (its stacks: the face a group's pile is drawn with, or null for none; where groups are kept stays the table's), `columns` on a shipped table (its whole list: every shipped key and type preserved — name, readonly, format, units, hidden and placeholder are look overlays; it is never removed or retyped, its engine reads it — then the person's own, keyed own_… with a name and a type of text, longtext, date, time, number, amount, choice (with choices), bool or url; their values are written with update_record like any column), `columns` on a made table (the whole existing list, with the same look overlays; adding, removing or retyping columns is refused), `live_read` (the read-only engine fields and bindings; methods outside the core allowlist are refused), and `instructions`. Each value replaces that key whole (null removes it, except a shipped tool's picture: null restores its shipped picture); a value put back to what Cotton ships follows Cotton's file again. Called with `table` alone it answers those keys as they stand and writes nothing — read them first and send back the whole edited value. A shipped column's type, engines, commands and connections are refused. The result is validated and refused whole if it does not draw; it answers `before`, each changed key as it stood."#,        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: true, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"table":{"type":"string","description":"The table's id (device, todo, or one a person defined)."},"columns":{"type":"array"},"slip":{"type":["object","null"]},"tile":{"type":["object","null"]},"page":{"type":["array","null"]},"page_parts":{"type":["array","null"],"items":{"type":"string","enum":["title","facts","grid","content","messages","script","sections","strip"]}},"parts":{"type":["object","null"]},"picture":{"type":["string","object","null"]},"group":{"type":["object","null"]},"sort":{"type":["object","null"]},"empty":{"type":["object","null"]},"links":{"type":["array","null"]},"menu":{"type":["array","null"]},"groups":{"type":["object","null"]},"live_read":{"type":["object","null"]},"instructions":{"type":["string","null"]}},"required":["table"],"additionalProperties":true}"#,        outside_write_lock: false,    },    ToolDef {        name: "arrange_tools", title: "Arrange the tiles on Home",        description: r#"Put tiles on Home or take them off — the same membership the owner's own Add a tile and Remove write. A tile is a view: a tool's list (its key — todos, memory, devices, or an installed tool's id), one table of a tool with several (`<tool>/<table>`, e.g. `money/transaction`; it opens that table's list), Everything (`everything`), or a group (`<table>/<groupId>`). `add` puts each named tile on Home, `remove` takes each off (the tool and its records stay; Add a tile brings it back). Home's order is not set here or anywhere: it is alphabetical by name in every database, always, and a tile with nothing to show is drawn faint in its place. A name this database cannot show is refused whole. Called with nothing it answers Home's tiles in the order they are drawn, each with whether it is empty, and the database's tools, and writes nothing."#,        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: true, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"add":{"type":"array","items":{"type":"string"},"description":"Tiles to put on Home: tool keys, <tool>/<table>, everything, or <table>/<groupId>."},"remove":{"type":"array","items":{"type":"string"},"description":"Tiles to take off Home."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_tools", title: "List tools",        description: r#"List imported tool definitions with their author and signature: `signature` is "unsigned", or "signed" with `by`, the signing device key."#,        scope: McpScope::Read,        annotations: Annotations { read_only_hint: true, destructive_hint: false, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_toolkits", title: "List toolkits",        description: r#"List the toolkits a new database can be made from, as your personal database keeps them, in the order the chooser shows: each kit's id, name, description, picture, whether it is still as Cotton shipped it (`shipped`), and its tools in order — a built-in by its key (todos, calendar), a tool the kit carries by its key, name, picture and tables. With `id`, answers that one kit whole, every carried tool's definition and tables included. Ask the personal database; a shared one keeps no kits."#,        scope: McpScope::Read,        annotations: Annotations { read_only_hint: true, destructive_hint: false, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"One kit's id (family, home-kitchen) to answer whole."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "save_toolkit", title: "Save a database as a toolkit",        description: r#"Save a database's Home as a toolkit a new database can be made from: the tools on that database's Home, in the order Home draws them — a built-in by its key, every tool installed there carried whole (its tables, its pictures) — under `name`, kept in your personal database. `from` is the database's id or its name. The kit gets its own id from its name (home-kitchen for "Home kitchen"), with a suffix when that id is taken (home-kitchen-2) — a shipped kit is never overwritten. `replace: true` overwrites the kit of yours at that name's id instead; it never replaces a shipped kit. Ask the personal database."#,        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: true, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"from":{"type":"string","description":"The database to save: its id or its name."},"name":{"type":"string","description":"The kit's name, as the chooser shows it."},"description":{"type":"string"},"replace":{"type":"boolean","description":"Overwrite your own kit at this name's id rather than saving a new one. Never a shipped kit."}},"required":["from","name"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_toolkit", title: "Change a toolkit",        description: r#"Change a toolkit: each of `name`, `description`, `picture` and `tools` given replaces that part whole (tools in the form list_toolkits with an `id` answers; read it first and send the whole edited list). A shipped kit is never changed in place: changing one saves your changed copy under its own id (home-kitchen-2), answered as the toolkit, and the shipped kit stays as Cotton ships it. Ask the personal database."#,        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: true, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"picture":{"type":["string","object","null"]},"tools":{"type":"array"}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "delete_toolkit", title: "Delete a toolkit",        description: r#"Delete a toolkit, so the chooser no longer offers it; databases already made from it are untouched. A shipped kit you delete stays deleted. Ask the personal database."#,        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: true, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string"}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "add_tool", title: "Add a tool",        description: r#"Add to this database, on purpose, one of the tools Cotton offers as packages: a kit tool by its id (`"todos"`, `"calendar"`, `"notebook"`, `"people"`, `"photos"`, `"email"`, `"messages"`, `"passwords"`, `"documents"`, `"artifacts"`, `"music"`), a business package a flavour names (`"yoga"`, `"kitchen"`), installed whole here with its tables and picture and no sample rows, exactly as import_tool installs it; or Domains (`"domains"`) — the domains you hold or look after, written by hand or filled by a Cloudflare connection. No tool is built in: every tool is a package this database holds a row of. Adding a tool already here changes nothing (`added: false`); an id that is none of these is refused, naming what can be added. remove_tool takes it away again and keeps its tables and records for its return. A tool of your own arrives with import_tool."#,        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: false, idempotent_hint: Some(true), open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"tool_id":{"type":"string","description":"The tool to add: a kit tool's id (\"todos\", \"notebook\", ...), a business package's (\"yoga\"), or \"domains\"."}},"required":["tool_id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "remove_tool", title: "Remove a tool",        description: r#"Remove any tool from this database: its row and its tiles on Home go; its tables, their records and every engine on them stay untouched, so importing or adding it again draws what is there. Tables no other tool here lists are answered as `orphaned_tables`."#,        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: true, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"tool_id":{"type":"string"}},"required":["tool_id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_records",        title: "List a table's records",        description: r#"Ahead reads monthly expected occurrences through from/to, by default as many calendar months from the reader day as the view's horizon says (three where its definition names none). Each later occurrence carries its stored row identity and month index; the read creates no rows. With last_changed true, answers only {table, last_changed}: the latest live record stamp for the whole table, or null where no stored stamp exists; ask without filters or paging. A built-in marked derived is answered by its engine. Supply today (YYYY-MM-DD) for a day-dependent view; missing or invalid days are refused. One page of any table's records, by the table's id — a built-in such as `todo`, `note` or `goal`, or a table the user defined. Each record is `{ table, id, data, created_at, updated_at, deleted_at, byline }`, `data` keyed by the table's column keys. Deleted records are left out. `project` (a project id or slug) keeps the records filed under it; `query` keeps those whose title or text columns contain every word. `where` keeps those whose columns hold what it names — an object of column keys, each mapped to a value (`{\"status\": \"open\"}`), a list of values or `{\"values\": [..]}` (any one of them), or `{\"present\": true}` / `{\"present\": false}`, or on a date column `{\"month\": 1-12}` (that month in any year) or `{\"within_days\": n}` (no more than n days back, or later); every entry must hold, and a column the table does not have or cannot be narrowed by is refused. A table whose definition `shows` only some of its records lists just those (the accounts list: the places money sits) unless `where` names that column itself. Paging is by offset: `page` is how many records to skip (0 first), `limit` how many to return (50 by default, at most 5000), and the answer's `next_page` is the `page` to ask for next, or null when there are no more; `total` is how many records the whole list holds. A list read in sections — todos (today, late newest first, each of the next seven days, later, undated, done, dropped) and a list split into days such as the calendar (coming from today soonest first, earlier newest first) — also answers `sections`, `[{key, count}]` (a day ahead also `day`), each count over the whole list on the reader's day (`today`, else the day in `timezone`), sections with none left out; its records come today, the days ahead, the undated, the late, then the closed — or, with `section`, only that section's. `ids` (1 to 5000 record ids) answers just those records instead, live ones only, in the order asked — every other narrowing and paging argument is refused beside it. Archived records are left out of the list; `archived: true` answers only the table's archived records instead (never binned ones), in the same order, paged the same way, `total` how many are archived — `limit: 0` beside it answers that count with no records. A table whose records are never archived refuses it. An archived record comes back with update_record, clearing its archive column."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"view":{"type":"string","description":"A tool view of this table, by its id (or tool/view): the list reads in that view's own order and slips where it declares them."},"count_only":{"type":"boolean","description":"Read only the visible count. Takes table, today, timezone and an optional Money runway from/to window; answers total without records."},"last_changed":{"type":"boolean","description":"Read only the whole table’s latest live change stamp, without record bodies."},"timezone":{"type":"string","description":"The reader's IANA time zone (\"Europe/Lisbon\"). An event's day and start time are answered in it; absent, the workspace's zone."},"today":{"type":"string","description":"The caller calendar day, YYYY-MM-DD. Money engine views default from a known workspace timezone; send this when the workspace has no known timezone."},"table":{"type":"string","description":"The table's id, as its definition names it: \"todo\", \"note\", or a table the user defined such as \"lesson\"."},"project":{"type":"string","description":"A project id or slug."},"query":{"type":"string","description":"Words to look for in the title and text columns."},"where":{"type":"object","description":"Column key → a value, a list of values (any one), {\"values\": [..]} or {\"present\": true|false}; every entry must hold. On a table with groups, {\"group\": id} alone answers that group's records in the group's own order."},"page":{"type":"integer","minimum":0,"description":"How many records to skip; next_page from the previous answer."},"limit":{"type":"integer","minimum":0,"maximum":5000,"description":"How many records to return (default 50); 0 only beside archived: true."},"ids":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":5000,"description":"Record ids: answer just these records, in this order, instead of a page."},"section":{"type":"string","description":"On a list read in sections (todos; a list split into days, such as the calendar): only this section's records, paged as usual, total its count. Todos: today, late, day (with day), later, undated, done, dropped. Calendar: coming, earlier."},"day":{"type":"string","description":"With section \"day\": which of the next seven days, YYYY-MM-DD."},"period":{"type":"string","enum":["this_month","today","tomorrow","next_7_days","next_day","this_year"],"description":"Only records whose own date falls in this stretch from today (say today): this_month, today, tomorrow, today and the six days after it, next_day — the first day after today that holds any of the list's records — or this_year, the calendar year of today. Tables the user or a package defined only."},"archived":{"type":"boolean","description":"true: only the table's archived records (never binned ones), total how many are archived; with limit 0, that count alone."},"from":{"type":"string","format":"date","description":"For a monthly Money runway view, the first calendar day of its window, YYYY-MM-DD; defaults to the reader day."},"to":{"type":"string","format":"date","description":"For a monthly Money runway view, the last calendar day of its window, inclusive, YYYY-MM-DD; defaults to the view's horizon in calendar months from the first day (three where its definition names none), exclusive."}},"required":["table"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "summarize_records",        title: "A table's tile figures",        description: r#"The figures a table's board tile shows, computed over every live record of the table — what its definition's `tile.summary` asks for: a `count` of rows, a `sum` of a number or amount column, the `min` or `max` of a date, number or amount column, each over the rows its `where` keeps. Answers `{ table, summary: [{ op, column, label, value, currency }] }` in the definition's order; `value` is null when no row qualifies or when an amount sum's rows do not share one currency (then `currency` is "mixed"). A table whose tile has no summary answers an empty list. A tile drawn as a chart adds `chart: { kind, by, x, y, currency, buckets: [{ start, value }], total, left_out }` — each period's sum of `y` (an amount in minor units, in `currency`; rows in another currency are named in `left_out`, never added) or its count, over the window ending with today's period. A table that ships a chart view adds `view_chart`, that view's series, the same shape."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"table":{"type":"string","description":"The table's id, as its definition names it."},"record":{"type":"string","description":"A record of the table: adds `sparklines`, the line each of its page's sparkline sections draws over that record's linked rows."},"at":{"type":"string","description":"Current instant with an offset, RFC3339; anchors hourly charts. Absent, the server clock."},"today":{"type":"string","description":"The caller calendar day, YYYY-MM-DD: a chart's window ends with its period. Absent, today in UTC."}},"required":["table"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "get_record_by_table",        title: "Get one record of a table",        description: r#"A built-in marked derived is answered by its engine. Supply today (YYYY-MM-DD) for a day-dependent view; missing or invalid days are refused. One record of any table, by the table's id and the record's id, deleted or not: `{ table, id, data, created_at, updated_at, deleted_at, byline }`. `data` is keyed by the table's column keys; a column with no value is left out. A built-in also answers what its engine keeps beside its columns: `attachments` (a note's or a thought's pictures, `[{ kind, id, caption }]`) and `links` (the records a thought became, `[{ table, id, title, container, when_kind, when }]`)."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"timezone":{"type":"string","description":"The reader's IANA time zone (\"Europe/Lisbon\"). An event's day and start time are answered in it; absent, the workspace's zone."},"today":{"type":"string","description":"The caller calendar day, YYYY-MM-DD. Money engine views default from a known workspace timezone; send this when the workspace has no known timezone."},"table":{"type":"string","description":"The table's id, as its definition names it: \"todo\", \"note\", or a table the user defined such as \"lesson\"."},"id":{"type":"string","description":"The record's id."}},"required":["table","id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "run_record_act",        title: "Run a package action",        description: "Run a declared act of an installed package on its current record. The server resolves conditions and bindings and executes reserve_record, cancel_reservation, a typed rules@1 set or create. Number picks take a JSON number within the declared min and max; omission uses the declared default. Acts with picks take picked as an ordered list, one typed value per pick.",        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: true, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"table":{"type":"string"},"id":{"type":"string"},"act":{"type":"string"},"picked":{"type":["string","number","array"],"items":{"type":["string","number"]}}},"required":["table","id","act"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "reserve_record",        title: "Reserve places",        description: "Claim places against the installed tool reserve binding in one server transaction. A configured quantity_column on the claim takes a positive whole number, default one; capacity counts the sum of live quantities. Answers typed ok, reason, remaining, and record on success. Refuses on a phone copy.",        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: false, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"tool":{"type":"string"},"slot":{"type":"string"},"data":{"type":"object"}},"required":["tool","slot","data"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "cancel_reservation",        title: "Cancel a reservation",        description: "Cancel one claim and release its full quantity on the serving machine. Answers typed ok, reason, remaining.",        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: false, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"tool":{"type":"string"},"id":{"type":"string"}},"required":["tool","id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "create_record",        title: "Create a record in a table",        description: r#"Add one record to any table, by the table's id. `data` is an object of column keys and values, checked against the table's definition: a key the table does not have, a missing required column or a value of the wrong type is refused with the reason. Values are JSON by column type: text and longtext a string; date \"YYYY-MM-DD\"; time \"HH:MM\"; number a number; amount a WHOLE number of currency minor units — 12.5 or even 12.0 is refused, never rounded; choice one of the column's choices; link the linked record's id; photo and file a media key; bool true or false; url an absolute web address starting http:// or https://. null clears a column. A column the data leaves out takes the definition's `default` for it when there is one. A link must name a record that exists. For a built-in table the record is written by that table's own tool, so its rules still hold; a built-in that cannot be written this way says so. Every write answers `{ change, record }`: `change` is `{ id, table, record_id, verb, byline, before, after, created_at, undone_by, undoable, reason }` — who wrote it, the values before and after, and whether undo can reverse it (`reason` says why not) — and `change.id` is what undo takes."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"table":{"type":"string","description":"The table's id, as its definition names it: \"todo\", \"note\", or a table the user defined such as \"lesson\"."},"data":{"type":"object","description":"The new record's values, keyed by column key."}},"required":["table","data"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "get_board",        title: "Read a board",        description: "Read a screen's whole resolved board JSON, its id and default: true when it draws this build's shipped copy. Read, edit the definition and send it to update_board to change the board in this database.",        scope: McpScope::Read,        annotations: Annotations { read_only_hint: true, destructive_hint: false, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The board id: home, tools, database or settings."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_board",        title: "Save or preview a board",        description: "Write a whole board as this database's own copy over the shipped board. Unknown parts, faces and data sources are refused before anything is saved. dry_run: true names changes and writes nothing. The shared record change.id can be undone through undo. A saved board redraws live.",        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: true, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string"},"definition":{"type":"object","description":"The whole board definition, naming the same id."},"dry_run":{"type":"boolean","default":false}},"required":["id","definition"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "save_theme",        title: "Save or preview a theme",        description: "Write a whole theme definition using the shared record history. dry_run: true writes nothing and answers changes (key, old, new), refused (key, value, range when a number is outside its range, reason), and valid. Every number has a fixed range; any key outside its range refuses the whole save and the refusal names each key, value and range. The change.id can be undone through undo; the owner can undo the last theme change from this device's page.",        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: true, idempotent_hint: None, open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"definition":{"type":"object","description":"Whole theme definition; id is paper, plain or database."},"dry_run":{"type":"boolean","default":false}},"required":["definition"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_record",        title: "Update a record in a table",        description: r#"Change some values of one record, by the table's id and the record's id. `patch` names only the columns to change; a key left out is kept and null clears it (never a required column). Values are JSON by column type: text and longtext a string; date \"YYYY-MM-DD\"; time \"HH:MM\"; number a number; amount a WHOLE number of currency minor units — 12.5 or even 12.0 is refused, never rounded; choice one of the column's choices; link the linked record's id; photo and file a media key; bool true or false; url an absolute web address starting http:// or https://. null clears a column. On a note or a thought, `attachments` is the WHOLE ordered picture list, `[{ kind, id, caption? }]` (`[]` or null takes every picture off). Every write answers `{ change, record }`: `change` is `{ id, table, record_id, verb, byline, before, after, created_at, undone_by, undoable, reason }` — who wrote it, the values before and after, and whether undo can reverse it (`reason` says why not) — and `change.id` is what undo takes. `before` and `after` hold only the columns that changed."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"table":{"type":"string","description":"The table's id, as its definition names it: \"todo\", \"note\", or a table the user defined such as \"lesson\"."},"id":{"type":"string","description":"The record's id."},"patch":{"type":"object","description":"The columns to change, keyed by column key; null clears one."},"scope":{"type":"string","enum":["this","all"],"description":"A repeating event only, and then required: \"this\" changes the day the id names (a later day's id is <series>@<start>) as its own event and leaves the series; \"all\" changes every day of it."}},"required":["table","id","patch"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "delete_record",        title: "Delete a record from a table",        description: r#"Delete one record, by the table's id and the record's id. A record of a table the user defined is kept with `deleted_at` set and waits in the bin (list_bin kind `record`), so undo or restore_from_bin brings it back; a built-in record is removed the way its own tool removes one (a note or a todo waits in the bin), and a table whose records are never deleted says what to do instead. On the `bin` table it ERASES that one binned row for good, as empty_bin does, and cannot be undone — say what you are about to erase and let the user answer first. Every write answers `{ change, record }`: `change` is `{ id, table, record_id, verb, byline, before, after, created_at, undone_by, undoable, reason }` — who wrote it, the values before and after, and whether undo can reverse it (`reason` says why not) — and `change.id` is what undo takes."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"table":{"type":"string","description":"The table's id, as its definition names it: \"todo\", \"note\", or a table the user defined such as \"lesson\"."},"id":{"type":"string","description":"The record's id."},"scope":{"type":"string","enum":["this","all"],"description":"A repeating event only, and then required: \"this\" deletes the day the id names (a later day's id is <series>@<start>) into the bin and leaves the series; \"all\" deletes every day of it."}},"required":["table","id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "reorder_records",        title: "Reorder a table's records",        description: r#"Put records of one table in a new order, for a table with a manual order (its definition's `order` column); a table without one is refused. `ids` are the records in their new order: they take positions 1, 2, 3 and so on, and records not listed keep theirs. The change's `before` and `after` map each moved record's id to its old and new position; `record` is null."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"table":{"type":"string","description":"The table's id, as its definition names it: \"todo\", \"note\", or a table the user defined such as \"lesson\"."},"ids":{"type":"array","items":{"type":"string"},"minItems":1,"description":"Record ids in their new order."}},"required":["table","ids"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_groups",        title: "List groups",        description: r#"The groups (views) made of one table's records — Family among people, Weekend among todos, the open todos — in the order they were made; leave `table` out for every group of the database, each saying its `table`. A group is either records picked by hand or a live filter (`where`, as list_records reads it) whose records are whatever it finds when read; a record can be in several. Each group answers `{ id, name, table, count, top, where? }`: `count` is how many records it holds now, `top` its first three as list_records answers a record, and `where` the filter of a filter group. With `record`, each group also says `holds` — whether that record is in it (for a filter, whether it matches). Read a group's records with list_records `{ table, where: { group: id } }`. Every table that keeps records takes groups; a worked-out table (money views) is refused."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"table":{"type":"string","description":"The table whose records the group gathers, as its definition names it: \"person\", \"todo\", \"event\", \"goal\", or a table the user defined. Left out: every group of the database."},"record":{"type":"string","description":"A record id of that table: each group then says whether it holds this record. Needs `table`."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "create_group",        title: "Make a group",        description: r#"Make a named group (a view) of one table's records, when the user asks for one — picked by hand (make a Family group with Asha and Ben) or a live filter (a view of my open todos with priority 1). This is THE way a view is made, and Home can show it. `name` is the user's own word for it, one per table. Give EITHER `records` — the ids to put in it, in order (leave both out to start an empty hand-picked group) — OR `where` — a filter in list_records' where grammar (`{ column: value }`, `{ column: [values] }`, `{ column: { "present": true } }`), checked now (an unknown column or a value the column never holds is refused) and read live: a record made later that matches joins it, one that stops matching leaves. A filter matches stored values; for days relative to today use the shipped views (Today, Next up). Answers `{ change, group }`: `change.receipt.said` is what happened in the user's words, and `change.id` is what undo takes."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"table":{"type":"string","description":"The table whose records the group gathers, as its definition names it: \"person\", \"todo\", \"event\", \"goal\", or a table the user defined."},"name":{"type":"string","description":"The group's name, in the user's words."},"records":{"type":"array","items":{"type":"string"},"minItems":1,"description":"Record ids to put in the group, in order. Not with where."},"where":{"type":"object","description":"A live filter instead of records, in list_records' where grammar: column keys mapped to a value, a list of values, {\"values\": [...]} or {\"present\": true|false}. Not with records."}},"required":["table","name"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_group",        title: "Change a group",        description: r#"Change one group, by its id from list_groups — ONE thing per call: `name` renames it; `add` puts records in, after the last; `remove` takes records out (the records themselves are untouched); `order` lists members in their new order, and members not listed follow them as they stood; `where` replaces a filter group's filter. A filter group takes no add, remove or order, and a hand-picked group takes no where. Answers `{ change, group }`: `change.receipt.said` is what happened in the user's words, and `change.id` is what undo takes."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The group's id."},"name":{"type":"string","description":"The new name."},"add":{"type":"array","items":{"type":"string"},"minItems":1,"description":"Record ids to put in the group."},"remove":{"type":"array","items":{"type":"string"},"minItems":1,"description":"Record ids to take out of the group."},"order":{"type":"array","items":{"type":"string"},"minItems":1,"description":"Member record ids in their new order."},"where":{"type":"object","description":"A filter group's new filter, in list_records' where grammar."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "delete_group",        title: "Delete a group",        description: r#"Delete one group (view), by its id — hand-picked or filter. The records it held are untouched — only the group goes — and undo brings it back with its members or its filter. Answers `{ change, group: null }`."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The group's id."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_connections",        title: "List connections",        description: r#"Every connection in this database, optionally narrowed by kind. Answers connections with typed stored state, read timestamps, error, schedule, config and secret_id (id only). Credential-bearing config keys are removed recursively. Like devices and secrets, the list answers whole."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"kind":{"type":"string"}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "get_connection",        title: "Get a connection",        description: r#"One connection by id in this database, with typed stored state, read timestamps, error, schedule, config and secret_id (id only). Credential-bearing config keys are removed recursively. The store keeps current read state, not a history of read attempts."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string"}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "propose_connection_mapping",        title: "Propose a connection's mapping",        description: r#"For an MCP server connection (Connections tool), propose the mapping that makes it read: which of the server's tools to call, how often, and how each answer becomes rows of one table. Answers `{ connection, current, proposal: { mapping, installs, ready, note }, tools }`. For Cloudflare's API server the proposal is ready (zones and DNS records into the Domains tool); for any other server it is a skeleton per tool — fill each call's into, key, key_column and columns from the tool's description and inputSchema, drop the calls that are not reads, then keep it with set_connection_mapping. Refused until the connection is signed in, because its tools are only known then."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The connection's id."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "set_connection_mapping",        title: "Keep a connection's mapping",        description: r#"Keep the mapping an MCP server connection reads by — usually the proposal from propose_connection_mapping, changed or as it was. It replaces the connection's mapping. Checked first against this database's tables: every call's into is a table here (Domains' tables count before the tool is installed), every column is that table's, key_column is a text column, a link names a real table and column. A refusal names the call and column to fix. The serving Mac reads it at its next pass."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The connection's id."},"mapping":{"type":"object","description":"{ calls: [{ tool, args, every, into, rows, key, key_column, columns, paging? }] }, as propose_connection_mapping answers it."}},"required":["id","mapping"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "connect",        title: "Connect a mailbox, a calendar, Cloudflare or a tailnet",        description: r#"Connect a mailbox (kind mail, read over IMAP) or a calendar (kind calendar, read over CalDAV) with an app password the owner ALREADY filed in this database's vault: pass the secret's id, never the password — this tool takes no password and no token. The serving Mac's reader opens the secret itself. `reaches` is the address (it is written lower-case); `server` is only for a provider Cotton does not know: a mail host, or a calendar's https address. A Cloudflare account (kind cloudflare) connects the same way with an API token the owner filed in the vault as an API key: `reaches` is only their word for the account and may be left out, and the serving Mac lists the account's domains into the Domains tool, changing nothing at Cloudflare. Kind tailscale connects the household's tailnet: `reaches` is the tailnet's name (tail1234.ts.net, a domain, or the address a personal tailnet is named by) and `secret` a vault login holding its OAuth client — the client id as the username, the client secret as the password; with it every device tries the tailnet after the home network and before the relay. Refused by name: a secret id that is not a login or an API key in this database's vault (a login naming a client id, for a tailnet), a kind other than mail, calendar, cloudflare or tailscale, and a Gmail calendar — Google's calendar takes only Google's own sign-in, so it connects as a Google account. Connecting the same address again replaces the secret it reads with and keeps its other settings. Answers `{ connection: { id, kind, name, reaches, state }, note }`; the row is the one the phone's Connect… writes."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"kind":{"type":"string","enum":["mail","calendar","cloudflare","tailscale"],"description":"mail (IMAP), calendar (CalDAV), cloudflare (an account's domains) or tailscale (the household's tailnet)."},"reaches":{"type":"string","description":"The address, like you@example.org; for a tailnet, its name, like tail1234.ts.net."},"secret":{"type":"string","description":"The id of the vault secret (a login or an API key) that holds the app password; for a tailnet, the login holding its OAuth client."},"name":{"type":"string","description":"What the connection is called; the address when absent."},"server":{"type":"string","description":"Only for a provider Cotton does not know: the IMAP host, or the calendar's https address."}},"required":["kind","reaches","secret"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "link_records",        title: "Link a record to another",        description: r#"Point one link column of a record at another record: `column` must be a link column, and `target_id` must be a record of the table that column links to — or null to clear the link. Every write answers `{ change, record }`: `change` is `{ id, table, record_id, verb, byline, before, after, created_at, undone_by, undoable, reason }` — who wrote it, the values before and after, and whether undo can reverse it (`reason` says why not) — and `change.id` is what undo takes."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"table":{"type":"string","description":"The table's id, as its definition names it: \"todo\", \"note\", or a table the user defined such as \"lesson\"."},"id":{"type":"string","description":"The record's id."},"column":{"type":"string","description":"The link column's key."},"target_id":{"type":["string","null"],"description":"The id of the record to link to; null clears the link."}},"required":["table","id","column","target_id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "undo",        title: "Undo a change",        description: r#"Reverse one change a record verb made, by the change's id: a create is deleted, a delete restored, an update, link or reorder put back as it was. The undo is itself a change with your byline, and the change it reversed gets `undone_by`. Refused when the change was already undone, when a later change touched the same record or column, or when the record no longer holds what the change left — undoing then would overwrite a later edit. Answers `{ change, undone, record }`: the change the undo wrote, the change it reversed, and the record as it now stands (null after a reorder)."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"change_id":{"type":"string","description":"The change's id, from the change a record verb answered."}},"required":["change_id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_documents",        title: "List documents",        description: r#"The papers the user keeps — statements, bills, policies, letters, IDs — newest first. Each entry gives the id, what Cotton made of it (a type, who issued it, a one-line summary) and its status. `ready` means it was read and is searchable; `locked` means it is password-protected and Cotton could not open it, which you can fix with update_document; `failed` means reading broke and the file is still safe. Filter by docType, issuer or status to answer 'do I have my March Meridian Bank statement' without reading anything."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"docType":{"type":"string","enum":["bank_statement","card_statement","invoice","receipt","tax","id","insurance","medical","legal","ticket","statement_other","letter","manual","other"]},"status":{"type":"string","enum":["processing","summarizing","ready","locked","failed"]},"issuer":{"type":"string","description":"Who issued it, matched loosely — 'Meridian' finds 'Meridian Bank Ltd'."},"limit":{"type":"integer","minimum":1,"maximum":1000,"description":"Maximum documents to return (default 25)."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "search_documents",        title: "Search inside documents",        description: r#"Full-text search across every document AND the text of its pages, so a phrase that appears only INSIDE a statement is findable — this is the difference between finding the document called 'Meridian July' and finding the document that mentions a particular transfer. Returns the matching passage and the page it was on, which is often enough to answer without opening anything. A locked document has no page text yet, so it matches on its title alone."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"query":{"type":"string","description":"Words to look for. Supports quoted phrases and -exclusions."},"limit":{"type":"integer","minimum":1,"maximum":50,"description":"Maximum documents to return (default 20)."}},"required":["query"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "get_document",        title: "Get one document",        description: r#"One document in full: its type, issuer, summary, and the facts Cotton pulled out of it (account number, period, closing balance, due date — whatever the kind of paper carries). Set includeFileUrl to also get a link to the file itself, valid for five minutes; it is off by default because a link is a credential and most questions are answered by the summary and facts alone. The password is never returned. For the words on a page, use search_documents."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"documentId":{"type":"string","description":"The document's uuid."},"includeFileUrl":{"type":"boolean","description":"Also return a five-minute link to the file (the unlocked copy when there is one). Default false."}},"required":["documentId"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "get_document_bytes",        title: "Get a document's file as bytes",        description: r#"The document's file itself, carried inside the tool result as base64 — no URL and no fetch, so it works from a client whose sandbox cannot reach the web. Reach for it when you need the actual file: to copy it, edit it, or re-file a corrected version. For QUESTIONS about a document the summary, facts and page text answer far more cheaply, and files over 2 MB are refused — base64 in a conversation costs real context, so ask get_document with includeFileUrl for a five-minute link instead. Serves the unlocked copy when there is one; the password is never returned."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"documentId":{"type":"string","description":"The document's uuid."}},"required":["documentId"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "request_document_upload",        title: "Get a slot to upload a document",        description: r#"Step one of filing a NEW document: hand over the file's name, type, size and sha256, and get back a URL to PUT the bytes to plus the exact call to make afterwards. Bytes never travel through this conversation — a PDF turned into text here would cost more context than the whole job. If this workspace already has a file with that sha256 it says so and there is nothing to upload, which makes re-running a harvest free. Compute the sha256 over the raw file bytes."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"fileName":{"type":"string","description":"The file's own name, e.g. 'Meridian-Jul2026.pdf'."},"mime":{"type":"string","description":"e.g. 'application/pdf'."},"byteSize":{"type":"integer","minimum":1},"sha256":{"type":"string","description":"64 lowercase hex characters, over the raw file bytes."}},"required":["fileName","mime","byteSize","sha256"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "export_package",        title: "Export records as a Cotton package",        description: r#"Package records of this database as one Cotton package (.cottonpkg) — a zip of a manifest, one JSON Lines file per table in Cotton's own columns and record ids, and the pictures and files the records name — and file it as a document here. Answers the document's id, what each table held and any media key whose bytes the server did not have. A table a person made travels with its definition, so any Cotton database, Rigby's included, can import it with import_package. Identity and credential tables (tokens, devices, secrets, the vault) never travel."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"tables":{"type":"array","minItems":1,"items":{"oneOf":[{"type":"string"},{"type":"object","properties":{"table":{"type":"string"},"ids":{"type":"array","items":{"type":"string"}},"where":{"type":"object"}},"required":["table"],"additionalProperties":false}]},"description":"The tables to export, by the id a tool names them (\"todo\", \"person\", a table the user defined) — each a string, or {table, ids?, where?} to take only some records."},"where":{"type":"object","description":"For every table named as a plain string: stored column → a value, a list of values (any one), {\"values\": [..]} or {\"present\": true|false}; every entry must hold. Columns are the stored ones the package's JSON Lines carry."}},"required":["tables"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "import_package",        title: "Import a Cotton package",        description: r#"Import a document of this database that is a Cotton package (.cottonpkg) — one export_package filed, or one the owner brought from another database. Every record keeps its id and is written as an ordinary write of yours; a record this database already holds is changed only where it differs, so importing the same package twice changes nothing. Answers, per table, what was created, changed and left unchanged, and every record that could not be written with why."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"document":{"type":"string","description":"The id of the document that is the package."}},"required":["document"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "file_document",        title: "File a document you have uploaded",        description: r#"Step two of filing a NEW document, after request_document_upload and the PUT: this files the row and Cotton starts reading it — unlocking it if it is protected, pulling out its words, and writing a title, a summary, a type and its facts. Answers immediately with the filed document; the reading finishes on the server's own clock, so poll get_document if you need the profile. Filing the same sha256 twice returns the SAME document and reads nothing again, which is what makes re-running a harvest safe. It stays silent on the owner's phone unless you pass notify: true — one assistant filing thirty statements should speak once, in its own words, through notify_owner."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"stagedPath":{"type":"string","description":"The stagedPath request_document_upload gave you."},"fileName":{"type":"string","description":"The file's own name."},"mime":{"type":"string","description":"e.g. 'application/pdf'."},"byteSize":{"type":"integer","minimum":1},"sha256":{"type":"string","description":"64 lowercase hex characters, over the raw file bytes."},"title":{"type":"string","description":"Optional. A title you already know; otherwise Cotton writes one."},"docType":{"type":"string","enum":["bank_statement","card_statement","invoice","receipt","tax","id","insurance","medical","legal","ticket","statement_other","letter","manual","other"],"description":"Optional. Only when you are certain — Cotton classifies it otherwise."},"notify":{"type":"boolean","description":"Tell the owner's phone about THIS document when it finishes. Use it for the single document they asked for by name, never for a harvest."}},"required":["stagedPath","fileName","mime","byteSize","sha256"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_document",        title: "Correct a document, or open a locked one",        description: r#"Two jobs in one tool. Correct what Cotton wrote — a wrong type, a missing issuer, a title the user would actually recognise. AND open a locked document: pass passwordCandidates and Cotton tries each one, then reads the document properly if any works. That second job is the point of this tool during a mailbox harvest — the covering email usually says how the password is built ('your name in caps and your date of birth'), so work out the spellings and send them all at once. Each wrong guess costs about half a second, and the answer says whether it opened."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"documentId":{"type":"string","description":"The document's uuid."},"title":{"type":"string"},"docType":{"type":"string","enum":["bank_statement","card_statement","invoice","receipt","tax","id","insurance","medical","legal","ticket","statement_other","letter","manual","other"]},"issuer":{"type":"string"},"summary":{"type":"string"},"passwordCandidates":{"type":"array","items":{"type":"string"},"maxItems":25,"description":"Passwords to try, in the order most likely first. At most 25; sending more is refused rather than trimmed, so you always know exactly which ones were tried."}},"required":["documentId"],"additionalProperties":false}"#,        outside_write_lock: true,    },    ToolDef {        name: "delete_document",        title: "Delete a document",        description: r#"Move one document to the bin, its file with it: hidden from every read here, and restore_from_bin {kind: "document"} brings it back. Only erasing it from the bin (empty_bin) removes it and its file for good — until then its file still takes storage. Requires confirm: true, so it cannot happen by accident. A statement Cotton has already read is refused, because its entries are the evidence behind transactions in the user's money — remove those transactions first (delete_transaction), or keep the paper. THIS IS THE OWNER'S OWN CALL. Prefer update_document for anything short of the user actually wanting the paper gone."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"documentId":{"type":"string","description":"The document's uuid."},"confirm":{"type":"boolean","description":"Must be true."}},"required":["documentId","confirm"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "notify_owner",        title: "Tell the owner something",        description: r#"Send the user a notification on their phone. This is your ONLY way to reach them directly, so spend it on what a person actually wants to be interrupted for: the summary at the end of a long job ('filed 30 statements, 4 still need passwords'), or one thing that needs their decision. Documents you file do not notify them by themselves — that is deliberate, and this is why. One message per job, not one per document. Never about chat messages, statuses or posts: Cotton does not notify about WhatsApp or Instagram, so a connection that read chats in the last day is refused — say it in your reply."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"title":{"type":"string","description":"A few words. Shown as the notification's heading."},"body":{"type":"string","description":"One or two sentences, written to be read on a lock screen."},"documentId":{"type":"string","description":"The document this is about, if it is about one — tapping the notification opens it."}},"required":["title","body"],"additionalProperties":false}"#,        // OUTSIDE THE LOCK, and it is the one tool here that writes nothing to        // the person's file at all — every row this ends up writing is written        // by the RAIL, which takes the workspace's write lock itself. Held        // inside it, this tool asked for a lock its own caller was holding, so        // the rail could only defer and the assistant got `queued` instead of        // an outcome it can act on ("no device is registered — say it in your        // reply instead"). Cotton note "The Rust server — what runs inside CottonDB for Mac".        outside_write_lock: true,    },    ToolDef {        name: "brief",        title: "The memory briefing",        description: r#"The owner's standing knowledge for this session, compiled from their memory: the matched project's entries in the owner's own order — the procedures linked to it (one line each: the name, the trigger to match a task against, and the note id to read it by), the last five sessions across all their machines, and what needs their attention. Memory belongs to projects: there is no project-independent layer, so call it at the START of working with the git remote you are working in (repoUrl) or the project slug (project), plus your hostname (machine). A repo bound to no project gets a two-line answer saying how to find one (list_projects, then brief { project } or get_project). Entries are addressed by [slug]: cite them, never restate them. Every entry is the owner's own words — technical facts about the code live in the repo, not here. Compiled and budgeted — over budget it sheds procedure lines first, then recent sessions, and only then whole entries from the end of the owner's order — never part of one — with a line saying how many were left out; `recall` is the full set."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"repoUrl":{"type":"string","description":"The git remote of the repository this session works in, any spelling (https, ssh, scp). Resolves which projects brief."},"project":{"type":"string","description":"A project slug from list_projects, when you know it — overrides repoUrl resolution."},"machine":{"type":"string","description":"This machine's hostname. Machine-scoped memories brief only on their machine."},"budgetTokens":{"type":"integer","minimum":400,"maximum":6000,"description":"Token budget for the briefing (default 4000). Over it, whole entries are left out from the end of the owner's order and a line counts them."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "recall",        title: "Recall memory entries",        description: r#"The owner's memory beyond the briefing — the owner's own words, nothing else. `q` is a ranked full-text search — reach for it BEFORE assuming you do not know what the owner thinks (the ruling behind a habit, a standing preference, the current state of their work). With `project`, that project's entries in ITS order — pinned first, then the owner's arrangement; without, every entry newest-first, each carrying `projects: [{ slug, pinned, position }]` — the projects it briefs in and how it is arranged in each. Technical facts are not here: they live in the repo, next to the code that can invalidate them. Default: active entries."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"q":{"type":"string","description":"Search terms — full-text, ranked. A query with no searchable words falls back to a substring match."},"project":{"type":"string","description":"A project slug from list_projects — that project's entries in its own order. Omit for every entry, newest-first."},"status":{"type":"string","enum":["active","archived","all"],"description":"Default active."},"limit":{"type":"integer","minimum":1,"maximum":300,"description":"Maximum entries to return (default 100)."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "remember",        title: "Remember a fact",        description: r#"Transcribe one thing the OWNER SAID into their memory — RECONCILED against what is already there, so duplicates never reach the feed. Memory is the owner's mind: every entry is the owner's own words, quoted or faithfully condensed; nothing you inferred on your own goes in, and technical facts about code never do (they live in the repo — an AGENTS.md partial, the app's CLAUDE.md, a runbook, a skill, a guard). The SENTENCE is the memory: one imperative, factual line (≤280 chars); a longer thought is several thoughts — split it into separate calls. Memory has no categories: what the entry is, is the sentence. Every write lands live. An entry that is only true for a while SAYS SO IN ITS OWN SENTENCE — "… — valid until 24 Oct", "… until the app launches" — and when you read one whose date has passed you archive it with memory_archive; there is no dated flag and nothing comes back on a schedule. A memory belongs to projects, so project is REQUIRED: the entry briefs in that project, in its order — except an Owner entry, what is true of the owner whatever the project, written with no project in their personal database and briefed first in every brief (300 tokens, refused past that); the same sentence can later be linked into other projects with link_to_project (kind memory) — never written twice. Pin it when the owner wants every assistant working in that project to read it first. Give source when you have one (a PR or commit URL, session:<tool>:<id>, file:<path>, note:<id> for long source material you filed as a note). The reconcile loop: when similar entries exist the call answers { needsDecision, candidates } and writes NOTHING — read them and call again with decision: { action: "update", target: <slug> } to correct one, { action: "supersede", target } when the new fact replaces it, or { action: "add" } when it is genuinely different. An entry that already says the same thing answers { action: "noop" } — or, when it lives in other projects but not this one, { action: "linked" }: the existing entry gains this project and nothing else is written. Never store credentials; store a pointer to where they live."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"title":{"type":"string","description":"The entry — one imperative, factual sentence in the owner's words, ≤280 chars."},"project":{"type":"string","description":"The project slug, from list_projects — where the entry briefs. Required, except for an Owner entry. A fact that holds in several projects is remembered once and linked into the others with link_to_project."},"owner":{"type":"boolean","description":"An Owner entry: what is true of the owner whatever the project — it opens every brief. Written with no project, in the owner's personal database (database: their personal database); owner: true says so explicitly."},"source":{"type":"string","description":"Provenance: a URL, session:<tool>:<id>, file:<path>, note:<id>, or human."},"pinned":{"type":"boolean","description":"Pin it in this project: a pinned entry briefs first in that project's list."},"machine":{"type":"string","description":"Hostname, when what the owner said holds on one machine only."},"slug":{"type":"string","description":"Bring a stable slug (kebab, ≤64) when you have one; otherwise it is minted from the title."},"decision":{"type":"object","description":"Your answer to a needsDecision reply.","properties":{"action":{"type":"string","enum":["add","update","supersede","noop"]},"target":{"type":"string","description":"The candidate's slug, for update and supersede."}},"required":["action"],"additionalProperties":false}},"required":["title"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "log_session",        title: "Log this session",        description: r#"Record what this session did, so the next session on any machine learns it from the briefing instead of from a transcript. Idempotent: the same (tool, externalId) updates the one row. On a Mac with the hooks installed the row already exists — the SessionStart hook registers it with the tool's own title and model, and the Stop hook logs every turn of the conversation (the owner's prompts AND the assistant's replies, each with its role) — so a session calls this to add what only it knows: a summary (the latest wins) or a title. Use the externalId and machine the hooks use (the id is the tool's own session id, the one the SessionStart hook registered; machine is the hostname, `hostname -s`); a hand-picked id or a guessed machine name creates a second, phantom session on a machine that does not exist. A run with no machine of its own (a claude.ai cloud session) passes machine "cloud". Summary and prompts are redacted before they are written; PR and commit links in the summary are kept as shipped. The transcript itself is never sent — transcriptRef is a pointer. Send `tasks` to mirror your own task list onto the session row, so the owner can see "4/6" on the card and open the list: the array REPLACES whatever the row held, so send the whole list every time and send an empty array when there is nothing left."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"tool":{"type":"string","enum":["claude-code","codex","kimi","gemini","opencode","other"]},"externalId":{"type":"string","description":"The tool's own session id — the one the SessionStart hook named, never the claude.ai session URL id."},"sessionId":{"type":"string","description":"The Cotton row this session IS, when something told you which one — on a Mac the helper puts it in the agent's environment as COTTON_SESSION_ROW_ID and the hooks pass it here, so a session Cotton started stays one row from its first hook. Always the FULL row id, never a prefix: an id this database does not hold fails the call, and a row already logging another session is left alone."},"machine":{"type":"string","description":"This machine's hostname (`hostname -s`), exactly as the hooks report it; \"cloud\" for a run with no machine. Never a guess."},"repoUrl":{"type":"string","description":"The git remote, any spelling — resolves the project."},"branch":{"type":"string"},"cwd":{"type":"string"},"project":{"type":"string","description":"A project slug, when you know it — overrides repoUrl resolution."},"startedAt":{"type":"string","description":"ISO-8601; defaults to lastActiveAt on first sight."},"lastActiveAt":{"type":"string","description":"ISO-8601 — now."},"endedAt":{"type":"string","description":"ISO-8601, when the session is over."},"title":{"type":"string","description":"The tool's session title (≤140)."},"titleIfEmpty":{"type":"string","description":"The first line of the first prompt (≤140) — written only when this session has no title yet. Pass `title` instead to rename one deliberately."},"summary":{"type":"string","description":"The last assistant recap (≤2000); the latest wins."},"model":{"type":"string","description":"The model id the tool reports (claude-fable-5-1), ≤80; the latest wins."},"turnCount":{"type":"integer","minimum":0,"description":"Set explicitly; otherwise each call counts one turn."},"prompts":{"type":"array","description":"The turns since the last call — what the owner typed and what the assistant said back, in order. The parameter keeps its historical name; a turn without a role is the owner's.","items":{"type":"object","properties":{"seq":{"type":"integer","minimum":0,"description":"Position in the session — any non-negative integer, unique per session across both roles."},"ts":{"type":"string","description":"ISO-8601."},"role":{"type":"string","enum":["user","assistant"],"description":"Who said it; defaults to user."},"text":{"type":"string","description":"≤8000; redacted on arrival."}},"required":["seq","ts","text"],"additionalProperties":false}},"transcriptRef":{"type":"string","description":"box:<machine>:<path> — a pointer, never content."},"tasks":{"type":"array","description":"Your own task list, mirrored onto the session row. The whole list every time: what you send REPLACES what the row held, and an empty array clears it. Omit the parameter entirely to say nothing about tasks.","items":{"type":"object","properties":{"seq":{"type":"integer","minimum":0,"description":"Position in the list, from 0 — unique per session."},"text":{"type":"string","description":"The task, in your own words (≤500; truncated, never refused)."},"state":{"type":"string","enum":["open","active","done"],"description":"Defaults to open."}},"required":["seq","text"],"additionalProperties":false}}},"required":["tool","externalId","machine","lastActiveAt"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_sessions",        title: "List sessions",        description: r#"Recent sessions across every machine and tool, newest first — what happened elsewhere, without syncing chats. A session that has not started yet is here too, at `state: "queued"`: `prompt` is what it will open with, `requestedDeviceId` is the Mac the owner asked for (null means any Mac) and `holdReason` is the sentence saying why it is still waiting — no Mac signed in, every Mac full, or the chosen one not picking it up. Filter by project or machine, or narrow to a window with `since`; `q` searches what the owner typed (full-text over prompts) and returns the sessions that hit, with the matching snippets. `hostOwned` says whether Cotton holds the session's terminal or merely adopted it from the agent's own transcript. Every row says what KIND of session it is: a `conversation` is a project's one standing conversation and a `thread` is everything else, with `parentSessionId` naming the conversation that opened it. Pass `parent` to list one conversation's threads, or `kind` to list only one or the other. `tasksDone` and `tasksTotal` are the task list the session mirrored onto its own row — 0 and 0 for a session that mirrored none; get_session has the list itself. A full page carries `nextCursor`: pass it back as `cursor` with the same filters to read the next one."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"limit":{"type":"integer","minimum":1,"maximum":5000,"description":"Default 20."},"project":{"type":"string","description":"A project slug, or \"none\" for sessions assigned to no project."},"machine":{"type":"string"},"q":{"type":"string","description":"Search the prompts."},"since":{"type":"string","description":"ISO-8601. Only sessions that did something at or after this instant (their last activity, whether or not they have ended). Use it for \"what has been running this week\" rather than raising the limit."},"parent":{"type":"string","description":"A conversation's session id — only the threads it opened. This is how a project conversation reads its own work."},"kind":{"type":"string","enum":["conversation","thread"],"description":"Only the project conversations, or only the threads."},"cursor":{"type":"string","description":"nextCursor from the previous page, passed back unchanged with the same filters. Omit it for the first page."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "create_session",        title: "Open a session",        description: r#"Open a coding session — a THREAD — on one of the owner's Macs, and answer with the row it is queued as. Use it when the owner has asked for a piece of work that somebody has to actually do: write the thread a prompt it can work from on its own, because it starts with that and nothing else. The session is queued, not started: Cotton places it on whichever Mac is free (or the one you named), and the Mac's own client picks it up. `holdReason` on the row says why a queued session is still waiting — no Mac signed in, every Mac full — and get_session reads it back. Pass `parentSessionId` when you are a project's standing conversation, so the thread hangs off you and list_sessions { parent } finds it; your own row id is in the prompt you were opened with. Do not open a thread for something you can answer yourself, and never open two for one piece of work."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"project":{"type":"string","description":"The project slug, from list_projects — which project the work belongs to, and where the checkout comes from."},"prompt":{"type":"string","description":"What the session opens with. Write it so a session that knows nothing about this conversation can work from it (≤8000)."},"title":{"type":"string","description":"What the card says (≤140). Defaults to the prompt's first line."},"parentSessionId":{"type":"string","description":"The conversation opening this thread — your own session row id, which your standing prompt names. Omit it when nothing opened this."},"todoId":{"type":"string","description":"The todo this session works on, when there is one; the session keeps a link to it."},"todoDatabase":{"type":"string","description":"The id of the database that todo is in, when it is not your personal database. The session itself always lives in your personal database."},"tool":{"type":"string","enum":["claude-code","codex"],"description":"Defaults to claude-code."},"branch":{"type":"string","description":"The git branch the Mac checks out."}},"required":["project","prompt"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "get_session",        title: "Read one session",        description: r#"One session, whole: what it is doing (`state`), what it is waiting on, what it last said, the prompt it opened with, its recap, the Mac it is on, and the sentence on `holdReason` or `error` if something stopped it. `prompts` is its last twenty turns, oldest first — the owner's and the assistant's, each with its role — and `tasks` is the task list it mirrored onto its row, in its own order, with `tasksDone` and `tasksTotal` beside it. `kind` says whether this is a project's standing conversation or a thread, and `parentSessionId` names the conversation that opened it. Read this before reporting on a thread; it is the summary, not the transcript, and the transcript stays on the Mac that made it."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"sessionId":{"type":"string","description":"The session's id, as list_sessions and create_session answer with."}},"required":["sessionId"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "open_project_conversation",        title: "Open a project's conversation",        description: r#"The project's ONE standing conversation — the session the owner talks to about that project, which opens threads for the work. Answers the existing row if the project has one and opens it if it does not; `created` says which happened. A project has at most one, so calling this twice is safe and returns the same id both times. Use it to find a project's conversation, or to give a project its conversation for the first time."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"project":{"type":"string","description":"The project slug, from list_projects."}},"required":["project"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_devices",        title: "List the devices",        description: r#"Every phone and Mac approved to open this database, newest approval first: its name, what it is, the version it is running right now, when it joined and which device approved it, and — for one that has been cut off — when and why. The version is kept current: a device says what it is on every request it makes, and its row is rewritten on the day that changes. A revoked device stays in the answer and says so; re-admitting a key is a new approval, never an undo. A Mac also says its free disk, load and memory as of `sampledAt`. This is a READ. Nothing over MCP approves, renames or revokes a device: joining is a person comparing six digits on two screens, and revoking is a confirmed red row in the owner's own app."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"includeRevoked":{"type":"boolean","description":"Default true. False lists only the devices that may open the database right now."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_keep_rules",        title: "List what a phone keeps",        description: r#"What one phone keeps of this database, one line per rule in words — "Mail: everything", "Album Goa: always" — with Cotton's own defaults marked as defaults until somebody changes them. A Mac keeps every row; its answer says what it keeps of its files (`keeps`: everything, rows_only, or per_tool when Storage was set tool by tool) and whether it serves now (a serving Mac keeps everything whatever it says). `narrowing` says whether a phone may yet be set to keep less than everything of a table; while it is false only "everything" is offered for a table. Pass the device's key or its id from list_devices."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"device":{"type":"string","description":"The device's key, or its id from list_devices."}},"required":["device"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "set_keep_rule",        title: "Set what a phone keeps",        description: r#"Change what one phone keeps: a table kept `all` (or, once `narrowing` is on, `none` or `days:N`), or a group or a record kept `always`; or, for a Mac, kind `bytes` with rule `everything` or `rows_only` (files fetched when opened and gone 30 days later — the Mac's Storage rules for every tool with files). Setting the same rule again changes nothing. A Mac keeps every row, so any other rule for one is refused; until `narrowing` is on, a rule that keeps less than everything is refused with a sentence saying it comes after the next update. THIS IS THE OWNER'S OWN ACT AND YOU CANNOT MAKE IT: what a phone holds is the person's choice about their own device."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"device":{"type":"string","description":"The device's key, or its id from list_devices."},"kind":{"type":"string","enum":["table","group","record","bytes"]},"target":{"type":"string","description":"A table (cotton_email_threads, cotton_stories), a group's or album's id, or a record as <table>:<id>. Not used for bytes."},"rule":{"type":"string","description":"For a table: all, none or days:N. For a group or a record: always. For a Mac's bytes: everything or rows_only."}},"required":["device","kind","rule"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "clear_keep_rule",        title: "Stop a phone keeping something",        description: r#"Take back one of a phone's rules: a group or a record it kept always goes back to what its table keeps, and a table goes back to Cotton's default; a Mac's `bytes` goes back to everything. THIS IS THE OWNER'S OWN ACT AND YOU CANNOT MAKE IT."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"device":{"type":"string","description":"The device's key, or its id from list_devices."},"kind":{"type":"string","enum":["table","group","record","bytes"]},"target":{"type":"string","description":"What the rule is about, as set_keep_rule named it. Not used for bytes."}},"required":["device","kind"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "set_audience",        title: "Set who may hold a record",        description: r#"Hold one record of a shared database for the owner alone (`only_you`), or release it to everyone in the database (`everyone`). An only-you record never reaches another person's device: not the record, not a comment or link naming it. Only-you is chosen before anyone else can hold the record — a record another person's device may already hold is refused. Releasing is final: the record travels to every member from then on. A personal database's records carry no audience (nobody else enters one). Setting the audience a record already has changes nothing. THIS IS THE OWNER'S OWN ACT AND YOU CANNOT MAKE IT: who may see a record is the person's choice, and a release by anybody else is refused."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"table":{"type":"string","description":"The record's table: a definition's id (todo, note) or the table it is stored in."},"id":{"type":"string","description":"The record's id."},"audience":{"type":"string","enum":["only_you","everyone"]}},"required":["table","id","audience"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_projects",        title: "List projects",        description: r#"The workspace's projects: slug, name, description, the git remotes that resolve to each, status, the brand kit where one is set, and a count of what is linked to each (chats, people, notes, todos, meetings, documents, …). A project is the owner's working context for one piece of work — read this to learn the vocabulary before get_project, link_to_project or remember."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "get_project",        title: "A project's working context",        description: r#"Everything one project gathers, in one call: its description and repos, then compact rows for every linked chat thread, email thread, person, note, procedure (a note whose first line names the trigger a session matches on — read one with get_record when a task matches it), todo (split open vs closed), event, document and transaction — each with the short note its link carries ("the main group chat", "superseded by the v2 contract") — plus the project's memory entries and its recent sessions. Call it when a conversation is about a project, or at the start of a session working on one; then drill in with the per-record tools (read_message_thread, read_email_thread, get_document, get_meeting, …). Counts state the whole membership; each group carries at most 50 rows. It also totals the money filed under the project — what came in, what went out, and the net, and answers the project's brand kit: its colours, fonts, voice, tagline and links, plus `brandAssets` — the logo, dark logo, wordmark and icon files linked to it."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"slug":{"type":"string","description":"The project's slug, from list_projects."},"includeBrandAssetUrls":{"type":"boolean","description":"Mint a short-lived download link for each brand asset (logo, icon, wordmark). Off by default: the links are credentials, and most calls only want the palette and the type. The asset ids work with get_document and get_document_bytes either way."}},"required":["slug"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "create_project",        title: "Create a project",        description: r#"Start a new project — the working context for one piece of work (a client engagement, a build, a screenplay's production). Give it a slug (short, stable, lowercase), a name, and a description: the paragraph an assistant reads first, saying what this project IS and where it stands. Then link what belongs to it with link_to_project, and bind the git repos that should brief it (repos here or update_project later). Create one when the owner starts something new; do not create one per conversation — list_projects first."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"slug":{"type":"string","description":"1-64 chars of a-z, 0-9 and dashes, starting alphanumeric — e.g. \"pyro\"."},"name":{"type":"string","description":"The display name."},"description":{"type":"string","description":"What this project is and where it stands — the first thing an assistant reads. Keep it current with update_project as the work moves."},"repos":{"type":"array","items":{"type":"string"},"description":"Git remotes whose sessions should brief this project."},"template":{"type":"string","enum":["cab-driver","delivery-partner","small-seller"],"description":"Start the project from a profession's template, each seeding the todos and how they repeat, and a money account: \"cab-driver\" for the papers that expire, the vehicle checks and the fare cash; \"delivery-partner\" for the payouts to check, the bike to keep running and the papers to renew; \"small-seller\" for the orders, stock, costs and the licence. Without a description of your own, the template's is used."}},"required":["slug","name"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_project",        title: "Update a project",        description: r#"Change a project's name or description, archive or reactivate it (status), or edit the repos it briefs for. A project's repo list IS the mechanism behind "which project does this session get": `brief` and `log_session` resolve a project by matching the caller's git remote against that list, so a project no repo points at briefs nobody and collects no session log. Send `repos` to replace the whole list, or `addRepos` / `removeRepos` to edit it in place. Every spelling of a remote is stored as one (`https://github.com/org/repo`, `git@github.com:org/repo.git` and `.../repo.git` are the same repo), so adding one twice is a no-op and removing it by another spelling still works. Send `brand` to set the project's brand kit — its colours, fonts, voice, tagline and links — or null to clear it; the logo files themselves are linked documents, not fields here. Keep the description current — it is what every future session reads first."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r##"{"type":"object","properties":{"slug":{"type":"string","description":"The project's slug, from list_projects."},"name":{"type":"string","description":"A new display name for the project."},"description":{"type":"string","description":"The replacement description. An empty string clears it."},"status":{"type":"string","enum":["active","archived"],"description":"archived hides the project and its briefing; active brings an archived one back. Links and memory entries stay put either way."},"repos":{"type":"array","items":{"type":"string"},"description":"Replace the whole list with these remotes. An empty array unlinks the project from every repo."},"addRepos":{"type":"array","items":{"type":"string"},"description":"Bind these remotes, keeping the ones already bound."},"removeRepos":{"type":"array","items":{"type":"string"},"description":"Unbind these remotes; one that is not bound is ignored."},"brand":{"type":["object","null"],"description":"The project's brand kit, replacing whatever is there: colours (name plus a hex like #1f2933, at most 12), fonts (role display, body or mono, plus a family and an optional source, at most 6), voice (how this project sounds, up to 2000 characters), an optional tagline and optional links. Send null to clear it. The LOGO FILES are not set here: file the image with file_document, then link_to_project with the note logo, logo-dark, wordmark or icon.","properties":{"colors":{"type":"array","maxItems":12,"items":{"type":"object","properties":{"name":{"type":"string","description":"What the owner calls it — Ink, Field."},"hex":{"type":"string","description":"#rgb, #rrggbb or #rrggbbaa."}},"required":["name","hex"],"additionalProperties":false}},"fonts":{"type":"array","maxItems":6,"items":{"type":"object","properties":{"role":{"type":"string","enum":["display","body","mono"]},"family":{"type":"string","description":"The typeface — Inter, Fraunces."},"source":{"type":"string","description":"Where to get it: a foundry page, a specimen, a licence."}},"required":["role","family"],"additionalProperties":false}},"voice":{"type":"string","maxLength":2000,"description":"How this project sounds, in the owner's own words."},"tagline":{"type":"string","maxLength":200},"links":{"type":"array","maxItems":12,"items":{"type":"object","properties":{"label":{"type":"string"},"url":{"type":"string","description":"Starts with http:// or https://."}},"required":["label","url"],"additionalProperties":false}}},"additionalProperties":false}},"required":["slug"],"additionalProperties":false}"##,        outside_write_lock: false,    },    ToolDef {        name: "link_to_project",        title: "Link records to a project",        description: r#"File records under a project — a chat thread, person, note, journal entry, todo, event, document, transaction, or a photo album — so get_project gathers them. One record can belong to several projects (the owner's chat with a collaborator genuinely spans the projects they work on together); linking again is safe. The optional note per record says what standing the record has in THIS project ("the main group chat", "superseded by the v2 contract — kept for reference"): omit note to leave an existing note alone, send a string to set or replace it, and send null to clear it. Individual messages are never linked: link the thread, context does the rest. A memory entry links here too (kind memory, the entry's id from recall): it joins the tail of the project's list and briefs there from then on; linking an ARCHIVED entry restores it — a home is what brings a dropped entry back. `pinned` on a memory record pins it in that project (memory only; a new link is unpinned)."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"project":{"type":"string","description":"The project's slug, from list_projects."},"records":{"type":"array","minItems":1,"maxItems":50,"items":{"type":"object","properties":{"kind":{"type":"string","enum":["thread","email_thread","person","note","journal","todo","event","document","transaction","photo","video","memory","call","album"]},"id":{"type":"string","description":"The record's id."},"note":{"type":["string","null"],"maxLength":500,"description":"What this record is to this project — shown wherever the link shows. Omit it to leave an existing note alone; pass null to clear one. On a document, the exact notes logo, logo-dark, wordmark and icon also fill that slot of the project's brand kit."},"pinned":{"type":"boolean","description":"MEMORY ONLY: pin the entry in this project — a pinned entry briefs first in that project's list. Omit it to leave an existing pin alone; a new link is unpinned. Any other kind naming it is refused."}},"required":["kind","id"],"additionalProperties":false}}},"required":["project","records"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "unlink_from_project",        title: "Unlink records from a project",        description: r#"Remove records from a project's working context. The records themselves are untouched — only the membership goes; a record that was not linked reports so and nothing errors, so re-running is safe. One refusal, by design: a memory entry always has a project, so an unlink that would leave one with none is refused and nothing in the call is unlinked — link it into another project first, or use memory_archive, which is how an entry is retired and keeps its links."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"project":{"type":"string","description":"The project's slug, from list_projects."},"records":{"type":"array","minItems":1,"maxItems":50,"items":{"type":"object","properties":{"kind":{"type":"string","enum":["thread","email_thread","person","note","journal","todo","event","document","transaction","photo","video","memory","call","album"]},"id":{"type":"string","description":"The record's id."}},"required":["kind","id"],"additionalProperties":false}}},"required":["project","records"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "memory_update",        title: "Update a memory entry",        description: r#"Correct or evolve one entry, addressed by slug or id. Send only the fields that change: the sentence (title), its source, its machine scope. An expiry belongs IN the sentence ("… — valid until 24 Oct"), never in a flag beside it. Every prior state is version-snapshotted with restore behind it. `pinned` is PER PROJECT: pass project with it to pin or unpin the entry in that project's list (the sentence is untouched). Re-homing an entry is link_to_project / unlink_from_project, like any record."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"slug":{"type":"string"},"id":{"type":"string","description":"The entry's uuid, instead of slug."},"project":{"type":"string","description":"With pinned: the project whose list the pin applies to."},"title":{"type":"string"},"source":{"type":"string","description":"Provenance: a URL, session:<tool>:<id>, file:<path>, note:<id>, or human."},"machine":{"type":["string","null"],"description":"New hostname scope, or null to brief everywhere."},"pinned":{"type":"boolean","description":"Pin or unpin the entry in `project`'s list — pinned entries brief first there."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "memory_reorder",        title: "Reorder a memory entry",        description: r#"Move one entry in the owner's own order FOR ONE PROJECT — the order that project's page shows, the briefing renders and every assistant reads there; the same entry is arranged separately in each project it briefs in. Address the entry by slug or id, name the project, and say where it goes: `after` names the entry it should follow, `before` names the entry it should precede; give neither to send it to the head of that project's list. Pinned entries always read first, whatever their order among themselves. Only ever call this when the owner has told you where they want something — arranging their memory is their act, not a tidy-up you perform."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"slug":{"type":"string"},"id":{"type":"string","description":"The entry's uuid, instead of slug."},"project":{"type":"string","description":"The project whose list is being arranged. Required."},"after":{"type":"string","description":"The slug of the entry this one should follow, in that project's list."},"before":{"type":"string","description":"The slug of the entry this one should precede, in that project's list."}},"required":["project"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "memory_archive",        title: "Archive a memory entry",        description: r#"Retire an entry that no longer holds (work shipped, a ruling was superseded, the owner changed their mind) — everywhere, in one call. Archived entries leave every briefing but keep their history, comment threads and project links; give the reason and it lands as a comment on the entry so the owner sees why it went. To take an entry out of ONE project, unlink_from_project it instead."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"slug":{"type":"string"},"id":{"type":"string"},"reason":{"type":"string","description":"Why it no longer holds."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_calls",        title: "List calls",        description: r#"The user's phone calls, newest first — cellular, FaceTime and the WhatsApp calls their phone logged, read off their own devices. Each row says who the call was with (their name when the number is one the user knows, the number itself when it is not), which way it went, whether it was answered, when it started and how long it lasted. This is a record of calls that already happened: Cotton neither places calls nor edits the log. Use the filters rather than paging everything — `personId` for one person's calls, `project` for the calls of everyone working on something, `since`/`until` for a period, `provider` for one carrier or app, `direction` and `outcome` to answer "did they call me back" or "what did I miss". What was actually SAID on a call is never in the log; get_call expands one."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"personId":{"type":"string","description":"Only calls with this person — an id from list_people or search_records."},"project":{"type":"string","description":"Only calls this project holds: the ones explicitly linked to it, plus the calls of every person linked to it. The project's slug."},"since":{"type":"string","description":"ISO-8601 instant. Only calls that started at or after it."},"until":{"type":"string","description":"ISO-8601 instant. Only calls that started at or before it."},"provider":{"type":"string","description":"How the call was placed: cellular, facetime_audio, facetime_video, whatsapp, or the app's bundle id for anything else."},"direction":{"type":"string","enum":["in","out"],"description":"in for a call the user received, out for one they placed."},"outcome":{"type":"string","enum":["answered","missed","cancelled","failed"],"description":"How it ended. A declined call cannot be told apart from a missed one in the phone's own log, so both read as missed."},"limit":{"type":"integer","minimum":1,"maximum":5000,"description":"Maximum calls to return (default 50)."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "get_call",        title: "Get a call",        description: r#"One call by id, with where the record came from: which device read it, the id that device's own log gave it, and whatever else that log carried with no field of its own. Everything a list row says, plus the provenance. The id comes from list_calls, search_records or get_project. What was said on the call is not here and never will be — a phone's log records who, when and how long, and nothing else; read the comments on it for that."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The call's id, from list_calls."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_photos",        title: "List photos",        description: r#"The user's photos, newest first by when each was taken. A photo is one picture wherever it came from — a chat, the share sheet, their phone's library, or their Apple Photos library imported from the Mac — and the same picture seen in several of those is ONE photo whose sightings list every place. Each carries its caption (the user's own words), its description (one or two sentences the server wrote from looking at the picture), when it was taken, its size, the place it was taken when known, its subtypes (screenshot, selfie, live, panorama…), whether it is a favourite, and the names of the people in it. Use the filters to answer a real question rather than paging everything: `thread` for one chat's pictures, `since`/`until` for a period, `person` (an id from list_people) for the pictures somebody is in, `withPeople` for pictures with anybody in them, `screenshots` for screenshots, `favourite`, `place` (a city, a country, a venue), `label` (a scene label such as `dog` or `beach`), `reviewed: true` for the ones already flagged for the user to look at again, `described: false` for pictures nothing has described yet. Start here for a photo's id; get_photo expands one, and get_photo_bytes hands you the picture itself."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"project":{"type":"string","description":"Only photos linked to this project — its slug or uuid."},"thread":{"type":"string","description":"Only photos that arrived in this chat — the chat's uuid."},"since":{"type":"string","description":"ISO-8601 instant. Only photos taken at or after it."},"until":{"type":"string","description":"ISO-8601 instant. Only photos taken at or before it."},"reviewed":{"type":"boolean","description":"true for photos carrying a review note, false for the ones carrying none."},"described":{"type":"boolean","description":"true for photos that already have a description, false for the ones still waiting on one."},"person":{"type":"string","description":"Only photos a face resolved to this person — their id from list_people."},"withPeople":{"type":"boolean","description":"true for photos with at least one face in them (named or not), false for photos with none."},"favourite":{"type":"boolean","description":"true for the user's favourites (as marked in Apple Photos), false for the rest."},"utility":{"type":"boolean","description":"true for pictures of information — receipts, documents, whiteboards, screens of text — as the Mac's analysis judged them; false for photographs. A picture nothing has analysed yet matches neither."},"screenshots":{"type":"boolean","description":"true for screenshots only."},"place":{"type":"string","description":"Only photos taken somewhere whose name, city, region or country contains this text (case-insensitive)."},"label":{"type":"string","description":"Only photos carrying this scene label, matched whole — lower-case words such as `dog`, `beach`, `food`."},"limit":{"type":"integer","minimum":1,"maximum":5000,"description":"Maximum photos to return (default 50)."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "get_photo",        title: "Get a photo",        description: r#"One photo by id, with everything known about it: the caption, the description, when it was taken (and the clock offset where it was taken), its size and dimensions, every place it was seen (`sightings` — each chat with its name and message, the share sheet, the phone's library, the Apple Photos asset), the faces in it (`faces`, each with its rectangle and the person it resolved to, or null), its location and place, the camera, orientation, subtypes, scene labels, original filename, Apple's aesthetic and curation scores, whether it is a favourite, the projects it belongs to, and any review note standing on it. This answers with FACTS, not the picture — call get_photo_bytes when you need to look at it. The id looks like `photo:` followed by the content hash and comes from list_photos, search_records or get_project."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The photo's id — `photo:` and its content hash."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "get_photo_bytes",        title: "Get a photo's bytes",        description: r#"The picture itself, as an image you can look at. Use it to answer a question about what is actually IN a photo — reading a screenshot, checking a receipt, describing a scene for the user. Over 2 MB the call is refused rather than filling the conversation with base64; get_photo gives you everything else about it either way. The id comes from list_photos or a search hit."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The photo's id — `photo:` and its content hash."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "add_photo",        title: "Add a picture",        description: r#"Put a picture into this database — a dish, the kitchen, a trainer, a cover — so a record can show it. Send the picture's bytes as standard base64 (PNG, JPEG or WebP, at most 12 MB). The answer is the photo's id, `photo:` and its content hash: write that id into the record's photo column with create_record or update_record. Where the Photos tool is held, the picture is a photo of it and the answer also carries its create `change`, undone like any add. Sending the same picture again answers the same id and adds nothing. A caption is the picture's words, at most 500 characters."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"bytes":{"type":"string","description":"The picture's bytes as standard base64: a PNG, JPEG or WebP of at most 12 MB."},"fileName":{"type":"string","description":"Optional. The picture's own file name, e.g. 'paneer-tikka.jpg'."},"caption":{"type":"string","description":"Optional. The picture's words, at most 500 characters."}},"required":["bytes"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_photo",        title: "Update a photo",        description: r#"Change a photo's caption, star it as a favourite, leave a review note on it, or write what you saw in it. The caption is the user's own words for the picture (at most 500 characters); pass null to clear it. A review note (at most 280) is a SUGGESTION that the user look at this picture again — "a screenshot of a 2024 boarding pass, probably done with" — and it is stamped with your name and the moment. Nothing deletes on a review note: the user reads it on the Storage screen and decides. Pass null for reviewNote to take a note back off. A description (at most 400) is one plain sentence of what the picture shows — write it only after looking with get_photo_bytes, when the user asks or when you needed to look anyway; Cotton never describes pictures on its own. It is stamped with your name; null clears it."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The photo's id — `photo:` and its content hash."},"caption":{"type":["string","null"],"description":"The user's words for this picture, at most 500 characters. null clears it."},"reviewNote":{"type":["string","null"],"description":"Why the user might want to look at this again, at most 280 characters. null clears the note."},"description":{"type":["string","null"],"description":"What the picture shows, one plain sentence of at most 400 characters, written after looking at it. null clears it."},"favourite":{"type":"boolean","description":"true stars it as one of the user's favourites, false takes the star off."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "remove_photo",        title: "Remove a photo",        description: r#"Move ONE photo to the bin — hidden from every read here, its faces, albums and links waiting with it; restore_from_bin {kind: "photo"} brings it back, and only erasing it from the bin (empty_bin) removes the record for good, and its bytes on every device once nothing else names them (bytesRemoved stays false until then). If the picture arrived in a chat, the chat keeps its copy until those messages are deleted; the answer says how many chats (alsoInChats). Deleting pictures is the USER's decision and always a conscious one: only call this for a photo they have named, never to act on a review note, never to tidy up on your own initiative, and never in a sweep — there is no batch form on purpose. One id per call."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The photo's id — `photo:` and its content hash."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_face",        title: "Say who a face is",        description: r#"Decide a face on a photo: set `personId` (an id from list_people) to say who it is, pass null to unset it, or `dismissSuggestion: true` to reject the Mac's suggestion without naming anyone. Faces and their suggestions come from get_photo. This is the USER's answer — call it only for a decision they have made about a face they have seen; never confirm a suggestion on your own initiative. A confirmed or cleared face carries no suggestion afterwards; a dismissed face is never suggested again. A face whose person says `matched: true` was linked by the Mac because it clearly matches that person's face print; naming it confirms it, and clearing it tells the Mac it is not them, so it is never linked or suggested again."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The face's id, from get_photo."},"personId":{"type":["string","null"],"description":"Who this is — a person id from list_people. null clears the person."},"dismissSuggestion":{"type":"boolean","description":"true to reject the suggestion on this face without naming anyone."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_duplicates",        title: "List near-duplicate photos",        description: r#"The Mac's proposals that one photo is a copy of another, grouped: each group names the photo proposed as the one to KEEP and the copies proposed under it, with the pHash distance (0 identical … 8 the limit) and each row's state. `open` rows await the user; `confirmed` means they agreed it is a copy; `dismissed` means they said it is not. Use it to answer "which of my photos are duplicates" and to prepare a suggestion — then leave the deciding to the user (decide_duplicate) and the deleting to remove_photo, which moves a copy to the bin. A pair with a photo in the bin is not listed. This tool deletes nothing and proposes nothing itself."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"state":{"type":"string","enum":["open","confirmed","dismissed"],"description":"Only rows in this state. Default: every state."},"keep":{"type":"string","description":"Only the group under this photo id."},"limit":{"type":"integer","description":"Rows to return, default 100, at most 500."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "decide_duplicate",        title: "Decide a near-duplicate proposal",        description: r#"Record the USER's decision on one proposal from list_duplicates: `confirmed` (yes, that photo is a copy of the keep), `dismissed` (no, they are different pictures) or `open` to take a decision back. Nothing is deleted by this call — a confirmed copy stays until the user asks remove_photo for it by id, which moves it to the bin. Only call this for a decision the user has actually made."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The proposal's id, from list_duplicates."},"state":{"type":"string","enum":["open","confirmed","dismissed"]}},"required":["id","state"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_videos",        title: "List videos",        description: r#"The user's videos, newest first by when each was taken — the same shape and the same filters as list_photos, plus how long each one runs. A video is one recording wherever it came from, and the same file seen in several places is ONE video whose sightings list every place. Each carries its caption, its description (written from the still frame that stands in for it), its size, the place it was taken when known, its subtypes (slow motion, time lapse, screen recording), whether it is a favourite and the people in it — videos are usually what is actually taking the space. Filter by `thread`, `since`/`until`, `person`, `withPeople`, `favourite`, `place`, `label`, `reviewed` and `described` rather than paging everything. get_video expands one and hands you a short-lived download link."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"project":{"type":"string","description":"Only videos linked to this project — its slug or uuid."},"thread":{"type":"string","description":"Only videos that arrived in this chat — the chat's uuid."},"since":{"type":"string","description":"ISO-8601 instant. Only videos taken at or after it."},"until":{"type":"string","description":"ISO-8601 instant. Only videos taken at or before it."},"reviewed":{"type":"boolean","description":"true for videos carrying a review note, false for the ones carrying none."},"described":{"type":"boolean","description":"true for videos that already have a description, false for the ones still waiting on one."},"person":{"type":"string","description":"Only videos a face resolved to this person — their id from list_people."},"withPeople":{"type":"boolean","description":"true for videos with at least one face in them (named or not), false for videos with none."},"favourite":{"type":"boolean","description":"true for the user's favourites (as marked in Apple Photos), false for the rest."},"place":{"type":"string","description":"Only videos taken somewhere whose name, city, region or country contains this text (case-insensitive)."},"label":{"type":"string","description":"Only videos carrying this scene label, matched whole — lower-case words such as `dog`, `beach`, `food`."},"limit":{"type":"integer","minimum":1,"maximum":5000,"description":"Maximum videos to return (default 50)."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "get_video",        title: "Get a video",        description: r#"One video by id, with everything known about it: the caption, the description, how long it runs, when it was taken, its size, every place it was seen (`sightings`), the faces in it, its location, place and camera, subtypes and labels, whether it is a favourite, the projects it belongs to and any review note. It also mints a short-lived download link (`fileUrl`, five minutes) for the recording itself, and returns the still frame as an image you can look at when one has been made. There is no bytes tool for a video — a recording is far too large to travel inside a tool result, which is what the link is for."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The video's id — `video:` and its content hash."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_video",        title: "Update a video",        description: r#"Change a video's caption, star it as a favourite, or leave a review note on it — update_photo's rules exactly. The caption is the user's own words (at most 500 characters, null clears it); a review note (at most 280) suggests they look at this recording again and is stamped with your name and the moment. Nothing deletes on a review note. Pass null for reviewNote to take one back off."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The video's id — `video:` and its content hash."},"caption":{"type":["string","null"],"description":"The user's words for this recording, at most 500 characters. null clears it."},"reviewNote":{"type":["string","null"],"description":"Why the user might want to look at this again, at most 280 characters. null clears the note."},"favourite":{"type":"boolean","description":"true stars it as one of the user's favourites, false takes the star off."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "remove_video",        title: "Remove a video",        description: r#"Move ONE video to the bin — hidden from every read here; restore_from_bin {kind: "video"} brings it back, and only erasing it from the bin (empty_bin) removes the record for good, and the recording and its still frame on every device once nothing else names them (bytesRemoved stays false until then). If it arrived in a chat, the chat keeps its copy until those messages are deleted; the answer says how many chats (alsoInChats). Deleting is the USER's decision and always a conscious one: only call this for a video they have named, never on a review note of your own, and never in a sweep — there is no batch form on purpose. One id per call."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The video's id — `video:` and its content hash."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_albums",        title: "List albums",        description: r#"The user's photo albums. An album is either a SUGGESTION the server made from the pictures they took — a trip (days spent away from home) or an event (a dense cluster of pictures on one day) — or one the user made themselves. Each carries its kind, its state (`open` = a suggestion waiting for the user to keep or dismiss it; `kept` = theirs; `dismissed` = declined, never suggested again), its title and who wrote it, the days it spans, the home it was judged against for a trip, its cover picture, how many pictures it holds and the people who appear in most of them. Open suggestions come first, then the newest. Dismissed albums are left out unless you ask for `state: "dismissed"`. Use `kind`, `since`/`until` (instants; an album counts when its days touch the range) and `limit` to narrow. get_album expands one with its pictures."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"state":{"type":"string","enum":["open","kept","dismissed"],"description":"Only albums in this state. Leave out for open and kept."},"kind":{"type":"string","enum":["trip","event"],"description":"Only trips, or only events."},"since":{"type":"string","description":"ISO-8601 instant. Only albums whose days end at or after it."},"until":{"type":"string","description":"ISO-8601 instant. Only albums whose days start at or before it."},"limit":{"type":"integer","minimum":1,"maximum":5000,"description":"How many to return; default 50."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "get_album",        title: "Get album",        description: r#"One album by id, with everything list_albums says plus its pictures in order (`items` — each a photo or video id, who put it there: `derived` for the server's suggestion or `user` for the person, and when it was taken) and the projects it belongs to. get_photo and get_photo_bytes take an item's id from here. The id looks like `album:event:2026-03-14T19` or `album:trip:2026-04-10` and comes from list_albums or get_project."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The album's id."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "decide_album",        title: "Decide album",        description: r#"Answer a suggested album for the user: `keep` makes it theirs (the server stops changing it), `dismiss` declines it for good (it is never suggested again, and nothing it held is deleted), and `open` takes a decision back so it is a suggestion once more. Only do this when the user has said what they want about THIS album — a decision is theirs, not a default. Refuses a decision the album is already in."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The album's id."},"decision":{"type":"string","enum":["keep","dismiss","open"],"description":"What the user decided."}},"required":["id","decision"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_album",        title: "Update album",        description: r#"Change an album the way the user asked: rename it (`title` — from then on the title is theirs and the server never rewrites it), choose its cover (`coverId`, one of its own pictures), add pictures (`add`, photo or video ids) or take pictures out (`remove`). Changing an OPEN suggestion keeps it first, in the same step — a name is a decision. A screenshot or a picture of information is refused: it is not a moment, and it never goes in an album. A dismissed album must be re-opened with decide_album before it can change. Removing a picture from an album never deletes the picture."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The album's id."},"title":{"type":"string","description":"The new title, in the user's words."},"coverId":{"type":"string","description":"The picture to show for the album — one of its own."},"add":{"type":"array","items":{"type":"string"},"description":"Photo or video ids to put in the album."},"remove":{"type":"array","items":{"type":"string"},"description":"Photo or video ids to take out of the album."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "create_album",        title: "Create album",        description: r#"Make an album from pictures the user named. It is theirs from the start — kept, titled in their words, every picture added by them — and the server never changes it. `kind` says what it is (a `trip` spans days away; an `event` is one day), `photoIds` are the photo or video ids to put in it, and `coverId` (optional) is the one to show for it. Its id is derived from the first picture's moment, so if the server already suggested an album for that same moment this refuses and names it — add to that one with update_album, or re-open it with decide_album if it was dismissed. Screenshots and pictures of information are refused."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"kind":{"type":"string","enum":["trip","event"],"description":"A trip (days away) or an event (one day)."},"title":{"type":"string","description":"The album's title, in the user's words."},"photoIds":{"type":"array","items":{"type":"string"},"minItems":1,"description":"The photo or video ids to put in it."},"coverId":{"type":"string","description":"The picture to show for the album — one of photoIds."}},"required":["kind","title","photoIds"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "backup_now",        title: "Back up now",        description: "Write a verified copy of every database this server serves, and bring the copy of its media folder up to date, on every mounted backup disk (a volume whose root holds a CottonDB-backups folder) — now, whether or not today's copy exists. Answers each copy's path, size and verification, or why it was refused; refuses in a development build and says so when no backup disk is mounted. Takes minutes for a large database.",        scope: McpScope::Write,        annotations: Annotations { read_only_hint: false, destructive_hint: false, idempotent_hint: Some(true), open_world_hint: false },        input_schema: r#"{"type":"object","properties":{},"additionalProperties":false}"#,        outside_write_lock: true,    },    ToolDef {        name: "media_repair",        title: "Find photos with no bytes",        description: r#"The photos whose bytes are on no machine: not in this server's store under any of the photo's keys, and held by no live device. They draw as broken pictures. Answers how many photos there are, how many are missing, the window their rows were created in, the chats they came from (most first, with each chat's name) and up to twenty ids to look one up by. Runs as a dry run only (dry_run: true) and changes nothing; dry_run: false is refused until the owner decides what a real run does."#,        scope: McpScope::Read,        annotations: Annotations { read_only_hint: true, destructive_hint: false, idempotent_hint: Some(true), open_world_hint: false },        input_schema: r#"{"type":"object","properties":{"dry_run":{"type":"boolean","description":"true: list the photos with no bytes and change nothing."}},"required":["dry_run"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "storage_summary",        title: "Summarise storage",        description: r#"What is taking up the user's space, and what has been flagged for them to look at. Answers four things: `byKind` — bytes and item counts for photos, videos, documents, audio (voice notes and other audio sent in chats) and everything else attached to a message; `byChat` — the thirty chats holding the most bytes, each with its name; `largest` — the fifty biggest single items with enough of their caption or description to recognise them; and `flagged` — every photo and video carrying a review note, with the note and who left it. Use it to answer "what is eating my storage" and to prepare a suggestion, then leave the deleting to the user: remove_photo and remove_video take one named id each, and this tool deletes nothing. Sizes come from the user's own database, so a recording whose size was never recorded counts as an item with no bytes rather than being guessed at."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "create_secret",        title: "Store a password or key",        description: r#"Save a password, an API key, a secure note, a card or an identity document in the user's own database, sealed under a key only their own devices hold. Say which kind it is; pass the secret itself as value (a password, a key, a note's text) or as fields for the typed kinds. Re-saving the same name for the same service REPLACES the value — two live keys under one name is a question nothing here can answer — while a login, which has no service, is always a new one. The value passes through Cotton's server once, in the clear, while this one call is answered, and is then sealed so that only the user's own devices open it. You will never be able to read it back: no tool returns a stored value, and list_secrets answers only names. Cotton's own assistant runs on the key stored under service 'anthropic'."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"kind":{"type":"string","enum":["login","api_key","note","card","identity","document"],"description":"What this is. Defaults to api_key, which is the only kind that requires a service."},"name":{"type":"string","description":"What the user calls it. At most 120 characters."},"site":{"type":"string","description":"The host or address a login is for."},"username":{"type":"string","description":"The username or address it signs in as."},"service":{"type":"string","description":"Who the credential is for, lowercase and hyphenated — 'anthropic', 'openai', 'my-bank'. Required for an api key, which is how it is found again; omitted for a login. Cotton's assistant reads 'anthropic'."},"expiresAt":{"type":"string","description":"When it runs out, as a date."},"value":{"type":"string","description":"The secret itself — the password, the key, the note's text. Sealed before it is written and never returned by any tool, including this one. Pass this OR fields, never both."},"fields":{"type":"object","description":"The typed payload for a kind with more than one field: a login is {password, notes, totp}, a card {number, holder, expiry, cvv, notes}, an identity {number, id_type, holder, issued, expires, country, notes}. Pass this OR value, never both."}},"required":["name"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "list_secrets",        title: "List stored keys",        description: r#"The passwords, keys, notes, cards and identity documents the user has stored — the name, the site, the username and the service each is for, never the value or any part of it. Use it to tell the user what they already have, or to check whether the key a feature needs is set before telling them to paste one. What is in the bin is not here; list_bin answers that."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"kind":{"type":"string","enum":["login","api_key","note","card","identity","document"],"description":"Only this kind."},"service":{"type":"string","description":"Only the secrets stored for this service."},"q":{"type":"string","description":"Only the ones whose name, site, username or service carries this word. The sealed payload is never searched."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "delete_secret",        title: "Move a stored secret to the bin",        description: r#"Move one stored password, key or note to the bin. Ask the user before calling this. It can be brought back with restore_from_bin and is erased for good only by empty_bin — a password somebody removes by mistake is not one they can re-derive."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The secret's uuid, from list_secrets."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_secret",        title: "Rename or re-file a stored secret",        description: r#"Change what a stored password, key or note is CALLED and where it belongs — its name, the site it is for, the username it goes with, the service it answers to, or when it expires — and, when the user gives you a new one, the secret itself. It never answers with a value, including one it was just handed. The kind does not move: a login that became a card would leave its site and username describing nothing."#,        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The secret's uuid, from list_secrets."},"name":{"type":"string","description":"What the user calls it. At most 120 characters."},"site":{"type":"string","description":"The host or address the login is for."},"username":{"type":"string","description":"The username or address it signs in as."},"service":{"type":"string","description":"Who the credential is for, lowercase and hyphenated."},"expiresAt":{"type":"string","description":"When it runs out, as a date."},"value":{"type":"string","description":"A new secret for this row — the password, the key, the note's text. Sealed before it is written and never returned. Pass this OR fields, never both."},"fields":{"type":"object","description":"A whole new typed payload for this row's own kind. Pass this OR value, never both."}},"required":["id"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "restore_version",        title: "Put an earlier version back",        description: r#"Put a record back the way one of its earlier versions had it: the fields that version held which the person may edit are written again, as an ordinary edit that leaves its own version behind, and Money fields pass through the same typed row validation. A kind that cannot be put back, a record that is gone, or a version identical to the record now is refused with the reason. THIS IS THE OWNER'S OWN ACT AND YOU CANNOT MAKE IT: going back over the person's record is their call, made from the record's history."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(false),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"kind":{"type":"string","description":"The record's kind as its history names it (todo, event, note, person, transaction, …)."},"id":{"type":"string","description":"The record's id."},"version":{"type":"string","description":"The version's id, from the record's history."}},"required":["kind","id","version"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "make_todo_recurring",        title: "Make a todo repeat",        description: r#"Turn an existing todo into the first occurrence of a repeating series: it becomes the template's anchor and the next occurrence is projected at once. THIS IS THE OWNER'S REPEAT EDITOR AND YOU CANNOT REACH IT — reshaping the rule behind somebody's standing obligations is their own act. Use create_todo with an rrule to make a repeating todo from nothing."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"todoId":{"type":"string","description":"The todo's uuid. It must not already repeat."},"rrule":{"type":"string","description":"iCal RRULE, e.g. FREQ=WEEKLY;BYDAY=MO."},"dtstart":{"type":"string","description":"The series anchor — the first occurrence's due instant, ISO-8601."},"timezone":{"type":"string","description":"The IANA zone this device is standing in, used only when the database has not recorded one of its own."}},"required":["todoId","rrule","dtstart"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_todo_recurrence",        title: "Change a repeating todo",        description: r#"Replace a repeating todo's whole template and re-project its future. Not a patch: the editor holds the template it is editing, so every field is required, and `previous` is the state before the edit — an unchanged rule keeps a forward mark (a skipped occurrence stays skipped) while a changed rule re-projects from now. Overdue open occurrences are never touched: they are obligations that already came due. THIS IS THE OWNER'S REPEAT EDITOR AND YOU CANNOT REACH IT."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"recurrenceId":{"type":"string","description":"The template's uuid."},"title":{"type":"string"},"notes":{"type":["string","null"]},"priority":{"type":"integer"},"rrule":{"type":"string","description":"iCal RRULE."},"dtstart":{"type":"string","description":"The series anchor, ISO-8601."},"paused":{"type":"boolean","description":"A paused series projects nothing until it resumes."},"previous":{"type":"object","description":"The template's state before this edit.","properties":{"rrule":{"type":"string"},"dtstart":{"type":"string"},"materializedUntil":{"type":["string","null"]}},"required":["rrule","dtstart"],"additionalProperties":false},"timezone":{"type":"string","description":"The IANA zone this device is standing in, used only when the database has not recorded one of its own."}},"required":["recurrenceId","title","notes","priority","rrule","dtstart","paused","previous"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "stop_todo_recurrence",        title: "Stop a todo repeating",        description: r#"End a repeating todo. Open FUTURE occurrences go — except the one the owner is standing on, if they named it — and anything that survives detaches into a plain todo. Overdue and completed occurrences stay: they are what actually happened. THIS IS THE OWNER'S REPEAT EDITOR AND YOU CANNOT REACH IT."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"recurrenceId":{"type":"string","description":"The template's uuid."},"keepTodoId":{"type":"string","description":"An occurrence to keep as a plain todo — the one the owner is looking at."},"timezone":{"type":"string","description":"The IANA zone this device is standing in, used only when the database has not recorded one of its own."}},"required":["recurrenceId"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "materialize_todo_recurrences",        title: "Project repeating todos forward",        description: r#"Give every active repeating todo the occurrences it is owed. The owner's app runs this when it comes to the foreground; it mints only where this device is the file's writer of record — the serving Mac, or a device holding a database no Mac serves yet — and elsewhere it only claims the device's zone when none is recorded and answers `mints: false`, leaving the occurrences to the serving Mac's hourly tick and the sync. Nothing is decided twice — one rule says who mints, every producer runs the same planner and writes the same derived ids, and the projection mark never goes backwards. THIS IS THE APP'S OWN HOUSEKEEPING AND NOT A VERB TO CALL."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"timezone":{"type":"string","description":"The IANA zone this device is standing in, used only when the database has not recorded one of its own."}},"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "respond_to_invite",        title: "Answer an invitation",        description: r#"Accept, decline or tentatively hold an invitation on the owner's own calendar. The answer is kept here only: nothing writes to Google Calendar today, so a Google invitation is still answered in Google. THIS IS THE OWNER'S ANSWER AND YOU CANNOT GIVE IT: saying yes to somebody's invitation is a commitment made in a person's own name."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The event's uuid."},"response":{"type":"string","enum":["accepted","declined","tentative","needs_action"],"description":"The owner's answer."}},"required":["id","response"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "update_attendees",        title: "Set an event's guest list",        description: r#"Replace the guest list on one of the owner's events with the list given — every guest named, and nobody else. The list REPLACES: a guest left out is removed, and every response goes back to needs_action, because a list rewritten is a list nobody has answered yet. Not for a Google-synced event, whose guests belong to Google. THIS IS THE OWNER'S ACT AND YOU CANNOT MAKE IT: inviting somebody is a commitment made in a person's own name."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"eventId":{"type":"string","description":"The event's uuid."},"attendees":{"type":"array","description":"The whole guest list, in the order it is shown. An empty array removes everyone.","items":{"type":"object","properties":{"email":{"type":"string","description":"Their email address, when there is one."},"displayName":{"type":"string","description":"The name shown on the chip."},"personId":{"type":"string","description":"The uuid of the person in this file, when the guest is one of them — it is what links the event to them."}},"additionalProperties":false}}},"required":["eventId","attendees"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "sync_device_contacts",        title: "Bring contacts in from the phone",        description: r#"File a batch of the phone's own contacts as people, each carrying the device contact's id so the two stay the same person for ever. A contact already linked is SKIPPED, never duplicated — that is what makes running this twice safe, and what makes renaming somebody here harmless. THIS IS THE OWNER'S ACT AND YOU CANNOT MAKE IT: the address book is on their phone and no assistant can read it."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"contacts":{"type":"array","description":"The contacts the owner chose, each as the phone reads it.","items":{"type":"object","properties":{"deviceContactId":{"type":"string","description":"The identifier the phone's address book gives this contact. THE unique key: a second call naming it again writes nothing."},"fullName":{"type":"string","description":"Their name as the phone composes it."},"phones":{"type":"array","items":{"type":"string"}},"emails":{"type":"array","items":{"type":"string"}},"org":{"type":"string"},"roleTitle":{"type":"string"},"city":{"type":"string"},"birthday":{"type":"object","description":"Their birthday, when the card carries a whole one. A partial or out-of-range date is left out — never a reason to lose the contact.","properties":{"year":{"type":"integer"},"month":{"type":"integer"},"day":{"type":"integer"}},"additionalProperties":false}},"required":["deviceContactId","fullName"],"additionalProperties":false}}},"required":["contacts"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "rename_session",        title: "Rename a session",        description: r#"Give one session the owner's own name. THIS IS THE OWNER'S OWN WRITE, like move_session: a session's title is otherwise its agent's — a `/rename` inside it, or the machine, repository and branch it started in — and a session that renamed itself here would be an assistant deciding what the owner calls their work. The name holds until the session is renamed again, from the phone or by a `/rename` inside it, whichever comes later. At most 140 characters; runs of spaces and line breaks become one space."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The session's uuid."},"title":{"type":"string","description":"What to call the session, 1-140 characters."}},"required":["id","title"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "move_session",        title: "Move a session to a project",        description: r#"File one logged session, and every turn in it, under a project — or take it out of one. THIS IS THE OWNER'S OWN FILING: which project a piece of work belonged to is a judgement about their own working context, and a session that moved itself would be an assistant deciding what it had been doing. A project's standing conversation is refused: it is that project's own."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The session's uuid."},"projectId":{"type":["string","null"],"description":"The project's uuid, or null to take the session out of any project."}},"required":["id","projectId"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "create_link",        title: "Link two records",        description: r#"Record that one record came from another — the note somebody saved out of a briefing, the todo they made from a meeting. The direction is derived to source, so the NEW record is the from end. Saying the same edge twice changes nothing and hands back the edge as it already stands, with the moment it was first stated. THIS IS THE OWNER'S OWN PROVENANCE: the app writes it as a record is made, and it is what lets a note point back at the thing it was made out of."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"fromKind":{"type":"string","enum":["todo","event","note","person","transaction","document","photo","video"],"description":"The kind of the record the edge starts at — the derived one, made out of the other."},"fromId":{"type":"string","description":"That record's id."},"toKind":{"type":"string","enum":["todo","event","note","person","transaction","document","photo","video"],"description":"The kind of the record the edge points at — the source."},"toId":{"type":"string","description":"That record's id."},"toDatabase":{"type":"string","description":"The id of the database the source record is in, when it is not this one. Only the personal database links into another database."}},"required":["fromKind","fromId","toKind","toId"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "hide_chat_messages",        title: "Hide messages from this device only",        description: r#"Take one or more messages out of this person's own copy of a conversation. Private: it works on anybody's message, changes not a word of what was said, and every other participant keeps theirs. Where hiding removes the newest line of a conversation, the list line follows it down to whatever is now newest. An empty list is answered with nothing hidden rather than refused. THIS IS THE OWNER'S OWN ACT."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"messageIds":{"type":"array","items":{"type":"string"},"description":"The uuids of the messages to hide."}},"required":["messageIds"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "star_message",        title: "Star or unstar a message",        description: r#"Flag a message so it turns up under Starred, or take the flag off. Private to this person's own devices and never carried to anybody else in the conversation: starring is a note to self about somebody else's words. Starring a message already starred moves the stamp to now. THIS IS THE OWNER'S OWN ACT."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"messageId":{"type":"string","description":"The message's uuid."},"starred":{"type":"boolean","description":"True to star it, false to take the star off."}},"required":["messageId","starred"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "mark_thread_read",        title: "Move a conversation's read cursor",        description: r#"Record how far this person has read in one conversation, as a sequence number rather than a stamp on every message. It only ever moves FORWARD, so a second device further back in the conversation cannot drag it down, and it clears any deliberate unread flag. When there is nothing new to record it writes nothing at all — the conversation screen calls this on every arrival, and a write per no-op would fill an append-only history with the fact that somebody was looking at a screen. THIS IS THE OWNER'S OWN ACT: how far somebody has read is an observation only their own app can make."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"threadId":{"type":"string","description":"The conversation's uuid."},"upToSeq":{"type":"integer","description":"The sequence number read up to. Leave it out for the foot of the conversation, which is what opening one means."}},"required":["threadId"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "mark_thread_unread",        title: "Mark a conversation unread",        description: r#"Put a deliberate unread flag on a conversation so this person comes back to it. It does NOT rewind the read cursor: rewinding would tell every other participant's receipts that these messages had been un-read, which is not what somebody means by the gesture. Private to this person's own devices. THIS IS THE OWNER'S OWN ACT."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"threadId":{"type":"string","description":"The conversation's uuid."}},"required":["threadId"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "set_thread_muted",        title: "Mute or unmute a conversation",        description: r#"Stop a conversation from notifying this person until an instant, or lift the mute. It lives on the CONVERSATION rather than on the contact, so a group can be muted too. Private to this person's own devices. THIS IS THE OWNER'S OWN ACT."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"threadId":{"type":"string","description":"The conversation's uuid."},"until":{"type":["string","null"],"description":"The instant the mute lasts until, or null to unmute."},"database":{"type":"string","description":"For a chat FILED in a shared database (read there): that database, by its id or its name. The setting is kept in the user's own personal database and only they see it; the copy everybody there reads is unchanged. Leave out for a chat of the personal Messages."}},"required":["threadId"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "set_thread_pinned",        title: "Pin or unpin a conversation",        description: r#"Hold a conversation at the top of the list, or let it fall back into date order. Private to this person's own devices. THIS IS THE OWNER'S OWN ACT."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"threadId":{"type":"string","description":"The conversation's uuid."},"pinned":{"type":"boolean","description":"True to pin it, false to take the pin off."},"database":{"type":"string","description":"For a chat FILED in a shared database (read there): that database, by its id or its name. The setting is kept in the user's own personal database and only they see it; the copy everybody there reads is unchanged. Leave out for a chat of the personal Messages."}},"required":["threadId","pinned"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "set_thread_archived",        title: "Archive a conversation, or bring it back",        description: r#"Move a conversation out of the main list, or return it. Nothing is deleted and every message stays exactly where it is. Private to this person's own devices. THIS IS THE OWNER'S OWN ACT."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"threadId":{"type":"string","description":"The conversation's uuid."},"archived":{"type":"boolean","description":"True to archive it, false to bring it back."},"database":{"type":"string","description":"For a chat FILED in a shared database (read there): that database, by its id or its name. The setting is kept in the user's own personal database and only they see it; the copy everybody there reads is unchanged. Leave out for a chat of the personal Messages."}},"required":["threadId","archived"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "clear_thread",        title: "Clear a conversation",        description: r#"Hide everything said in a conversation before now, from this person's own copy. It is a single marker rather than a stamp on every message: clearing a forty-thousand-message archive costs exactly what clearing an empty conversation does, and an append-only history is not filled with one row per line. The marker only ever moves forward, so a second device clearing later cannot be undone by an earlier one. Nobody else's copy changes. THIS IS THE OWNER'S OWN ACT."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"threadId":{"type":"string","description":"The conversation's uuid."},"database":{"type":"string","description":"For a chat FILED in a shared database (read there): that database, by its id or its name. The setting is kept in the user's own personal database and only they see it; the copy everybody there reads is unchanged. Leave out for a chat of the personal Messages."}},"required":["threadId"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "delete_thread",        title: "Delete a conversation from this database",        description: r#"Remove one conversation and everything hanging off it — its messages, its reactions, its receipts and its participants — from this person's own database. Every other participant keeps theirs: deleting a copy of a conversation is a private act, and a deletion carried to everybody would be one person erasing shared history. There is no bin and nothing to restore from. THIS IS THE OWNER'S OWN ACT."#,        scope: McpScope::Owner,        annotations: Annotations {            read_only_hint: false,            destructive_hint: true,            idempotent_hint: Some(true),            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"threadId":{"type":"string","description":"The conversation's uuid."}},"required":["threadId"],"additionalProperties":false}"#,        outside_write_lock: false,    },    // ── THE DEVELOPER TOOL ──────────────────────────────────────────────────    //    // A tool that exists only while the server's COTTON_DEV_TOOLS switch is on,    // and is listed to nobody at all when it is off (`protocol::listed_to`).    // The owner's decision of 27 Sep 2026    // ([until-the-app-goes-public-a-developer-mcp-dev-tools-behind-a-ser]):    // until the app is public, the gates that need a person standing at a    // screen cost more than they buy, so an assistant may pass them — and every    // call it makes is written to the audit trail the owner reads.    //    // ITS DESCRIPTION SAYS SO IN ITS FIRST WORDS. A model choosing between    // tools has to know this is not an ordinary verb of the product.    ToolDef {        name: "dev_reveal_secret",        title: "Developer: read one stored password back",        description: r#"DEVELOPER TOOL — off in the public build. Open one of the owner's stored passwords, API keys or secure notes and answer what is inside it. This is the one reader of a stored value anywhere in the tool surface: the ordinary four verbs name a secret, store one, change one and bin one, and none of them can read one back — that stays true, and this tool is off in the public build precisely so it keeps being true there. The answer carries every field of the secret, so treat it as the credential it is: use it, do not repeat it back to the person in full, and remember the transcript is kept. The audit trail records WHICH secret was opened and never what it said. Find the id with list_secrets. Refused by name on a build that cannot open the vault."#,        scope: McpScope::Read,        annotations: Annotations {            read_only_hint: true,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"secretId":{"type":"string","description":"The secret's uuid, from list_secrets."}},"required":["secretId"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "move_record",        title: "Move one record to another database",        description: "Move one record to a database in reach. The record keeps its id, byline, created time, links and comments; its old home retains a tombstone naming the destination. `to` is the destination database's id or name.",        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"id":{"type":"string","description":"The record's uuid."},"to":{"type":"string","description":"The destination database's id or name."}},"required":["id","to"],"additionalProperties":false}"#,        outside_write_lock: false,    },    ToolDef {        name: "move_records",        title: "Move records to another database",        description: "Move up to 1,000 records together to a database in reach. The batch is all-or-none: every record keeps its id, byline, created time, links and comments, and each old home retains a tombstone naming the destination. `to` is the destination database's id or name.",        scope: McpScope::Write,        annotations: Annotations {            read_only_hint: false,            destructive_hint: false,            idempotent_hint: None,            open_world_hint: false,        },        input_schema: r#"{"type":"object","properties":{"ids":{"type":"array","minItems":1,"maxItems":1000,"items":{"type":"string"},"description":"The records' uuids, each once."},"to":{"type":"string","description":"The destination database's id or name."}},"required":["ids","to"],"additionalProperties":false}"#,        outside_write_lock: false,    },];