Read the canvas
canvas-readRead the canvas of an artifact the person has open in Agent Grid's Live Canvas. action picks what to read, and takes the parameters listed with it:
outline [rootId, depth]: Cheap orientation map of the open design file: pages, then one line per node — id, type, name, position (parent-local), size, flags. Flags: artboard; live-page (its layers are a snapshot of a running page — canvas-read action=html returns the page, canvas-replace_html swaps it); auto-layout:; img: (an image fill, reusable in your own fills); ref: on an instance; hidden; locked. Call this first; use the ids it returns with every other tool.
html [id required]: The canonical serialized HTML of a node subtree (pass a node id, e.g. an artboard from canvas-read action=outline) or a whole page (pass a page id). This is the document format itself: elements carry data-ac-* attributes (data-ac-model JSON = geometry/fills/effects, data-ac-layout = auto-layout, data-ac-text = typography; text content is the element text). Image fills reference assets as ../../assets/. Edit this HTML and send it back via canvas-replace_html / canvas-insert_html. Exception: for the artboard of a live page (an HTML page that runs its own scripts — see canvas-insert_html) it returns that page's own HTML as written, scripts included, with the user's unsaved canvas edits merged in; edit it and send the whole page back with canvas-replace_html on the artboard.
selection: The user's current selection: node ids + world-space bounding box. The shared pointer between user and agent — “make this blue” starts here.
screenshot [nodeId, scale]: Render a node/artboard to a PNG image for your own eyes — visual ground truth from the export renderer. Defaults to the selection, else the first artboard. Use it to check your own work after edits. For an image the user keeps, use canvas-read action=export_png.
assets: The file's image asset manifest (id, mime, dimensions). Reuse an existing assetId in an image fill instead of re-uploading identical bytes.
pages: Pages in the open file (id, name, which is current).
export_html [nodeId required]: Export a node/artboard as a standalone HTML document with every asset inlined as data: URIs — opens in any browser as-is. (canvas-read action=html is the lighter read for editing; this is the shippable deliverable.)
export_png [nodeId required, scale]: Export a node/artboard as PNG bytes. scale 2 (default) stamps pixel density so the image pastes back at logical size.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"sessionId": "<sessionId>",
"action": "<action>"
},
"name": "canvas-read"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | html: Node id or page id | |
| depth | No | outline: Levels to show, counting the page (or rootId) as the first: default 3 for the page (its artboards and their direct children), 4 under a rootId | |
| scale | No | screenshot: Render scale, 0.25–2. Default: the longer side fits 1200 px, at most scale 1 and at least 0.25 (a page taller than 4800 px comes out taller; screenshot a section of it instead); export_png: Render scale 0.25–4, default 2 | |
| action | Yes | One of: outline, html, selection, screenshot, assets, pages, export_html, export_png. | |
| nodeId | No | screenshot: Node to render (default: selection or first artboard); export_html: Node id (usually an artboard); export_png: Node id | |
| rootId | No | outline: Node id to outline from (defaults to the current page) | |
| sessionId | Yes | The artifact's id (its sessionId), from canvas-get_open or workspace-list_artifacts. |