Skip to main content
Glama
OpenFigma MCP

OpenFigma MCP

README.md
# OpenFigma MCP

An MCP server and Figma plugin that let Claude Code, or any other MCP client, read and edit Figma files. Built on
[Talk to Figma MCP](https://github.com/grab/cursor-talk-to-figma-mcp), without its separate WebSocket relay: each MCP
server listens for the plugin itself, so every Claude Code session works on its own.

## How it connects

```
Claude Code session ←(stdio)→ MCP server on a port from 3155–3164 ←(WebSocket)→ Figma plugin, one per open file
```

- Each MCP server (one per Claude Code session or script) listens on the first free port from 3155 to 3164.
- The plugin connects to every server that answers and tells it the file's key: the ID after `/design/` in the file's
  URL. It looks again every 2 seconds, so new sessions get connected without any action.
- A session picks its file with `join_channel` and the file key. Its commands go only to that file's plugin, and the
  answers come back only to that session.
- Figma starts a plugin only when someone runs it, so run the plugin once after opening a file.

## Project Structure

- `src/server/` - TypeScript MCP server for Figma integration
- `src/plugin/` - Figma plugin that connects the open file to the MCP servers
- `scripts/check-sessions.ts` - checks two servers side by side against a fake plugin: `bun scripts/check-sessions.ts`
- `scripts/check-design-system.ts` - checks the design-system tools against a copy of Apple's iOS and iPadOS 27 kit with the
  plugin running in it: `bun scripts/check-design-system.ts <file key> [check name …]`
- `kits/` - one design-system guide per kit (see Design-system guides)

## Setup

1. Install [Bun](https://bun.sh), then the dependencies:

   ```bash
   bun install
   ```

2. Add the MCP server to Claude Code (other MCP clients take the same command in their MCP config):

   ```bash
   claude mcp add OpenFigma-MCP -- bun /path-to-repo/src/server/server.ts
   ```

   Claude Code server names allow only letters, numbers, hyphens and underscores, hence `OpenFigma-MCP`.

3. In Figma: Plugins > Development > Import plugin from manifest…, then pick `src/plugin/manifest.json`
4. Open a file and run the OpenFigma MCP plugin. Its window lists the connected sessions
5. In Claude Code, choose the file with `join_channel` and its file key, then use the tools below

## Usage analytics

The plugin sends anonymous usage events to the project's Google Analytics 4 property over the Measurement Protocol:
`plugin_open`, `channel_join` when it connects to a session, and `command_executed` per command with its name, success,
duration and error message. No file content is sent. The Measurement ID and API secret are at the top of the analytics
block in `src/plugin/ui.html`; the secret only lets its holder send events, not read or change the property.

## Design-system guides

`kits/` holds one guide per design-system kit, such as `kits/ios-ipados-27.md` for Apple's iOS and iPadOS 27 kit: how
the kit's tokens and elements become code, and how its elements are linked to their guideline pages. The server's MCP
instructions give every session the folder's path. Each linked kit element carries its guideline page as its Figma
documentation link, which node info reports as `component.link`.

## Design Automation Example

**Bulk text content replacement**

Thanks to [@dusskapark](https://github.com/dusskapark) for contributing the bulk text replacement feature. Here is the [demo video](https://www.youtube.com/watch?v=j05gGT3xfCs).

**Instance Override Propagation**
Another contribution from [@dusskapark](https://github.com/dusskapark)
Propagate component instance overrides from a source instance to multiple target instances with a single command. This feature dramatically reduces repetitive design work when working with component instances that need similar customizations. Check out our [demo video](https://youtu.be/uvuT8LByroI).

## MCP Tools

The MCP server provides the following tools for interacting with Figma:

### Document & Selection

- `get_document_info` - Get information about the current Figma document
- `get_selection` - Get information about the current selection
- `read_my_design` - Get detailed node information about the current selection without parameters
- `get_node_info` - Get detailed information about a specific node, including what it's made of: `component` (for an instance: its main component, component set, property values, description and documentation link), `styles`, `textStyles` (per range), `variables` (bound variables by name), `layout`, and `inferredLayout` (Figma's inferred auto layout, for frames without auto layout). `layout` and `inferredLayout` leave out Figma's defaults (no auto layout, spacing and padding 0, alignment MIN, sizing modes AUTO, layoutAlign INHERIT, layoutGrow 0, layoutSizing FIXED), and a hidden layer has `visible: false`
- `get_nodes_info` - Get detailed information about multiple nodes by providing an array of node IDs
- `set_focus` - Set focus on a specific node by selecting it and scrolling viewport to it
- `set_selections` - Set selection to multiple nodes and scroll viewport to show them

### Annotations

- `get_annotations` - Get all annotations in the current document or specific node
- `set_annotation` - Create or update an annotation with markdown support
- `set_multiple_annotations` - Batch create/update multiple annotations efficiently
- `scan_nodes_by_types` - Scan for nodes with specific types (useful for finding annotation targets)

### Prototyping & Connections

- `get_reactions` - Get all prototype reactions from nodes with visual highlight animation
- `set_default_connector` - Set a copied FigJam connector as the default connector style for creating connections (must be set before creating connections)
- `create_connections` - Create FigJam connector lines between nodes, based on prototype flows or custom mapping

### Creating Elements

- `create_rectangle` - Create a new rectangle with position, size, and optional name
- `create_frame` - Create a new frame with position, size, and optional name
- `create_section` - Create a section to group related content on the canvas
- `create_text` - Create a new text node in any installed font (`fontFamily`, `fontStyle`), with alignment, fixed width, line height and letter spacing
- `create_page` - Create a page (a Starter-plan file is limited to 3 pages)
- `create_ellipse` - Create an ellipse, circle, ring (stroke only) or arc
- `create_svg` - Create vector layers from SVG markup, like Figma's SVG import (lines, arrows, paths, icons)
- `create_slice` - Create a slice, an export region over whatever lies under it

### Modifying text content

- `scan_text_nodes` - Scan text nodes with intelligent chunking for large designs
- `set_text_content` - Set the text content of a single text node
- `set_multiple_text_contents` - Batch update multiple text nodes efficiently
- `set_text_style` - Change a text node's font, size, alignment, line height, letter spacing or sizing, also inside instances

### Auto Layout & Spacing

- `set_layout_mode` - Set the layout mode and wrap behavior of a frame (NONE, HORIZONTAL, VERTICAL)
- `set_padding` - Set padding values for an auto-layout frame (top, right, bottom, left)
- `set_axis_align` - Set primary and counter axis alignment for auto-layout frames
- `set_layout_sizing` - Set horizontal and vertical sizing modes for auto-layout frames (FIXED, HUG, FILL)
- `set_item_spacing` - Set distance between children in an auto-layout frame

### Styling

- `set_fill_color` - Set the fill color of a node (RGBA)
- `set_stroke_color` - Set the stroke color and weight of a node
- `set_corner_radius` - Set the corner radius of a node with optional per-corner control
- `set_image_fill` - Fill a node with an image from a local file path, URL, or base64 data (FILL, FIT, CROP, or TILE)
- `set_gradient_fill` - Replace a node's fills with a linear, radial, angular or diamond gradient
- `set_effects` - Replace a node's effects: drop and inner shadows, layer and background blur, Liquid Glass
- `set_node_properties` - Set opacity, visibility, rotation, blend mode, clipping, lock, stroke alignment, dashes or corner smoothing

### Layout & Organization

- `move_node` - Move a node to a new position
- `resize_node` - Resize a node with new dimensions
- `delete_node` - Delete a node
- `delete_multiple_nodes` - Delete multiple nodes at once efficiently
- `clone_node` - Create a copy of an existing node with optional position offset
- `rename_node` - Rename a node
- `set_parent` - Move a node into a new parent (section, frame or group), preserving its absolute position by default
- `group_nodes` / `ungroup_node` - Group nodes, or ungroup keeping the children
- `boolean_operation` - Combine shapes with union, subtract, intersect or exclude

### Components & Styles

- `get_styles` - Get information about local styles
- `get_local_components` - Get information about local components
- `get_components_by_page` - List each page's component sets and the components outside sets, with their descriptions and documentation links; variants are left out (`get_local_components` lists them), except those with a description or link of their own, listed under their set
- `set_documentation_links` - Set or clear the documentation links of components, component sets, variants and styles, in one batch; each item reports its own result
- `create_component_instance` - Create an instance of a component
- `get_instance_overrides` - Extract override properties from a selected component instance
- `set_instance_overrides` - Apply extracted overrides to target instances
- `get_instance_properties` / `set_instance_properties` - Read and set an instance's variants and its boolean, text and instance-swap properties
- `detach_instance` - Detach an instance into a frame
- `create_component_from_node` - Turn a node into a component
- `apply_style` - Apply a local fill, stroke, text or effect style
- `bind_color_variable` - Bind a fill or stroke colour to a local colour variable, by ID or name

### Export & Advanced

- `export_node_as_image` - Export a node as an image (PNG, JPG, SVG, or PDF) - limited support on image currently returning base64 as text
- `export_node_to_file` - Export a node or slice to a file on disk (PNG, JPG, SVG or PDF)

### Connection Management

- `join_channel` - Choose the file to work on, by its file key from the file's URL

### MCP Prompts

The MCP server includes several helper prompts to guide you through complex design tasks:

- `design_strategy` - Best practices for working with Figma designs
- `read_design_strategy` - Best practices for reading Figma designs
- `text_replacement_strategy` - Systematic approach for replacing text in Figma designs
- `annotation_conversion_strategy` - Strategy for converting manual annotations to Figma's native annotations
- `swap_overrides_instances` - Strategy for transferring overrides between component instances in Figma
- `reaction_to_connector_strategy` - Strategy for converting Figma prototype reactions to connector lines using the output of 'get_reactions', and guiding the use 'create_connections' in sequence

## Development

### Building the Figma Plugin

1. Navigate to the Figma plugin directory:

   ```
   cd src/plugin
   ```

2. Edit code.js and ui.html

## Best Practices

When working with the Figma MCP:

1. Always choose a file with `join_channel` before sending commands
2. Get document overview using `get_document_info` first
3. Check current selection with `get_selection` before modifications
4. Use appropriate creation tools based on needs:
   - `create_frame` for containers
   - `create_rectangle` for basic shapes
   - `create_text` for text elements
5. Verify changes using `get_node_info`
6. Use component instances when possible for consistency
7. Handle errors appropriately as all commands can throw exceptions
8. For large designs:
   - Use chunking parameters in `scan_text_nodes`
   - Monitor progress through WebSocket updates
   - Implement appropriate error handling
9. For text operations:
   - Use batch operations when possible
   - Consider structural relationships
   - Verify changes with targeted exports
10. For converting legacy annotations:
    - Scan text nodes to identify numbered markers and descriptions
    - Use `scan_nodes_by_types` to find UI elements that annotations refer to
    - Match markers with their target elements using path, name, or proximity
    - Categorize annotations appropriately with `get_annotations`
    - Create native annotations with `set_multiple_annotations` in batches
    - Verify all annotations are properly linked to their targets
    - Delete legacy annotation nodes after successful conversion
11. Visualize prototype noodles as FigJam connectors:

- Use `get_reactions` to extract prototype flows,
- set a default connector with `set_default_connector`,
- and generate connector lines with `create_connections` for clear visual flow mapping.

## License

MIT