# Control protocol Start the app with `--control `. The server listens on `127.0.0.1` only and speaks JSON lines: one request object per line, one reply per line. Authenticate before sending app methods, using the server's token or its challenge-response handshake. Before authentication, a request line is limited to 1 MiB. Authenticated request lines and replies are limited to 256 MiB. Malformed JSON gets an error reply and the connection continues serving subsequent lines. Blank lines are skipped. The connected MCP client requires the reply's numeric `id` to match its request, `ok` to be a boolean, and exactly one of `result` (success) or a string `error` (failure). It accepts CRLF and rejects EOF inside a reply. Invalid replies invalidate the connection and leave the command's outcome unknown; the client does not replay it. Unsolicited bytes already buffered between calls force a reconnect before sending. The server allows 16 connections and 64 queued requests; excess work receives a `busy` error. Connections close after 10 minutes idle or 30 seconds blocked writing a reply. The UI reply wait is 60 seconds. An `expired` reply means the request was never dispatched and cannot run later. A `timeout` reply means it was dispatched and may still apply; its outcome is unknown. The client must not automatically retry a timed-out mutation. ```json {"id": 1, "method": "engine.execute", "params": {"command": "shape.insert", "params": {"preset": "roundRect", "rect": [100, 100, 240, 120], "text": "Hello"}}} {"id": 1, "ok": true, "result": {"id": 258}} ``` Coordinates are slide points (1/72 inch; a 16:9 slide is 960 × 540) unless noted. | Method | Params | What it does | |---|---|---| | `engine.execute` / `ui.menu.invoke` / `command` | `{command, params}` | Run any command (see `engine.commands`; `deckcraft-cli describe COMMAND` documents one) | | `engine.commands` | — | Every command: id, label, menu path, shortcut, params doc, enabled / disabled reason | | `document.inspect` | — | Slides, sections, layouts, shapes, selection | | `ui.inspect` | — | UI state, active tool, window/canvas/slide rects, `dialogs`, `palette`, `home` (the File tab over an open presentation), `backstage` (the current File page, including the start screen), slide show state (`grid`, `zoomArm`, `zoom`, `blank`, `presenterPaused`, `presenterSecs`, `notesPx`, `custom`, `goto`; `cells` when See All Slides is open), `animPreview` (canvas playback: slide, time, duration), documents, perf (frame ms, render ms) | | `ui.tool.select` | `{tool, preset?}` | `select`, `text`, `shape` + preset, any preset name, `curve`, `freeform`, `scribble`, `pen`, `highlighter`, `eraser` | | `ui.pointer` | `{events: [{kind: down\|drag\|up\|move\|doubleclick\|tripleclick\|contextclick, x, y, mods?, pressure?}], mods?}` | Send slide-point pointer events through the active tool's mouse path. `contextclick` performs the right-click selection used by context menus; `pressure` is `0..=1` for a pen and can be omitted for a mouse | | `engine.key` | `{key, shift?, alt?, cmd?}` | Send a key press. During an active slide show, digits followed by Enter jump to that slide; G opens See All Slides, Z arms zoom, T toggles the presenter timer's pause, R resets it, and `[` / `]` resize notes. Esc clears a typed slide number or backs out of the grid/zoom before ending the active show. Close See All Slides with Esc or G before using the other listed show shortcuts. Slide-show keys ignore modifier flags; use `show.end` to leave the end-of-show screen. Outside a show, Escape stops canvas animation preview | | `engine.text` (also `ui.text`) | `{text}` | Insert into the current text edit. With one shape selected and no active text edit, begin editing and replace the shape's existing text | | `ui.key` / `ui.type` / `ui.ime` | `{key, modifiers?, hold?, window?}` / `{text, window?}` / `{preedit, cursor?: [start,end], window?}` or `{commit, window?}` | Input through the window's focused control; IME cursor offsets count characters (`active` is another name for `cursor`). `engine.key` and `engine.text` address the session directly | | `ui.click` / `ui.move` / `ui.release` | Screen points, a named control, or for `ui.click` and `ui.move` a widget's `label` or `id`; optional `window` | Window input reaches widgets, menus and panes. `ui.move {label}` hovers the centre of the one widget with that label | | `ui.drag` | `{x, y, toX, toY, coordinates?, page?, steps?, button?, window?}`, or the library's `{from: {x, y, coordinates?, page?}, to: {...}, steps?, button?, modifiers?, window?}` | A press at the start, `steps` moves and the release at the end. The flat form puts both points in one space; the `from`/`to` form gives each point its own and can hold modifiers through the drag. A drag with a pause is `ui.click {hold: true}`, `ui.move`, then `ui.release` | | `ui.focus` / `ui.find` | A named control and optional `window`; `ui.find` takes `{name, role?, within?, index?, window?}` | Focus or inspect a control through the window's accessibility tree. `within` names an ancestor; `index` selects a match in reading order | | `ui.accessTree` | `{}` | Return the main window's settled accessibility tree, waiting for a presented tree when necessary | | `ui.window` | `{maximized: bool, window?: docWindow\|presenter}` | Maximize or restore the named window, or the main window when omitted; refused where window commands are unavailable (desktop only) | | `ui.wheel` / `ui.drop` / `ui.capsLock` | Library synthetic-input parameters | Wheel input, file drops and Caps Lock state through the window host | | `ui.set` | `{tab?, view?, pane?, notes?, zoom?, dark?, recent?, palette?: {query, selected?}, backstage?: {page?, query?, exportTask?, fileType?, printLayout?, printRange?}, paneWidth?, thumbsWidth?, notesHeight?, caretBlink?, presenterView?, handoutPerPage?, …}` | Set UI state and return the full state. Pane sizes are finite numbers in points, clamped to the supported ranges. `caretBlink: false` requests a solid editor caret; true inherits the motion policy. `recent` is a list of paths. Palette selection is a displayed-result ordinal, excluding headings and dividers; it is normalized by the palette. File-page keyboard focus uses `ui.focus` on the entry label | | `ui.notify` | `{text, kind?: toast\|status}` | Post a notice; the default kind is `toast` | | `ui.dialog.open` | `{id, params?, fields?}` | Open a dialog through its registered implementation; `fields` pre-fills its fields, and `tab` among them picks the tab Bullets and Action Settings open on | | `ui.dialog.set` / `ui.dialog.confirm` / `ui.dialog.cancel` / `ui.dialog.close` | Dialog selector and fields for `set` | Edit or answer the real hosted dialog; closing follows its cancel path. A value may be text: a number field takes its digits, a check box `1`/`0` or `true`/`false`. Some dialogs also take these names: Find `text` (Find what), Hyperlink `mode: slide` (a place in this document), Action Settings `kind` (`none`, `program`, `playMedia` or a hyperlink target such as `url`), Paragraph `lineKind` (`multiple` or `exactly`) and `lineValue`, Tabs `stops` as `position:align\|…` (inches; `l`, `ctr`, `r`, `dec`), Reuse Slides `off{index}: 1` (untick a slide). A value outside a field's range is refused at `set` | | `ui.screenshot` | `{path?, region?: [x0,y0,x1,y1], window?: docWindow\|presenter}` | Capture a PNG of the named window or the main window. A region is in window points. Without a path, return `{base64, mime, width, height, pixels_per_point}`; with a path, return `{path, width, height, pixels_per_point}`. Unknown or closed windows are refused | | `ui.render` | `{path?, slide?, scale?}` | Render a slide headlessly | | `ui.resize` / `app.focusWindow` | `{width, height}` / `{}` | Resize or focus the main OS window | | `show.start` / `show.end` | `{from?: slide index, custom?: name, reading?, rehearse?, transitionPreview?, presenter?}` / `{}` | Play or end a show. `custom` plays that custom show without changing Set Up. Otherwise, the default starts at the first slide of the show order. A `from` that is not a slide is refused; a hidden slide plays. `presenter: true` forces Presenter View, including in reading mode. `transitionPreview` cannot combine with `rehearse`, `presenter` or a custom show | | `ui.show.hold` | `{t: number\|null}` | Hold show clocks at elapsed seconds, or release the hold with `null` | | `ui.animPreview` | `{time: number\|null}` | Hold the canvas animation preview, or release the hold with `null`; without a preview return `{held: false}` | | `ui.eyedropper` | `{mode: menu\|transparent}` | Arm the canvas colour sampler | | `app.open` | `{path, background?}` or `{paths, source: "os"}` | Open a file, start its background open, or process an OS open batch | | `app.reuseSlidesDialog` | `{path}` | Open the reuse-slides chooser for a presentation | | `ui.update.offer` | `{tag}` | Offer the named update through the update dialog (desktop only) | | `ui.prefs` | `{units: in\|cm}` | Apply the length-unit preference through Preferences | | `ui.iconSheet` | `{filter?: string, open?: bool}` | Open and filter the icon sheet, returning `{open, icons}`. `open` defaults to true; false closes it | | `ui.contextMenu` | `{part, key}` | Queue a context menu for a slide, section, animation, Selection object or flagged notes word | | `ui.paneState` | `{part: selection\|sorter, fold?, rename?}` | Replace folded groups or sections, or request a rename. `rename: null` cancels a rename, including a pending start. Selection keys are shape IDs; sorter keys are section indices | | `app.save` / `app.export` / `app.quit` | `{path?, …}` / `{path, …}` / `{save?: bool}` | Save, export using `file.export` parameters, or quit. Quit discards without prompting unless `save: true` asks to save every presentation first | `docWindow` targets the document window after its first displayed pass. `presenter` targets the Presenter View's recorded local viewport while that window is open. A remote browser presenter without a locally registered viewport is unavailable for window input and screenshots. The MCP server (`deckcraft-cli mcp`, see [mcp.md](mcp.md)) wraps the same methods for Claude and other agents; `deckcraft-cli app --method METHOD [PARAMS]` sends one request from a shell. ## Inspecting slide actions Run the `slide.actions` engine command through `engine.execute`: ```json {"id": 2, "method": "engine.execute", "params": {"command": "slide.actions", "params": {"index": 0}}} ``` `index` is zero-based and optional; omitting it inspects the selected slide. The reply's `result` contains `{index, slideId, actions}`. Each action includes an `owner` with the shape id/name and its group path; text actions also identify the paragraph/run and run text, plus the table row/cell for table text. Actions report their `event` (`click`, `hover`, `textLink`, or `textHover`), `type`, `target`, and full `hyperlink`. Inspection never runs an action. A slide without actions returns `"actions": []`.