Tool reference
Codex serves its tools, prompts and resources at /mcp. This page lists all of them. Its tool, prompt and resource tables come from the server’s own definitions, so the names and descriptions are the ones your agent sees.
The server defines 48 tools, 4 prompts and 6 resources. Codex leaves upload_image out at /mcp, so an agent sees 47 tools. To connect an agent, see Connect an agent. To create a token with the scopes you need, see Tokens and scopes.
Scopes
Section titled “Scopes”Every token holds codex:read. A tool called without its scope fails with forbidden, and the message names the scope.
A call also needs a high enough role on the book it touches. A token with codex:write on a book shared to you for viewing fails with forbidden.
undo also needs the scope of the tool whose write it reverses. Signing off a source and accepting fair use stay in the app, whatever scopes a token has.
| Scope | Tools |
|---|---|
codex:read |
list_books, search, resume_work, get_outline, read_manuscript, get_draft, get_kb_entry, find_kb_usages, list_kb_entries, get_book_settings, list_revisions, get_job, preview_layout, export_for_printer, get_clearance, export_references, list_images, get_image |
codex:write |
edit_outline, edit_prose, upsert_beat, submit_draft, resolve_draft, upsert_kb_entry, manage_kb_category, link_kb_entry, undo, delete_kb_entry, merge_kb_entries, create_book, update_book, create_series, update_series, upload_image, create_image_upload, place_figure, update_figure, set_opener |
codex:references |
cite_source, update_source, update_source_use, record_clearance_decision, draft_permission_letter, manage_permission, add_source, archive_source, merge_sources |
codex:generate |
draft_prose |
A tool marked read only never changes anything.
Reading
Section titled “Reading”| Tool | Scope | What it does | Arguments |
|---|---|---|---|
list_booksWhat am I working on? Read only |
codex:read |
The Library: series (with their totals) and standalone books, each with status, words / target, last edited and open_url. It lists the author’s own books and the books shared with them; each book and series has role (view, comment, write or owner: what the author may do there) and owner. |
series: Only the books of this series (id or title).status: Only these statuses: planning, draft, writing, revising, published.sort: last_edited (default, like the Library), title or series_number. |
searchWhere is …? Read only |
codex:read |
Finds books, chapters, scenes, Knowledge base entries (names and aliases), sources and prose containing the query (case-insensitive). Prose hits carry the sentence with the match. | query (required): The words to look for.book: Only this book (id, title or “<series>/<number>”); default the whole Library.types: Any of book, chapter, scene, kb_entry, source, prose; default all.limit: At most this many hits (default 20, at most 100). |
resume_workPick up where I left off Read only |
codex:read |
A briefing on a book: the scene last worked on (with its version and pending AI draft), every pending draft with its text, scenes waiting on the author (Needs research, or no summary and no prose) and the References risks. Each line has an open_url. | book: The book; default the most recently edited one. |
get_outlineShow me the shape of the book Read only |
codex:read |
Acts → chapters → scenes in book order, with display numbers, ids, titles, labels, status, words and a pending_draft flag. include adds kb_links, beats, plan_notes (each chapter’s and scene’s planning notes; summaries likewise covers chapters), archived (archived chapters) or kb_index (the Knowledge base categories in scope, book or series). | book (required): The book: id, title or “<series>/<number>”.within: One act or chapter instead of the whole book: “act:2”, “5”, “ch:<slug>” or an id.include: Any of summaries, labels, word_counts (the default three), kb_links, beats, plan_notes, archived, kb_index. |
read_manuscriptLet me read it Read only |
codex:read |
A book’s prose in reading order, one block per scene with its label and version (edit_prose needs it). annotated (default) shows beats, Knowledge base additions, source markers and pending AI drafts as readable text; markdown is the body exactly as stored, with pending drafts listed beside it. Stops near max_words (at most 20000) and returns a cursor to continue; a scene split across pages reads whole when its parts are joined (markdown: as is; annotated: with a blank line). | book (required): The book: id, title or “<series>/<number>”.scope: “book” (default), or an act, chapter or scene: “act:2”, “5”, “5.2”, “ch:<slug>” or an id.format: annotated (default) or markdown.include_hidden_beats: Show hidden beats in annotated text (default true).max_words: Stop after about this many words (default 4000, at most 20000).cursor: The cursor a previous call returned, to continue from there. |
get_draftShow me that draft Read only |
codex:read |
One AI draft (pending, applied or discarded): its text, model, attempt, template, words, tokens, and the scene’s current version. | draft (required): The draft (generation) id, as resume_work or read_manuscript return it. |
get_kb_entryTell me about this entry Read only |
codex:read |
One Knowledge base entry: category, scope (book or series), aliases, tags, summary, body, fields, related entries, its source, and its additions (what the reader learns, scene by scene) in book order. | entry (required): The entry: id, name, alias or “e:<slug>”.book: Look only in this book’s scope (its own and its series’ entries); default the whole Library. |
find_kb_usagesEverywhere this is used Read only |
codex:read |
Every scene that uses a Knowledge base entry, in book order, with how (scene_link, mention, summary_mention, beat_mention, context, addition, alias_match, printed), a snippet and an open_url that highlights the entry in Write; plus counts by kind and the source linked to the entry. | entry (required): The entry: id, name, alias or “e:<slug>”.kinds: Only these kinds of use.books: For a series entry: only these books (ids or titles). Default every book. |
list_kb_entriesList the Knowledge base Read only |
codex:read |
The Knowledge base entries a book can see (its own and its series’; archived ones left out), in the order the Knowledge base screen shows them: category, then entry. Each has its id and open_url, name, category, scope (book or series), aliases, tags, always_in_context and used_in_scenes (live scenes that use it, as get_kb_entry counts them). Pages of limit (default 100, at most 500); next_cursor continues, absent (null) on the last page; total counts every entry in scope (of the category, when one is given). | book (required): The book: id, title or “<series>/<number>”.category: Only this category (its name, any case).cursor: The cursor a previous call returned, to continue from there.limit: Entries per page (default 100, at most 500). |
get_book_settingsHow is this book set up? Read only |
codex:read |
A book’s settings: title, author, status, target, series, the style guide (book, series and merged, as sent with every AI draft) and the publication settings (citation style, quote word limit, publisher, year, formats, print run, territory; each says whether it is inherited from the series). | book (required): The book: id, title or “<series>/<number>”. |
list_revisionsWhat did this scene say before? Read only |
codex:read |
A scene’s saved versions, newest first (the last 50, as History in Write shows them): each revision’s id, how it came to be (source: manual, autosave, ai_apply, restore, agent, import, replaced; label: “Edited”, “AI draft applied”, “Edited by <client>”), when, its words, and which one matches the scene now (current). Give revision to read that version’s text as stored Markdown. To put an old version back, edit_prose the scene with that text, or restore it from History in Write. |
scene (required): The scene: an id, or “5.2” with book.revision: A revision id from this list: returns its text.book: The book, when scene is a display number. |
Writing
Section titled “Writing”| Tool | Scope | What it does | Arguments |
|---|---|---|---|
edit_outlineAdd, rename, move or cut parts of the outline |
codex:write |
A batch of outline ops, applied in order, all or nothing. Every ref is read against the outline as it was before the batch, so “6” means the same chapter in every op. Ops: {op:“move”, item, before|after|into} for acts, chapters and scenes; {op:“archive”|“restore”, item} for acts, chapters and scenes (restore takes the archived item’s id; archiving a chapter or act takes its scenes out with it, and restore brings back the ones that were live); {op:“update”, item, title?, summary?, plan_notes?, status?, add_labels?, remove_labels?, create_missing_labels?} for a scene; {op:“update”, item, title?, summary?, plan_notes?, is_numbered?} for a chapter (is_numbered:false takes it out of the numbering, so the chapters after it renumber; its ch:<slug> never changes); {op:“update”, item, title?} for an act; a scene or chapter update may also give expected_summary? / expected_plan_notes? (the text you read): if the stored text differs the batch fails conflict; {op:“add”, kind:“act”|“chapter”|“scene”, title?, before|after|into} (a scene also takes summary? and labels?; a new act starts with one chapter holding one empty scene). Refs can’t name an item the same batch adds: read the outline again for its id. Returns a result per op and the chapters renumbered; dry_run reports the same without writing. | book (required): The book: id, title or “<series>/<number>”.ops (required): The ops, applied in order.dry_run: Report the result without writing. |
edit_proseFix this passage |
codex:write |
Exact-match replacements in one scene’s prose, all or nothing: an old that is missing, or that matches more than once without occurrence (1-based), fails the whole call and writes nothing. Takes expected_version from read_manuscript; a stale one fails with conflict. An edit may not add ::beat or ::kb-addition lines or ref: links (use upsert_beat, link_kb_entry, cite_source); removing one archives it, as deleting it in Write does. dry_run returns the new body without writing. The scene’s prose before this session’s first edit is kept as a revision (Restore in Write), and undo_id reverses the edit. |
scene (required): The scene: an id, or “4.1” with book.expected_version (required): The scene’s version from read_manuscript.edits (required): Replacements applied in order: { old, new, occurrence? }.book: The book, when scene is a display number (default: the most recently edited book).dry_run: Report the result without writing. |
upsert_beatPlan what a passage should say |
codex:write |
Creates a beat (omit beat; give scene, at and expected_version, since its ::beat line changes the prose) or updates one (beat id): instruction, target_word_count, is_hidden, and + Context entries (context_add / context_remove by name or alias). at is “start”, “end”, {“after”: {“text”: …}} or {“before”: {“text”: …}}; inside a paragraph the beat splits it. |
beat: The beat to update; omit to create one.scene: Creating: the scene, an id or “5.2” with book.at: Creating: where the ::beat line goes.expected_version: Creating: the scene’s version from read_manuscript.instruction: What the passage should say.target_word_count: How long the drafted passage should be (e.g. 200, 400, 600).context_add: Knowledge base entries to add to the beat’s context.context_remove: Knowledge base entries to take out of the beat’s context.is_hidden: Hide the beat in reading views.book: The book, when scene is a display number. |
draft_proseWrite a draft of this for me |
codex:generate |
Has Codex write a draft with the author’s connected AI account (their default integration in Settings → AI, or the one named in integration) and the Write screen’s prompt (the book’s style guide, the beat’s context, the prose before it). Give beat (prose for that beat) or scene (continue at the end of the scene). Returns the generation id and a job_id at once; the draft is written in the background. Read it with get_draft or get_job once the state is done, then resolve_draft. Never applies. Each token can start 20 of these per sliding hour by default (CODEX_MCP_MAX_GENERATIONS sets the limit); past it the call fails rate_limited. To supply the text yourself, use submit_draft. |
beat: Write the prose for this beat (its id).scene: Or continue this scene at its end: an id or “5.2” with book.retry_of: A new attempt of this earlier draft; the earlier one is discarded once this one starts.template: A prompt template, by id or name (see the Write screen’s picker).model: A model id; default the integration’s default model (an anthropic integration falls back to Sonnet 5.5; other kinds need one).target_word_count: About how long the draft should be; default the beat’s own target, else 400.book: The book, when scene is a display number.integration: The AI integration to write with, by id or label; default the author’s default one. |
submit_draftOffer a draft I wrote |
codex:write |
Stores prose you wrote as a pending draft for a beat (beat) or the end of a scene (scene), in the same Apply · Retry · Discard panel as Codex’s own. It names no model (it is marked as written by this client) and does not use the generation budget. The text may not contain ::beat or ::kb-addition lines, ::figure lines or ref: links. Nothing is applied: use resolve_draft. |
text (required): The prose, as Markdown in the stored scene format: blocks separated by one blank line, with headings, lists, quotes and tables allowed. Read codex://scene/{id} to see a scene as stored.beat: The beat this is the prose for (its id).scene: Or the scene it continues at the end: an id or “5.2” with book.book: The book, when scene is a display number. |
resolve_draftKeep it or bin it |
codex:write |
Applies a pending draft to its scene (a beat’s draft replaces the prose under the beat; a continuation goes at the end) or discards it. apply needs expected_version, the scene’s version from read_manuscript or get_draft, and a stale one fails with conflict. Both can be undone. For a new attempt, call draft_prose with retry_of. |
generation (required): The draft (generation) id.action (required): apply or discard.expected_version: For apply: the scene’s version. |
get_jobIs it done yet? Read only |
codex:read |
The state of a job by its id: a draft_prose job (the job_id it returned; running, done or failed, with the draft’s status and words once done; read the text with get_draft), or an export job. Poll until the state is done or failed. | job_id (required): The job id. |
upsert_kb_entryRemember this person, law, place or idea |
codex:write |
Creates a Knowledge base entry (omit entry; needs book, name and category) or updates one (entry: id, name or alias). category is a category name; create_category adds one. scope “series” puts a new entry in the book’s series, shared by every book in it. If the name or an alias already belongs to another entry in scope the call fails ambiguous unless allow_duplicate. tags replaces the set; exclude_from_auto_context keeps the entry out of the context chosen automatically for a draft. related_add and related_remove relate or unrelate other entries (id, name or alias, in the entry’s scope; an entry outside it fails out_of_scope before anything is written); a pair already related, or not related, changes nothing and undo reverses only the pairs that changed. |
book: The book whose Knowledge base this is (id, title or “<series>/<number>”). Required to create.entry: Update this entry; omit to create.name: The entry’s name.category: The category’s name (People, Places, …).scope: “book” (default) or “series”, when creating.aliases: Other names the entry goes by; they drive the dotted-underline matches in Write. Replaces the set.summary: One or two lines.body: The entry’s text.fields: The category’s field values, by field key.always_in_context: Always send the entry to the AI as context.tags: The entry’s tags. Replaces the set.exclude_from_auto_context: Never pick the entry for a draft’s context automatically.create_category: Create the category when no category has that name.allow_duplicate: Allow a name or alias another entry in scope already has.related_add: Entries to relate this one to (id, name or alias).related_remove: Entries to unrelate from this one (id, name or alias). |
manage_kb_categoryCreate, rename, reorder or delete a Knowledge base category |
codex:write |
Manages one Knowledge base category of a book (or series), by name. op: create (category is the new name; colour optional), rename (name and/or colour), reorder (one of before or after another category’s name, or position “first”/“last”; categories of the book and of its series order separately), delete. delete refuses a category with live entries (conflict, naming the count) unless move_to names a category of the same book or series: the entries move there, in order, and the category is deleted in the same call. A delete is soft: the name can be used again, and the category comes back with undo. dry_run reports without writing. Undo puts the name, colour or place back, removes a created category while it is empty, or brings a deleted one back (same id, place and Details fields) and moves its entries back. |
book (required): The book whose Knowledge base this is (id, title or “<series>/<number>”).op (required): create, rename, reorder or delete.category (required): The category’s name (for create: the new category’s name).name: rename: the new name.colour: create, rename: a category colour token (category-blog, category-law, category-story, category-research, category-person).before: reorder: put the category just before this category.after: reorder: put the category just after this category.position: reorder: “first” or “last”.move_to: delete: move the live entries to this category first.dry_run: Report what would change and write nothing. |
link_kb_entryConnect this entry to the story |
codex:write |
Connects an entry to the story, one result per link. as: scene (the chip on the Plan card; scene), mention (turns the first plain use of anchor.text in scene into a mention chip), addition (scene, at, text, expected_version: what the reader learns from here on), context (beat: + Context). unlink removes scene, mention and context links. A link outside the book’s scope fails that link with out_of_scope and the rest still run. as source is not supported here: to link an entry to a source, call update_source with its kb_entry field. |
entry (required): The entry: id, name or alias.links: Links to add: { as, scene?, anchor?, beat?, at?, text?, expected_version? }.unlink: Links to remove (same shape).book: The book, when a scene is a display number or to scope a name. |
undoTake that back |
codex:write |
Reverses one write by the undo_id its result returned, within 24 hours: prose goes back to the body before the edit, moves go back, archived scenes come back. Fails with conflict, writing nothing, when the prose was edited again since. | undo_id (required): The undo_id from a write result. |
delete_kb_entryDelete a Knowledge base entry |
codex:write |
Deletes a Knowledge base entry (a soft delete). Every mention of it in scene prose, summaries, beats and other entries becomes plain text, its timeline notes are removed, and its scene, beat and related links are dropped. dry_run reports what would change (mentions, scenes, notes, links) without writing. Undo brings the entry, its mentions, notes and links back while nothing it touched has changed since; otherwise conflict. | entry (required): The entry: id, name or alias.dry_run: Report what would change without writing.book: The book, to scope a name or alias. |
merge_kb_entriesMerge a duplicate Knowledge base entry |
codex:write |
Folds the duplicate entry into the entry to keep, into, which must be in the same book or the duplicate’s series. Every use of the duplicate (mentions, printed spells and stat blocks, summaries, beats, other entries’ text) points at the kept entry; scene links, beat context, timeline notes, related links and sources move over; the kept entry gains the duplicate’s name and aliases as aliases and its body under “Merged from <name>” (its own summary and body stay). The duplicate is archived. dry_run reports what would move without writing. Undo restores the duplicate and puts everything back while nothing the merge touched has changed since; otherwise conflict. |
entry (required): The duplicate: id, name or alias. It is archived.into (required): The entry to keep: id, name or alias.dry_run: Report what would move without writing.book: The book, to scope names and aliases. |
Books and series
Section titled “Books and series”| Tool | Scope | What it does | Arguments |
|---|---|---|---|
create_bookStart a new book |
codex:write |
Creates a book: standalone, or in a series (series) as the next number unless series_number says otherwise. It starts with one empty Act 1. A book in a series shares the series’ Knowledge base. Returns the book and the Plan URL. Undo archives it. A starting outline is not supported yet: add acts, chapters and scenes with edit_outline. |
title (required): The book’s title.author_name: The author’s name; default the author.series: Add the book to this series (id or title).series_number: Its number in the series; default the next free number.target_word_count: The word count the book is aiming for.subtitle: A subtitle. |
update_bookChange the book’s settings |
codex:write |
Changes a book’s settings: fields (title, subtitle, author_name, description, status, target_word_count, style_guide), series_number (its place among the series’ books, the rest renumber), series or make_standalone (a move: the series’ Knowledge base is copied onto the book, so it fails needs_confirmation, writing nothing, until you call again with confirm after a dry_run), and publication (citation_style chicago/apa/harvard, quote_word_limit, publisher_name, planned_year, print_run, formats, territory), and layout (template slug, trim, options: the Layout screen’s choice). dry_run reports the changes without writing. Undo puts the fields, publication settings and layout back; a call that moves the book between series cannot be undone. |
book (required): The book: id, title or “<series>/<number>”.fields: { title, subtitle, author_name, description, status, target_word_count, style_guide }. An empty subtitle, author_name, description or style_guide clears it; target_word_count 0 clears the target.publication: Publication settings: { citation_style, quote_word_limit, publisher_name, planned_year, print_run, formats, territory }.layout: The book’s layout: { template (a slug such as “classic”), trim, options }. Options are { key: value } and the others keep their stored value.series_number: The book’s number among its series’ books (1 is first).series: Move the book into this series (id or title).make_standalone: Take the book out of its series.confirm: Confirms a series move whose dry_run you have read.dry_run: Report what would change and write nothing. |
create_seriesStart a new series |
codex:write |
Creates a series owned by you: name, optional description and author_name, and optional books (refs: id, title or “<series>/<number>”) to move in, in order, as books 1, 2, … of it. Moving books is a series move, as in update_book: a book that is in another series gets that series’ Knowledge base copied onto it, so it fails needs_confirmation, writing nothing, until you call again with confirm after a dry_run. Returns the series with affected and undo_id. Undo archives a series that is still empty; a call that also moved books cannot be undone. |
name (required): The series’ name.description: What the series is about.author_name: The author’s name.books: Books to move in, in order (they become 1, 2, …). Each must be a book, not a series; it can be standalone or in another series.confirm: Confirms moving books whose dry_run you have read.dry_run: Report what would change and write nothing. |
update_seriesChange a series |
codex:write |
Changes a series: name, description (empty clears it), order (every live book of the series, as refs, in the new order: they are renumbered 1, 2, …) and archive (a soft delete: the series leaves the shelf and its books go with it, keeping their numbers; undo brings it all back). dry_run reports without writing. Undo puts the name, description, order and archive back while they still read what the call left. |
series_ref (required): The series: id or title.name: A new name.description: A new description; empty clears it.order: Every live book of the series in the order you want (refs: id, title or “<series>/<number>”).archive: Archive the series with its books (undo restores it).dry_run: Report what would change and write nothing. |
preview_layoutHow will this look in print? |
codex:read, also codex:write for some calls |
How a scene, chapter or the whole book will look in print. kind “quick” (default) renders the Layout preview and returns an estimated page count and the warnings found (unknown directives, raw LaTeX the template skips, missing images); open_url opens it in Layout. kind “proof” queues a one-chapter PDF compiled by the worker (scope is a chapter, or a scene’s chapter) and returns a job_id to read with get_job; an unchanged chapter answers with its earlier proof (cached). template tries another layout without changing the book. A proof needs the codex:write scope; a quick preview needs pandoc (not_configured without it). |
scope: A scene, chapter or act: an id, “5”, “5.2”, “act:2” or “ch:<slug>”. Omit for the whole book (quick only).book: The book (default: the one the scope names, else the most recently edited).kind: quick (default) or proof.template: A template slug to try instead of the book’s, e.g. “manuscript”. |
export_for_printerBuild the print PDF |
codex:read, also codex:write for some calls |
Export for printer: the whole book as a print PDF. mode “preflight” lists what stands in the way and queues nothing: blocks (copyright risks from the print gate, missing images), warnings (images under the target dpi, unknown directives, raw LaTeX the template skips) and notes. mode “queue” runs preflight again and, when nothing blocks, queues the export and returns a job_id to read with get_job; any block, a copyright risk included, fails blocked and queues nothing, and a book with an export already queued or running fails conflict. Settings default to the book’s layout: trim (e.g. 6x9), bleed (none, 3mm, 0.125in), crop_marks (needs a bleed), image_quality (print = 300 dpi, screen = 150 dpi). A queued export is built by the worker and can’t be undone from here. Preflight needs codex:read; queue also needs codex:write. | mode (required): preflight or queue.book: The book (default: the most recently edited).template: A template slug to export with instead of the book’s.trim: Trim size slug, e.g. 6x9, 5.5x8.5, us-letter, a4.bleed: none (default), 3mm or 0.125in.crop_marks: Crop marks (needs a bleed).image_quality: print (300 dpi, default) or screen (150 dpi). |
References
Section titled “References”| Tool | Scope | What it does | Arguments |
|---|---|---|---|
get_clearanceWhat’s blocking print? Read only |
codex:read |
Copyright clearance of a book. Without source: the summary strip (cited, cleared, risks, print_blocked, unflagged_quotes), every source with its marker number, status (risk, needs_check, cleared, not_cited), reason and next_action (reduce_quoted_words, request_permission, chase_permission, cut_or_request, sign_off, decide_fair_use, set_licence, fix_identifier, review_new_use, fill_details), and the unflagged-quote inbox (flags; pass cite_source from_flag to resolve one). With source: that source as the References panel shows it, uses (marking those new since sign-off), identifier checks, the permission request and history; include picks from uses, checks, permission, history and flags (default: the first four). |
book: The book: id, title or “<series>/<number>”; default the most recently edited.source: One source: an id, a marker like “#4”, a cite key or a title.status: Only sources with these statuses: risk, needs_check, cleared, not_cited.include: What to include: uses, checks, permission, history, flags. |
cite_sourceCite this |
codex:references |
Cites a source for words already in a scene: scene + passage { text, occurrence? } + expected_version (from read_manuscript), or from_flag (an unflagged-quote id from get_clearance; its words are cited, with the flag’s own locator). source is a ref (an id, “#4”, a cite key or a title), { isbn | doi | url } (looked up and matched against the book’s sources, including Not cited ones; a new one is added if none matches) or { new: { kind, title, authors, year, publisher, … } }. Returns the use, its marker number, how many later markers shifted, and the source’s clearance before and after. kind: quote, paraphrase (default), data, figure, lyric. A stale expected_version fails with conflict. dry_run resolves the source and reports without writing. Undo restores the scene’s prose (and archives a source this call added); a citation from a flag cannot be undone here. |
scene: The scene: an id, or “7.1” with book.passage: The words to wrap: { text, occurrence? }, exactly as stored in the prose.source: A source ref, { isbn | doi | url }, or { new: { … } }.kind: quote, paraphrase (default), data, figure or lyric.locator: Where in the source: “pp. 41–43”, “Table 5.1”.from_flag: Cite an open unflagged quote instead of a passage.force_new: Add a new source even when one matches the identifier.expected_version: The scene’s version from read_manuscript.book: The book, when scene or source is a display number or title.dry_run: Report the result without writing. |
update_sourceFix the details of a source |
codex:references |
Changes a source: fields (kind, title, authors “Family, Given; …”, year, publisher, edition, isbn, doi, url, accessed_on yyyy-MM-dd, licence, rights_holder, kb_entry, cite_key, permissions_contact; an empty string clears), recheck (isbn, doi, url: re-runs the identifier checks) and accept_redirect (replace the address a recheck says has moved). Returns the clearance before and after. Undo puts the fields back. Changing one use of a source (kind, locator, rewrap, remove) is update_source_use. To merge duplicates use merge_sources. |
source (required): The source: an id, a marker like “#4”, a cite key or a title.fields: Fields to set, by name.recheck: Identifiers to re-check: isbn, doi, url.accept_redirect: Replace the address a recheck reported as moved with where it now lands.merge_into: Merge a duplicate into another source (use merge_sources instead).book: The book, when source is a marker, cite key or title. |
update_source_useFix one use of a source |
codex:references |
Changes one use of a source (its id is in get_clearance): kind (quote, paraphrase, data, figure, lyric), locator (where in the source; empty clears), rewrap { text, occurrence? } + expected_version (moves the use’s marker onto the words you just wrote in its scene: the same use, so its kind, locator and history stay, and the old words become plain text), or remove (unwraps the marker, which archives the use; expected_version optional). Returns the source’s clearance before and after. A stale expected_version fails with conflict; a rewrap text that is not in the scene is invalid. dry_run reports without writing. Undo puts kind, locator and a rewrap’s prose back while they still read what the call left; removing a use cannot be undone here. |
use (required): The use: its id, from get_clearance.kind: quote, paraphrase, data, figure or lyric.locator: Where in the source: “pp. 41–43”, “Table 5.1”; an empty string clears it.rewrap: The new words to carry the marker: { text, occurrence? }, exactly as stored in the prose.remove: Unwrap the use’s marker in the prose, which archives the use.expected_version: The scene’s version from read_manuscript (required with rewrap).dry_run: Report the result without writing. |
record_clearance_decisionI’ve decided about this source |
codex:references |
Records a copyright decision as the author, with provenance ‘agent’. decision: reopen takes back a sign-off; not_a_quote (with flag) dismisses an unflagged quote for good (its note is not stored). sign_off and accept_fair_use (needs note, the reason) are the author’s legal calls and are made only in References: they fail blocked (rule author_decision) with the summary of uses and words and the open_url where the author signs off; nothing is written. Signing off a source that is still a copyright risk fails blocked with the reason in the words References uses. Undo cannot re-sign a source or take back a dismissed quote or fair-use call. |
decision (required): sign_off, accept_fair_use, reopen or not_a_quote.source: The source: an id, a marker like “#4”, a cite key or a title.flag: The unflagged quote (not_a_quote), from get_clearance.note: The reason (accept_fair_use needs one); stored with accept_fair_use.book: The book, when source is a marker, cite key or title. |
draft_permission_letterDraft a permission letter |
codex:references |
Drafts the permission request for a source: the letter is written from the uses and the book’s print run (override with letter and to_address). Codex doesn’t send mail: the author sends it, then manage_permission mark_sent records that. A source with a live request (draft, sent or granted) is a conflict. Undo withdraws the draft while it still reads what this call wrote. |
source (required): The source: an id, a marker like “#4”, a cite key or a title.letter: The letter (Markdown), instead of the one drafted from the uses.to_address: Where the request goes, instead of the source’s permissions contact.book: The book, when source is a marker, cite key or title. |
manage_permissionAsk the rights holder |
codex:references |
Moves a source’s permission request along; draft it first with draft_permission_letter. update edits a draft’s letter and to_address. mark_sent records that it was sent (the author sends it, since Codex doesn’t send mail; a reminder is set two weeks out). set_reminder takes remind_at (yyyy-MM-dd, empty clears). record_refusal takes an optional note. withdraw drops a draft or sent request. record_grant is the author’s decision and needs the signed letter as a file, so it returns blocked with the References link. None of these steps can be undone here. |
source (required): The source: an id, a marker like “#4”, a cite key or a title.action (required): update, mark_sent, set_reminder, record_grant, record_refusal or withdraw.letter: The letter (Markdown), for update.to_address: Where the request goes, for update.remind_at: The reminder date, yyyy-MM-dd.note: Why permission was refused, for record_refusal.book: The book, when source is a marker, cite key or title. |
add_sourceAdd a source for later |
codex:references |
Adds a source to a book’s References without citing it. source is { isbn | doi | url } (looked up and matched against the book’s sources, Not cited ones included) or { new: { kind, title, authors, year, publisher, edition, isbn, doi, url, accessed_on, licence, rights_holder } }. When the book already has it, that source is returned (how: matched) and nothing is written; force_new adds a lookup result anyway, though never a second source with the same identifier. A new source is Not cited until cite_source uses it. dry_run looks the identifier up and reports without writing. Undo archives a source this call added. |
book (required): The book: id, title or “<series>/<number>”.source (required): { isbn | doi | url } or { new: { … } }.force_new: Add a looked-up source even when one matches the identifier.dry_run: Report the result without writing. |
archive_sourceRemove a source |
codex:references |
Removes a source from a book’s References, as Remove in the References panel: each passage citing it becomes plain text (the words stay, the marker goes, later markers renumber), and the source and its uses are archived. Returns the scenes whose prose changed. dry_run reports the uses and scenes without writing. Undo brings the source, its uses and the prose back while those scenes are unedited since; otherwise conflict. To fold a duplicate into another source use merge_sources instead. | source (required): The source: an id, a marker like “#4”, a cite key or a title.dry_run: Report the uses and scenes without writing.book: The book, when source is a marker, cite key or title. |
merge_sourcesMerge a duplicate source |
codex:references |
Folds the duplicate source into the source to keep, into, in the same book. The duplicate’s uses move to the kept source (markers renumber; the prose is not edited, since a use’s link names the use, and a moved use counts as new, so a signed-off kept source reopens). The kept source’s empty fields are filled from the duplicate; fields with a value stay. A live permission request moves too when the kept source has none. The duplicate is archived. dry_run reports what would move and the new clearance without writing. Returns the kept source’s clearance before and after. Undo restores the duplicate and moves its uses back while nothing the merge touched has changed since; otherwise conflict. |
source (required): The duplicate: an id, a marker like “#4”, a cite key or a title. It is archived.into (required): The source to keep, in the same book: an id, a marker, a cite key or a title.dry_run: Report what would move and the new clearance without writing.book: The book, when source is a marker, cite key or title. |
export_referencesGive me the bibliography Read only |
codex:read |
A book’s sources as text: bibtex, ris, csl_json, permissions_log (CSV) or bibliography. Cited sources only, unless include_uncited. bibliography is a plain author-year list: Codex formats entries in the book’s citation style only in Print and the References tab, and the result says so (style_applied: false); for styled output take csl_json. |
book: The book: id, title or “<series>/<number>”; default the most recently edited.format: bibliography, bibtex, ris, csl_json or permissions_log.include_uncited: Include sources nothing cites (default false). |
Images, figures and openers
Section titled “Images, figures and openers”| Tool | Scope | What it does | Arguments |
|---|---|---|---|
upload_imageUpload an image from this machine |
codex:write |
Uploads the PNG, JPEG or WebP file at path (on the machine this server runs on; at most 25 MB and 64 megapixels) to the book, or with scope “series” to its series. Returns the image id to pass to place_figure or set_opener, its pixel size and status (processing until its renditions are made). Call list_images first to skip files already uploaded.Codex does not offer this tool at /mcp. Use create_image_upload. |
path (required): Absolute path of the image file.book: The book (default: the most recently edited book).scope: book (default) or series.source: Where the image came from (kept with it).prompt: The prompt that generated it.licence: Its licence. |
create_image_uploadGet a link to upload an image to |
codex:write |
For an image the server can’t read from disk: returns a single-use upload_url for the book (or, with scope “series”, its series), valid for 10 minutes. PUT the file to it, e.g. curl –fail -T <file> <upload_url>; the response is the image (its id goes to place_figure or set_opener). Declare the file’s name, content_type (image/png, image/jpeg or image/webp) and exact size in bytes (at most 25 MB); a body of another size is refused. | filename (required): The file’s name, e.g. part-1-opener.png.content_type (required): image/png, image/jpeg or image/webp.bytes (required): The file’s size in bytes.book: The book (default: the most recently edited book).scope: book (default) or series.source: Where the image came from (kept with it).prompt: The prompt that generated it.licence: Its licence. |
list_imagesList a book’s images Read only |
codex:read |
The images the book can place: its own and its series’, newest first, with status, size in bytes and pixels, and the effective dpi at placement in the book’s layout. Match on filename and bytes to skip files already uploaded. |
book: The book (default: the most recently edited book).filename: Only images whose filename contains this.placement: The placement the dpi is judged for: column (default), page, spread or float-top. |
get_imageLook at an image Read only |
codex:read |
One image’s status, size and effective dpi at placement in book’s layout (default: the image’s own book). With view: true the result also carries the image itself (its web rendition, about 1600 px), so you can look at it to write alt text or a caption; until the rendition is made it carries none and says so. |
image (required): The image’s asset id.view: Attach the image so you can see it.placement: The placement the dpi is judged for: column (default), page, spread or float-top.book: The book whose layout the dpi is judged in (needed for a series image). |
place_figurePlace an image in a scene |
codex:write |
Places an uploaded image (upload_image, create_image_upload or list_images) as a figure in a scene: writes the figure and its ::figure line together. at is “start”, “end”, {“after”: {“text”: …}} or {“before”: {“text”: …}}, as for upsert_beat. placement is column (default), page, spread or float-top. Needs expected_version; a stale one fails with conflict and writes nothing. undo_id takes the line out, which archives the figure. |
scene (required): The scene: an id, or “5.2” with book.at (required): Where the ::figure line goes.asset (required): The image’s asset id.expected_version (required): The scene’s version from read_manuscript.placement: column, page, spread or float-top.caption: The caption printed with the figure.alt_text: Alt text for screen readers and the ebook.book: The book, when scene is a display number. |
update_figureChange a figure |
codex:write |
Changes a figure’s caption, alt_text, placement or image (asset); an empty caption or alt_text clears it. Or remove it (with expected_version): its ::figure line is taken out and the figure archived, as deleting the card in Write does. undo_id puts the old values, or the line, back. |
figure (required): The figure’s id (from place_figure, or a ::figure line in read_manuscript).caption: New caption; “” clears it.alt_text: New alt text; “” clears it.placement: column, page, spread or float-top.asset: A different image’s asset id.remove: Take the figure out of its scene (needs expected_version, and no other change).expected_version: Removing: the scene’s version from read_manuscript. |
set_openerSet an act or chapter opener |
codex:write |
Sets the full-page opener art of an act (a part opener, as LaTeX \part with its art) or a chapter: asset and an optional caption. clear removes it. undo_id puts the previous opener back. |
target (required): The act or chapter: an id, “act:2”, “5” or “ch:<slug>”.asset: The image’s asset id.caption: The caption printed with the opener.clear: Remove the opener instead.book: The book, when target is not an id (default: the most recently edited book). |
Prompts
Section titled “Prompts”Prompts appear in an agent as commands. They only read, so they need codex:read. Codex checks each write against the token when the agent calls the tool.
| Prompt | What it does | Arguments |
|---|---|---|
resumePick up where I left off |
A briefing from resume_work, then the first pending AI draft to review. | book: The book; default the most recently edited one. |
draft-sceneDraft this scene |
Reads a scene, proposes beats for it and drafts them as pending AI drafts for review in Write. | scene (required): The scene: an id, or a display number like “6.2” with book.book: The book, when the scene is a display number; default the most recently edited one. |
print-readinessGet this book ready to print |
Works through the copyright clearance blocking print, one source at a time, then the layout preview and the printer’s preflight. | book: The book: id, title or “<series>/<number>”; default the most recently edited one. |
triage-referencesTriage unflagged quotes and new uses |
Walks the unflagged-quote inbox and the uses added since sign-off, one at a time. | book: The book: id, title or “<series>/<number>”; default the most recently edited one. |
Resources
Section titled “Resources”Resources are read-only context an agent can pin. They need codex:read.
| Resource | What it holds | Format |
|---|---|---|
codex://booksLibrary |
The Library, as list_books returns it. | application/json |
codex://book/{id}/outlineBook outline |
A book’s outline, as get_outline returns it. | application/json |
codex://book/{id}/style-guideStyle guide |
The style guide every AI draft for the book is sent: the series’ guide, then the book’s. | text/markdown |
codex://scene/{id}Scene prose |
One scene’s prose as stored (Markdown) with its version. | application/json |
codex://kb/{id}Knowledge base entry |
A Knowledge base entry and its additions in book order, as get_kb_entry returns it. | application/json |
codex://book/{id}/referencesReferences |
The book’s References: the clearance summary, every source with its number, status and reason, and the unflagged quotes. | application/json |
Limits
Section titled “Limits”| Setting | Default | What happens at the limit |
|---|---|---|
CODEX_MCP_MAX_GENERATIONS |
20 | A token can start this many draft_prose calls in any hour. The next call fails with rate_limited. |
Errors
Section titled “Errors”A failed call returns a tool error. Its text is JSON with ok set to false and an error object that holds code, message and, for some errors, the extra fields below. A resource or prompt that fails is a protocol error whose message is “code: message”.
| Code | When | Extra fields |
|---|---|---|
not_found |
No match for a ref, including a display number too big for any outline, or a book the token’s user does not own and cannot open through sharing. | candidates: close matches |
ambiguous |
A ref matches more than one thing, such as a book the token’s user owns and a book shared with them that have the same title, or a name two entries share. | candidates. A book or series candidate names its owner, with id and display_name. |
out_of_scope |
The entry exists, but not in the book’s scope, which is the book and its series. | candidates: the entries found. scope: the book and series checked. |
stale_ref |
The server does not return this code at /mcp, because it keeps no session between calls. A display number such as 5.2 always means what it names at the time of the call. If the outline can change between calls, pass ids. |
None |
invalid |
A bad argument: a wrong type, a missing required argument, or an unknown tool name. A call to a tool that /mcp does not offer also fails this way. |
field |
conflict |
The call clashes with the current state. Examples: the expected_version is out of date, an undo comes after the prose has changed again, a draft is no longer pending, a category name is taken, a category still has live entries, a source has no permission request to act on, or an export of the book is already running. |
candidates holds the scene only when expected_version is out of date. Other conflicts have none, and a draft conflict names the draft. |
blocked |
Codex refuses the call. Examples: an undo that is already done (already_undone), expired (undo_expired) or not supported yet (undo_unsupported), or an undo of create_book while an export of the book runs. Codex also refuses when a copyright decision only the author can make in the app (author_decision) is pending, when you sign off a source that is still a copyright risk (copyright_risk), and when you record a permission grant without a signed letter as a file (signed_letter_is_a_file). Codex also refuses a print export with open blocks in queue mode. draft_prose fails this way when the provider declines to write the passage before the first chunk, and the message says to reword the beat and try again. |
rule is there when the tool sets one, and the print export, provider and archive refusals have none. open_url comes with author_decision and copyright_risk. For signed_letter_is_a_file the link is in the message. |
needs_confirmation |
Moving a book into, between or out of series copies the Knowledge base of the series it leaves, and an undo cannot reverse that. Codex writes nothing until you repeat the call with confirm set to true. |
None |
not_configured |
The server or your account lacks something the tool needs, and the message says what. Examples: the server setting CODEX_BLOB_ROOT for images and permission letters, no AI provider connected for draft_prose, or a provider that rejects the key or has no credit. |
None |
rate_limited |
The token has started its limit of draft_prose calls in the last hour. See Limits above. |
None |
forbidden |
The token lacks the scope the tool needs, or the token’s user has a role on the book below what the call needs. A view-only role fails every write. | field: the scope it needs. Nothing for a role. |
unauthorized |
A missing, unknown, revoked or expired token, or one whose user is disabled. At /mcp this is an HTTP 401 with WWW-Authenticate: Bearer realm="codex", not a tool error. |
None |
internal_error |
A fault in the server, or a model provider that is busy, cannot be reached or cannot use the request before the first chunk of a draft. For a server fault the message is fixed and the details go to the server log. For a provider the message says what to do: try again when it is busy or cannot be reached, and check the model and the beat when it cannot use the request. | None |