Skip to content

MCP Overview

Caja implements a Model Context Protocol server, allowing AI agents to interact with the design canvas programmatically.

How It Works

  1. An MCP client (Claude Code, Cursor, etc.) connects to Caja via stdio
  2. The agent discovers available tools and resources
  3. The agent calls tools to build and modify layouts
  4. Changes appear in real-time on the canvas

Available Tools

Frame Manipulation

ToolDescription
add_frameAdd a new element (box, text, image, button, input, etc.)
update_frameUpdate properties of an existing frame
update_spacingUpdate padding, margin, or inset
update_sizeUpdate width or height (hug, fill, fixed)
remove_frameDelete a frame from the tree
move_frameMove a frame to a new parent
wrap_frameWrap a frame in a new parent box
duplicate_frameDeep clone a frame

Tree Operations

ToolDescription
rename_frameRename a frame
select_frameSelect a frame in the UI
get_treeRead the full frame tree (flags responsive overrides)
get_selectedGet the currently selected frame
batch_updateExecute multiple operations in a single undo step

Responsive

ToolDescription
set_breakpointActivate a responsive breakpoint (base, md, sm)
get_breakpointGet current active breakpoint and canvas width
get_responsive_overridesGet responsive overrides for a frame
clear_responsive_overridesClear overrides at a breakpoint

Components

ToolDescription
list_componentsList available reusable components
insert_componentInsert a component instance
save_componentSave a frame as a reusable component
delete_componentDelete a component
export_libraryExport components as a .cjl file

Media

ToolDescription
screenshotTake a screenshot of the canvas
upload_assetUpload an image asset

Pages & Files

ToolDescription
new_fileReset to blank state
list_pagesList all pages
switch_pageSwitch to a different page
add_pageAdd a new page
remove_pageRemove a page

See the Tools Reference for detailed schemas and examples.

Tailwind Classes Shortcut

Most tools accept a classes parameter — a Tailwind class string that gets parsed into frame properties:

"classes": "flex gap-4 p-8 bg-blue-500 rounded-lg"

This is the fastest way to style elements, and it's what AI agents use most.

Responsive Workflow

The MCP responsive workflow follows a desktop-first approach:

  1. Build the base layout at the base (desktop) breakpoint
  2. Call set_breakpoint({ breakpoint: "md" }) to switch to tablet
  3. Use update_frame, update_spacing, or update_size — changes are saved as sparse overrides
  4. Call set_breakpoint({ breakpoint: "sm" }) for mobile adjustments
  5. Call set_breakpoint({ breakpoint: "base" }) to return to desktop

Only properties that differ from desktop are stored. The exported code uses max-md: and max-sm: prefixed Tailwind classes.