Agents & MCP
Drawing with create_nodes
create_nodes is the tool an agent draws with. It takes a list of nodes, each with nested children, and makes them all in one step. The same property names are used by update_nodes to change a node and by get_nodes to read it back, so what you learn here applies to all three. This article covers the properties that decide how a design looks, then builds a phone screen in one call.
The properties that matter most#
| Property | Value | What it does |
|---|---|---|
kind | frame, text, rectangle, ellipse, line, path, group, component, instance, boolean | Required. A frame is a screen or a container. |
x, y | numbers | Relative to the parent. On a page they are canvas coordinates. |
width, height | a number, or in a layout "fill", "hug", "50%" | A fixed size, a share of the space left, or the size of the content. |
fill, fills | a hex color, a gradient or an image; fills is a list, last on top | A frame has no background until you give it one. |
stroke, stroke_width | as fill; a number (1) | stroke_align is center, inside or outside. stroke_widths: [1, 0, 0, 0] strokes one side. |
corner_radius | one number, or four from top-left clockwise | corner_smoothing: 0.6 gives the continuous corner of iOS icons. |
layout | {direction, gap, padding, align, cross_align, wrap} | Auto layout: children are placed in a row, a column or a grid and need no x and y. |
text | a string, or a list of pieces with their own style | With font_family, font_size, font_weight, line_height, letter_spacing, text_align. |
effects, shadow | a list of drop_shadow, inner_shadow, layer_blur, background_blur, glass, noise | shadow alone is one drop shadow. |
depth | {elevation, softness, tint, angle, rim} | Lighting as one control: a soft shadow of five layers. Prefer it to stacking shadows by hand. |
bindings | {"fill": "color/accent"} | Makes a property follow a variable, named by its name or id. |
component, overrides | a component's id; a list of {target, …} | On an instance: which component it shows, and what it shows differently. |
A few details decide quality:
- Gradients.
{"gradient": "linear", "angle": 135, "mixing": "oklch", "stops": ["#5B5BD6", "#A35BD6"]}.oklchmixing avoids the dull middle between two bright colors. - Layout padding is one number,
[vertical, horizontal], or[top, right, bottom, left].alignruns along the direction and takesspace_between.cross_alignruns across it. - Outside the flow.
free: trueplaces a child of a layout by its ownxandy, like a tab bar.pinsays which edges it holds to when its frame is resized. - Line height is in units, baseline to baseline:
font_size: 20, line_height: 30. - Labels that change.
text_truncatewithmax_linescuts a text with an ellipsis.text_fit: 28lets a text shrink to 28 to fit its box. - Depth.
{"elevation": 45, "softness": 70, "tint": 60}puts 60% of the node's own color into its shadow, which suits a colored card.
A whole screen in one call#
Build a screen in one call, not node by node. One call is one step for you to review, and the layout is worked out once with everything in place.
A component has to exist before its instances, so this screen takes two calls. The first makes a Row component beside the screen:
{
"nodes": [
{
"kind": "component", "name": "Row", "x": 480, "y": 0, "width": 350, "height": 68, "fill": "#FFFFFF", "corner_radius": 16,
"layout": {"direction": "horizontal", "gap": 12, "padding": [12, 16], "cross_align": "center"},
"children": [
{"kind": "rectangle", "name": "Tile", "width": 44, "height": 44, "corner_radius": 12, "fill": "#EEF0FF"},
{
"kind": "frame", "name": "Words", "width": "fill", "height": "hug", "layout": {"direction": "vertical", "gap": 2},
"children": [
{"kind": "text", "name": "Title", "text": "Title", "font_family": "Inter", "font_size": 16, "font_weight": 600, "fill": "#111318"},
{"kind": "text", "name": "Detail", "text": "Detail", "font_family": "Inter", "font_size": 13, "fill": "#5E6472"}
]
},
{"kind": "text", "name": "Time", "text": "0:00", "font_family": "Inter", "font_size": 13, "font_weight": 600, "fill": "#5E6472"}
]
}
]
}
The reply gives every new id, nested as the nodes were: here 100:1 for the component, 100:2 for the tile, 100:4, 100:5 and 100:6 for the three texts. The second call uses them. It makes the screen, 30 nodes, with three instances that override the texts and the tile's color:
{
"nodes": [
{
"kind": "frame", "name": "Today", "x": 0, "y": 0, "width": 390, "height": 844, "fill": "#F4F5F8", "clips_content": true,
"safe_area": [47, 0, 34, 0],
"layout": {"direction": "vertical", "gap": 12, "padding": [64, 20, 0, 20]},
"children": [
{"kind": "text", "name": "Date", "text": "Tuesday, December 2", "font_family": "Inter", "font_size": 13, "font_weight": 600, "fill": "#5E6472"},
{"kind": "text", "name": "Heading", "text": "Today", "font_family": "Inter", "font_size": 34, "font_weight": 700, "letter_spacing": -0.5, "fill": "#111318"},
{
"kind": "frame", "name": "Goal", "width": "fill", "height": 168, "corner_radius": 24, "corner_smoothing": 0.6,
"fill": {"gradient": "linear", "angle": 135, "mixing": "oklch", "stops": ["#5B5BD6", "#A35BD6"]},
"depth": {"elevation": 45, "softness": 70, "tint": 60},
"layout": {"direction": "vertical", "padding": 20, "align": "space_between"},
"children": [
{
"kind": "frame", "name": "Goal words", "width": "fill", "height": "hug", "layout": {"direction": "vertical", "gap": 4},
"children": [
{"kind": "text", "name": "Goal label", "text": "Weekly goal", "font_family": "Inter", "font_size": 13, "font_weight": 600, "fill": "#FFFFFFCC"},
{"kind": "text", "name": "Goal value", "text": "4 of 5 workouts", "font_family": "Inter", "font_size": 28, "font_weight": 700, "fill": "#FFFFFF"}
]
},
{
"kind": "frame", "name": "Track", "width": "fill", "height": 8, "corner_radius": 4, "fill": "#FFFFFF40",
"layout": {"direction": "horizontal"},
"children": [{"kind": "rectangle", "name": "Done", "width": "80%", "height": "fill", "corner_radius": 4, "fill": "#FFFFFF"}]
}
]
},
{"kind": "text", "name": "Section", "text": "Up next", "font_family": "Inter", "font_size": 17, "font_weight": 600, "fill": "#111318"},
{
"kind": "instance", "component": "100:1", "name": "Morning run", "width": "fill",
"overrides": [
{"target": "100:4", "text": "Morning run"}, {"target": "100:5", "text": "5 km · easy pace"},
{"target": "100:6", "text": "7:30"}, {"target": "100:2", "fill": "#E6F4F1"}
]
},
{
"kind": "instance", "component": "100:1", "name": "Strength", "width": "fill",
"overrides": [
{"target": "100:4", "text": "Strength"}, {"target": "100:5", "text": "Upper body · 40 min"},
{"target": "100:6", "text": "12:15"}, {"target": "100:2", "fill": "#EEF0FF"}
]
},
{
"kind": "instance", "component": "100:1", "name": "Stretch", "width": "fill",
"overrides": [
{"target": "100:4", "text": "Stretch"}, {"target": "100:5", "text": "Hips and back · 10 min"},
{"target": "100:6", "text": "21:00"}, {"target": "100:2", "fill": "#FFF1E6"}
]
},
{
"kind": "frame", "name": "Tab bar", "free": true, "x": 0, "y": 760, "width": 390, "height": 84, "fill": "#FFFFFF",
"stroke": "#E3E5EB", "stroke_widths": [1, 0, 0, 0], "pin": {"horizontal": "both", "vertical": "bottom"},
"layout": {"direction": "horizontal", "align": "space_between", "padding": [16, 40, 0, 40]},
"children": [
{"kind": "text", "name": "Today", "text": "Today", "font_family": "Inter", "font_size": 12, "font_weight": 600, "fill": "#5B5BD6"},
{"kind": "text", "name": "Plans", "text": "Plans", "font_family": "Inter", "font_size": 12, "font_weight": 600, "fill": "#6B7280"},
{"kind": "text", "name": "Stats", "text": "Stats", "font_family": "Inter", "font_size": 12, "font_weight": 600, "fill": "#6B7280"},
{"kind": "text", "name": "Profile", "text": "Profile", "font_family": "Inter", "font_size": 12, "font_weight": 600, "fill": "#6B7280"}
]
}
]
}
]
}

check_design on this frame reports nothing. A first draft with the inactive tabs in #9AA0AE did not pass: 2.62 to 1 on white, where 4.5 to 1 is asked for.
Draw the Today screen in one create_nodes call, with auto layout for every row and column. Make the row a component first and place three instances. Then run check_design on the frame.Limits#
- 2,000 nodes a call, children counted. Split a larger design by screen.
- An unknown property is refused, and the reply lists every property. Nothing is made.
- To make a component and its instances as one step, put both calls in a
batchand name the component as"@0.0". A reference like that names only a top-level node an operation made, not a layer inside it. See Agent recipes.
Common mistakes#
A transform given with x and y#
transform is the node's whole placement as a matrix, [a, b, c, d, x, y], for a scale or a skew. Give it without x, y, rotation or flip. If you give both, no error is raised: x and y take the place of the matrix's last two numbers, and a rotation given beside it is dropped. Put the position in the matrix:
{ "nodes": [{ "kind": "rectangle", "width": 40, "height": 40, "fill": "#FF0000", "transform": [2, 0, 0, 2, 300, 10] }] }
A gradient on a path that does not start at its origin#
A gradient's from and to are in units of the node's box, and a path's box is measured from the node's own origin (its x, y), not from where the outline begins. A path drawn as M100 0 L380 0 … has a box 380 wide, so a gradient across it has run a quarter of its way before the shape starts.
{
"nodes": [
{
"kind": "path", "name": "Away from the origin", "x": -72, "y": 64, "path": "M100 0 L380 0 L380 96 L100 96 Z",
"fill": {"gradient": "linear", "from": [0, 0], "to": [1, 0], "stops": ["#5B5BD6", "#F59E0B"]}
},
{
"kind": "path", "name": "From the origin", "x": 392, "y": 64, "path": "M0 0 L280 0 L280 96 L0 96 Z",
"fill": {"gradient": "linear", "from": [0, 0], "to": [1, 0], "stops": ["#5B5BD6", "#F59E0B"]}
}
]
}

Draw the path from 0 0 and place it with x and y.
Guessing how wide a text is#
An agent cannot know how wide "Start free trial" is in Inter 15. Do not let it guess a width and center by arithmetic. Put the text in a frame with a layout and width: "hug", and let the layout measure it. Read the result back with get_nodes: a button with 20 of padding each side around that label came back 139.822 wide, so the label is 99.822.