Authoring workflow
How an agent edits an ImageFlow book through the MCP server. The template API topics describe what a template can declare; this topic describes the order of work and which tool does what.
Orientation
- Call
list_projectsto get the handle and input revision of the open, authorized book. - Call
get_authoring_context. It returns the parsed template declarations (template), saved and current template identity, the files undertemplate/, a table of contents of the API reference (topics) and the shipped examples (examples). Ask for the topics you need withdocs: ['list-parameters', …], for example sources withincludeExamples: ['minimal'], and for template or Markdown files withincludeSource. Those calls return just what they ask for, without the declarations again; one for topics or examples alone has norevisioneither. - Call
inspect_bookfor the saved spreads, sources and parameter values. Theelementsview measures boxes and elements of one spread after whole-book text flow.
Editing
- Edit
template/TSX, CSS and assets directly with your workspace tools. - Edit registered Markdown at its source location; linked Markdown stays outside the package.
- Edits to Markdown and
template/files are not Undo steps in ImageFlow, and the book's history records their names, not their contents: onlyapply_project_changes,import_sourcesandrename_sourcesaves can be undone in the app. Before a larger pass over texts or template files, such as a proofreading or translation pass, keep a copy of the files you change (or use the book's git repository, if it has one) and tell the user how to go back. - Use
apply_project_changesfor sheet/page changes inproject.jsonand metadata changes inphotos.json. See Project commands and preview targets for examples. Address split-page content withpage: 'left' | 'right'besidespread; unaddressed content commands returnSPREAD_SHOWN_AS_PAGES. - While an editor is active, dry runs and draft checks still validate against saved inputs. Saves that change only other spreads go through; a blocked save (one touching the editor's spread or page, or anything book-wide) reports
EDIT_IN_PROGRESSwith the active editor when available.inspect_bookwithview: "summary"also shows it. - Copy new content into
inbox/and callimport_sources. Then assign the returned IDs with a command batch. - Parameter commands use saved scopes:
document,spread,boxorelement. An element editor can also own spread parameters; usescope: 'spread'for those fields, notscope: 'element'. - Mark a single user-written string the page prints with
<ctx.Text presentation="inline">, so it is typed where it prints (inline-text). Small text at whole-spread zoom opens the panel instead. - To find the parameter a request means, read each parameter's description with its unit, range and options. Give new parameters a description when their meaning or direction is not obvious from the label.
- To start or extend a template, read the package topic's example table, fetch the closest example with
includeExamplesand copy its layout. - For an empty book, inspect
template.openingSpreadsand insert suitable layouts withinsert_spreador facing page pairs withinsert_page_pair.openingSpreadsdescribes new-book defaults and is not applied again automatically. - Use a layout family when layouts are variants of one design (
template.layoutFamilies;familyandvarianton each layout). Give a family achoicepicker, which the app draws, unless it needs a component for more than one tag; pickers choose by variant tags, not hard-coded IDs. Switch variants withswitch_layoutand the layout ID of the variant (Layout families).
Verifying
- Call
check_bookwith a spread preview after every edit. Images include whole-book text flow. Layout errors carry the spread and template source line; text that runs out of its box or overlaps other text is reported per block. - Set
typescript: trueto type-check template sources against the installed runtime. Type errors do not suppress usable images. - Preview a new or unused layout before saving it: call
check_bookwithdraft.operations(aninsert_spreadwith aref) and target the preview at its$ref. Then apply the same operations withapply_project_changesto save them. A book whose page count the format does not take yet (one spread added to a book that grows in steps of four pages) gets apage-sequencewarning that names the pages to fill before export; save it anyway, and fit the page count before export, where it is an error. - Use
preview.target.spreadsfor a contact sheet of up to 12 spreads, andboxorelementtargets for close-ups.guidesandlabelsadd trim, safe-area and box outlines. - Stress-test layouts with
check_bookfixtures: synthetic typical, long, empty, portrait-photo, valid-GPX and malformed-file content per format, with a coverage matrix and a bannered fixture contact sheet that is never the saved book. Coverage names the checks that did not run.paramsanddocumenttest settings at other values than their defaults, such as{ "photoEdge": "bleed" }. - To choose photos, call
inspect_bookwithview: "sources",unplaced: trueorcaptured: { from, to }, andsheet: {}: an image of up to 48 photos, uncropped, with their IDs and capture times. Photo records carry the original'swidthandheightin pixels where they are known. - To see how sharp placed photos print, call
check_bookwithinspect: { spread }: each photo box hasprintwith the original'swidthPxandheightPxand theppiit prints at,measured: truewhere the render measured it, asrender.photoResolutioncounts it, or estimated from the size its source reported for a photo the render has no size for, such as one whose file is unavailable (ppi: nullwithout a known size). Compare it afterreplace_source.
Revisions
Every result carries the input revision. Pass it as expectedRevision to commands, page-number previews and drafts. A REVISION_CONFLICT means the book changed: inspect or check again before editing. Its changed lists the files that differ from the revision you passed (project.json, a text, a template file), where ImageFlow still knows that revision, and its message names the first few. Template files are inputs too, so editing template/ also changes the revision: after a template edit, take the new revision from check_book before the next apply_project_changes, or it is rejected once. When the user saves the book in ImageFlow during a check, or photos change in Lightroom, the result stands for the revision it names, and superseded.revision is the one to edit next; get_authoring_context and inspect_book then return the book as it is now, with checkedRevision for the diagnostics of the one before. When template files, texts or photo files change, the call is repeated for you until the book is quiet; a SOURCE_CHANGED error means it kept changing, and names what changed. A dry run or draft against a revision that has since changed is planned at the current one and says so in revisionMoved and notice; a commit always needs the exact revision. Commands need a unique idempotencyKey, so a retry of the same request after a lost reply returns the original result instead of applying the batch twice, also after ImageFlow restarts. After reopening a book, list_book_checkpoints with the key confirms whether a batch was committed and lists what changed since.