OpenPencil
OpenPencil provides a CLI and MCP server for .fig design files and the running OpenPencil editor.
Use two modes:
- App mode — connect to the running OpenPencil editor by omitting the file argument.
- Headless mode — work with
.figfiles directly by passing a file path.
Current reference version: OpenPencil 0.12.x. The MCP server exposes 106 tools in 0.12.0.
Requirements
The desktop app starts openpencil-mcp-http automatically in production Tauri builds when @open-pencil/mcp is installed globally and exposes automation on:
- HTTP/RPC:
http://127.0.0.1:7600 - WebSocket bridge:
ws://127.0.0.1:7601 - MCP Streamable HTTP:
http://127.0.0.1:7600/mcp
CLI Commands
Commands in 0.12.x:
info— document overview: pages, node counts, fontstree— print hierarchy with types and sizespages— list pagesnode— detailed node properties by IDselection— current selection from the running appfind— find nodes by name/typequery— XPath selectors for node searchvariables— list variables and collectionsexport— export PNG/JPG/WEBP/SVG/PDF/JSX/.figconvert— convert between supported document formatsanalyze— colors, typography, spacing, repeated clusterslint— consistency, structure, and accessibility checksformats— supported document/export formatseval— execute JavaScript with the Figma Plugin API
Inspect
Search and XPath query
Common node types: FRAME, TEXT, RECTANGLE, ELLIPSE, VECTOR, GROUP, COMPONENT, COMPONENT_SET, INSTANCE, SECTION, LINE, STAR, POLYGON, SLICE, BOOLEAN_OPERATION.
Export and convert
Analyze and lint
Eval (Figma Plugin API)
Execute JavaScript against the document using a Figma Plugin API-compatible runtime:
Every command that reports structured data supports --json when appropriate.
MCP Server
Stdio MCP clients
Use Bun by default:
If @open-pencil/mcp is installed globally, direct binaries also work:
HTTP / Streamable HTTP
MCP workflow
- Open/create a document —
open_file { path }whenOPENPENCIL_MCP_ROOTis configured, ornew_document {}. - Query —
get_page_tree,find_nodes,query_nodes,get_node,list_pages,get_current_page. - Inspect —
get_jsx,diff_jsx,describe,export_image,export_svg,export_pdf. - Modify —
render,batch_update,update_node,set_fill,set_layout,create_shape,import_svg, etc. - Navigate — after creating or editing visible canvas content, call
select_nodesandviewport_zoom_to_fit { id }(ornode_bounds+viewport_set) so the user can see the result in the running editor. - Save/export —
save_file,export_image,export_svg,export_pdf, or CLIexport.
MCP Tools in 0.12.0 (106 total)
Read and selection (17): get_selection, get_node, find_nodes, get_page_tree, get_current_page, list_pages, select_nodes, query_nodes, get_components, switch_page, page_bounds, list_fonts, list_available_fonts, get_jsx, diff_jsx, describe, node_tree
Create and import (12): render, create_shape, create_component, create_instance, create_page, create_vector, create_slice, import_svg, search_icons, insert_icon, fetch_icons, stock_photo
Modify (24): update_node, batch_update, set_layout, set_layout_child, set_radius, set_fill, set_stroke, set_text, set_text_properties, set_effects, set_opacity, set_font, set_visible, set_constraints, set_rotation, set_minmax, set_font_range, set_text_resize, set_blend, set_locked, set_stroke_align, set_image_fill, set_variable, bind_variable
Structure (16): delete_node, reparent_node, node_resize, clone_node, node_move, rename_node, group_nodes, ungroup_node, flatten_nodes, node_to_component, node_bounds, node_ancestors, node_children, node_bindings, node_replace_with, arrange
Variables (9): list_variables, list_collections, get_variable, find_variables, create_variable, delete_variable, get_collection, create_collection, delete_collection
Vector and viewport (15): boolean_union, boolean_subtract, boolean_intersect, boolean_exclude, path_get, path_set, path_scale, path_flip, path_move, viewport_get, viewport_set, viewport_zoom_to_fit, export_svg, export_pdf, export_image
Analyze and generation (9): analyze_colors, analyze_typography, analyze_spacing, analyze_clusters, diff_create, diff_show, design_to_tokens, design_to_component_map, calc
File and prompts (4): save_file, open_file, new_document, get_codegen_prompt
Tool availability can depend on server mode.
open_file,save_file, and disk-writing export paths requireOPENPENCIL_MCP_ROOTfor path scoping.
Key tools for agents
query_nodes— XPath selectors to find specific nodes without fetching the full tree.get_jsx— inspect any node as JSX in the same format accepted byrender.diff_jsx— compare two nodes structurally before editing.describe— semantic analysis of role, visual style, layout, and design issues.batch_update— apply multiple node updates efficiently.export_image/export_svg/export_pdf— visual verification and deliverables.viewport_zoom_to_fit/viewport_set/viewport_get— keep the live editor focused on the created or edited design.get_codegen_prompt— retrieve OpenPencil's current JSX/codegen guidance.
JSX Rendering
Use the render tool or eval to create component trees. If unsure about JSX syntax, call get_codegen_prompt first.
Elements: Frame, Text, Rectangle, Ellipse, Line, Star, Polygon, Group, Section, Component, Instance.
Text content is the child content of <Text>. Use design-JSX props, not Figma API field names:
Common props:
Tips
- Omit the file path to work with the document open in the running OpenPencil editor.
- Start with
infoorget_page_treeto understand the document. - Use
tree --depth 2orquery_nodesto avoid overwhelming output on large files. - Export specific nodes with
--nodefor faster visual checks. - Use
export_imageafter changes to verify visual quality. - After creating a visible design, select it and zoom the editor to it:
select_nodes { ids: [id] }thenviewport_zoom_to_fit { id }. - If zoom-to-fit is unavailable in a client, use
node_boundsto calculate the center and callviewport_set { x, y, zoom }. - Use
analyze colors --similarto find near-duplicate colors. - Use
evalfor Figma Plugin API operations not covered by a dedicated CLI/MCP tool. - Use
--jsonwhen piping CLI output to scripts. - In app mode,
evaland MCP modifications are reflected live in the editor.

