Skip to content

MCP Server

OpenPencil includes an MCP (Model Context Protocol) server that lets AI coding tools — Claude Code, Cursor, Windsurf, etc. — read and modify .fig files headlessly.

Two transports: stdio for MCP clients, HTTP for everything else.

Install

sh
bun add -g @open-pencil/mcp

Stdio (Claude Code, Cursor, etc.)

Add to your MCP config (e.g. ~/.claude/settings.json or .cursor/mcp.json):

json
{
  "mcpServers": {
    "open-pencil": {
      "command": "openpencil-mcp"
    }
  }
}

Or run from source without installing:

json
{
  "mcpServers": {
    "open-pencil": {
      "command": "bun",
      "args": ["/path/to/open-pencil/packages/mcp/src/stdio.ts"]
    }
  }
}
json
{
  "mcpServers": {
    "open-pencil": {
      "command": "npx",
      "args": ["tsx", "/path/to/open-pencil/packages/mcp/src/stdio.ts"]
    }
  }
}

HTTP

For browser extensions, scripts, CI, or any HTTP client:

sh
openpencil-mcp-http

Or from source: bun packages/mcp/src/index.ts / npx tsx packages/mcp/src/index.ts

Security defaults (HTTP transport):

  • Binds to 127.0.0.1 by default (HOST to override)
  • eval tool is disabled
  • File operations are limited to OPENPENCIL_MCP_ROOT (defaults to current working directory)
  • CORS is disabled by default; set OPENPENCIL_MCP_CORS_ORIGIN to allow one origin
  • Optional auth token: OPENPENCIL_MCP_AUTH_TOKEN (client sends Authorization: Bearer <token> or x-mcp-token)

Server starts on port 7600 (override with PORT env var). Endpoints:

  • GET /health — server status
  • POST /mcp — MCP Streamable HTTP (SSE). Sessions via mcp-session-id header.

Workflow

  1. Openopen_file to load an existing .fig, or new_document for a blank canvas
  2. Readget_page_tree, find_nodes, get_node, list_pages
  3. Createcreate_shape, render (JSX)
  4. Modifyset_fill, set_stroke, set_layout, update_node, set_effects
  5. Structurereparent_node, group_nodes, clone_node, delete_node
  6. Savesave_file to write back to .fig

AI Agent Skill

Teach your AI coding agent to use OpenPencil tools:

sh
npx skills add open-pencil/skills@open-pencil

Works with Claude Code, Cursor, Windsurf, Codex, and any agent that supports skills. The skill covers the CLI, MCP tools, JSX rendering, eval, and the running app's automation bridge.

Tools (90)

Document

ToolDescription
open_fileOpen a .fig file for editing
save_fileSave the current document to a .fig file
new_documentCreate a new empty document

Read

ToolDescription
get_selectionGet currently selected nodes
get_page_treeGet the full node tree of the current page
get_current_pageGet the current page name and ID
get_nodeGet detailed properties of a node by ID
find_nodesFind nodes by name pattern and/or type
get_componentsList all components in the document
list_pagesList all pages
list_variablesList design variables
list_collectionsList variable collections
list_fontsList fonts used in the current page
page_boundsGet bounding box of all objects on the current page
node_boundsGet bounding box of a node
node_ancestorsGet ancestor chain of a node
node_childrenGet direct children of a node
node_treeGet the subtree rooted at a node
node_bindingsGet variable bindings on a node

Create

ToolDescription
create_shapeCreate a shape (FRAME, RECTANGLE, ELLIPSE, TEXT, LINE, STAR, POLYGON, SECTION)
create_vectorCreate a vector node from a path string
create_sliceCreate an export slice
create_pageCreate a new page
renderRender JSX to design nodes — create entire component trees in one call
create_componentConvert a frame/group into a component
create_instanceCreate an instance of a component
node_to_componentConvert an existing node into a component in-place

Modify

ToolDescription
set_fillSet fill color (hex)
set_strokeSet stroke color, weight, alignment
set_effectsAdd shadow or blur effects
update_nodeUpdate position, size, opacity, corner radius, text, font
set_layoutSet auto-layout (flexbox) — direction, spacing, padding, alignment
set_constraintsSet resize constraints
set_rotationSet rotation angle in degrees
set_opacitySet opacity (0–1)
set_radiusSet corner radius (uniform or per-corner)
set_minmaxSet min/max width and height constraints
set_textSet text content of a TEXT node
set_fontSet font family and weight
set_font_rangeSet font properties on a character range
set_text_resizeSet text auto-resize mode (fixed/auto-width/auto-height)
set_visibleShow or hide a node
set_blendSet blend mode
set_lockedLock or unlock a node
set_stroke_alignSet stroke alignment (inside/center/outside)
set_text_propertiesSet text layout: alignment, auto-resize, text case, decoration, truncation
set_layout_childConfigure auto-layout child: sizing, grow, alignment, absolute positioning
node_moveMove a node to a new position
node_resizeResize a node
node_replace_withReplace a node with another node
arrangeAlign or distribute selected nodes

Structure

ToolDescription
delete_nodeDelete a node
clone_nodeDuplicate a node
rename_nodeRename a node
reparent_nodeMove a node into a different parent
select_nodesSelect nodes by ID
group_nodesGroup nodes
ungroup_nodeUngroup a group
flatten_nodesFlatten nodes into a single vector
boolean_unionBoolean union of two or more nodes
boolean_subtractBoolean subtraction
boolean_intersectBoolean intersection
boolean_excludeBoolean exclusion

Vector Path

ToolDescription
path_getGet the path data of a vector node
path_setSet the path data of a vector node
path_scaleScale a vector path
path_flipFlip a vector path horizontally or vertically
path_moveTranslate a vector path

Export

ToolDescription
export_imageExport nodes as PNG, JPG, or WEBP. Returns base64-encoded image data
export_svgExport nodes as SVG markup

Viewport

ToolDescription
viewport_getGet current viewport position and zoom level
viewport_setSet viewport position and zoom
viewport_zoom_to_fitZoom viewport to fit specified nodes

Variables

ToolDescription
get_variableGet a variable by ID or name
find_variablesFind variables by name pattern or type
create_variableCreate a new variable in a collection
set_variableSet a variable value in a mode
delete_variableDelete a variable
bind_variableBind a variable to a node property
get_collectionGet a variable collection by ID or name
create_collectionCreate a new variable collection
delete_collectionDelete a variable collection

Analyze

ToolDescription
analyze_colorsAnalyze color palette usage across the document
analyze_typographyAnalyze font/size/weight distribution
analyze_spacingAnalyze gap and padding values
analyze_clustersDetect repeated patterns (potential components)

Diff

ToolDescription
diff_createCreate a snapshot of the current document state
diff_showShow differences between the current state and a snapshot
ToolDescription
switch_pageSwitch to a page by name or ID

Escape Hatch

ToolDescription
evalExecute JavaScript with full Figma Plugin API access

Note: eval is available over stdio, but disabled in HTTP mode for security.

Released under the MIT License.