Batch Operations

Batch operations allow you to create, update, or manipulate multiple elements in a single MCP call, with features like client-specified IDs, nested children, and optimized performance.

Client-Specified IDs

Pre-assign element IDs when creating elements for easy reference in subsequent operations.

Why Use Client IDs?

ID Validation Rules

Example: Building a Card

# Create frame with known ID
create_frame({"id": "card-001", "x": 100, "y": 100, "width": 320, "height": 200})

# Add title (nested inside card)
create_text({
  "id": "card-001-title",
  "text": "Card Title",
  "parentId": "card-001",
  "x": 16,
  "y": 16
})

# Add body (nested inside card)
create_text({
  "id": "card-001-body",
  "text": "Card content here",
  "parentId": "card-001",
  "x": 16,
  "y": 50
})

# Later: Update specific part
update_element({
  "id": "card-001-title",
  "props": {"text": "Updated Title"}
})

Nested Children

Create entire element hierarchies in a single operation using the children parameter.

Features

Example: Nested Button

create_frame({
  "id": "button",
  "x": 100,
  "y": 200,
  "width": 200,
  "height": 48,
  "borderRadius": 8,
  "fills": [{"type": "solid", "color": "#007AFF"}],
  "children": [
    {
      "type": "text",
      "id": "button-label",
      "text": "Click Me",
      "x": 60,
      "y": 14,
      "props": {
        "fontSize": 16,
        "fontWeight": "600",
        "textColor": "#FFFFFF"
      }
    },
    {
      "type": "icon",
      "id": "button-icon",
      "name": "arrow-right",
      "x": 160,
      "y": 12,
      "size": 24,
      "color": "#FFFFFF"
    }
  ]
})

Limits

Coordinate System

Child coordinates are relative to parent. API accepts relative positions but stores absolute coordinates internally. This simplifies nested layout creation.

Response Format Options

Control response payload size with the responseFormat parameter.

minimal (Default)

Smallest payload - just success status, ID, and count

{
  "success": true,
  "id": "element-001",
  "elementCount": 1
}

full

Complete element data included in response

{
  "success": true,
  "id": "element-001",
  "element": {
    "id": "element-001",
    "type": "rectangle",
    "x": 100,
    "y": 100,
    "width": 200,
    "height": 200,
    "fills": [{"type": "solid", "color": "#FF0000"}]
  },
  "elementCount": 1
}

ids_only

Just the array of created element IDs

{
  "success": true,
  "ids": ["element-001", "element-002", "element-003"]
}

Usage

create_rectangle({
  "x": 100,
  "y": 100,
  "width": 200,
  "height": 200,
  "responseFormat": "full"  // or "minimal" or "ids_only"
})

Batch Create Examples

Grid of Squares

"Create a 5x5 grid of squares, each 80x80, starting at 100,100 with 10px spacing"

Claude will:

Color Palette

"Create 8 color swatches (60x60) with colors: red, orange, yellow, green, blue, indigo, violet, pink"

Claude will:

Social Media Icons

"Insert Font Awesome icons for Facebook, Twitter, Instagram, LinkedIn, and YouTube in a row"

Claude will:

Batch Update Examples

Change All Colors

"Change all rectangles to blue"

Claude will:

Align Multiple Elements

"Select elements card-001, card-002, card-003 and align them vertically with 20px spacing"

Claude will:

Performance Optimizations

Batch Parent Updates

When creating multiple children in same parent:

Minimal Response Format

For bulk operations:

Namespace Lazy Loading

Tools load on-demand:

Error Handling

Validation Errors

Operations fail with descriptive errors if:

Rollback on Failure

If batch operation fails partway:

Best Practices

Related Topics