Skip to main content
Glama
figma-bridge

figma-bridge

by RoelStierum
README.md
<div align="center">

# figma-bridge

**A free, self-hosted MCP server for Figma, plus a Storybook-to-Figma component sync.**

figma-bridge lets AI agents such as Claude Code, Claude Desktop, Cursor and GitHub Copilot read and edit the Figma file you have open. It works through a small local Figma plugin instead of the Figma REST API, so it needs no API key and has no rate limits.

[![MCP](https://img.shields.io/badge/MCP-stdio-2d2f7f?style=for-the-badge)](https://modelcontextprotocol.io)
[![Figma](https://img.shields.io/badge/Figma-plugin_API-449dd7?style=for-the-badge&logo=figma&logoColor=white)](https://developers.figma.com/docs/plugins/)
[![Node 22](https://img.shields.io/badge/Node-22+-5bc5f2?style=for-the-badge&logo=nodedotjs&logoColor=white)](https://nodejs.org)
[![MIT](https://img.shields.io/badge/License-MIT-71717a?style=for-the-badge)](./LICENSE)

</div>

---

## Why

Most Figma MCP servers wrap the REST API. Its per-plan rate limits run out within minutes once an agent iterates on a design, and the official Dev Mode MCP needs a paid seat.

figma-bridge talks to the Figma desktop app through a development plugin instead:

- there are no quotas
- it works on the free Starter plan
- it sees the file live, including unsaved changes
- it can **write** as well as read

|                              | REST-based MCP servers | figma-bridge |
| ---------------------------- | ---------------------- | ------------ |
| Figma API key                | required               | not needed   |
| Rate limits                  | per plan               | none         |
| Write to the file            | mostly read-only       | yes          |
| Storybook → Figma components | no                     | yes          |

## Install

You need Node 22+ and the Figma **desktop** app.

```bash
npx figma-bridge-mcp setup
```

The setup command does three things:

- It registers the server in every AI tool it finds: Claude Code, Claude Desktop, Cursor and VS Code.
- It unpacks the Figma plugin.
- It copies the path to the plugin's manifest.

Then, in Figma desktop, go to **Plugins → Development → Import plugin from manifest…** and paste that path.

Run the plugin. The first time, your AI asks for the code the plugin shows. After that it connects by itself.

<details>
<summary>Manual setup</summary>

**Claude Code**

```bash
claude mcp add --scope user figma -- npx -y figma-bridge-mcp
```

**Claude Desktop or Cursor** (`.mcp.json`)

```json
{ "mcpServers": { "figma": { "command": "npx", "args": ["-y", "figma-bridge-mcp"] } } }
```

**VS Code Copilot** (`.vscode/mcp.json`)

```json
{ "servers": { "figma": { "type": "stdio", "command": "npx", "args": ["-y", "figma-bridge-mcp"] } } }
```

For Claude Desktop, you can instead download `figma-bridge.mcpb` from the [latest release](https://github.com/RoelStierum/figma-bridge/releases/latest) and double-click it.

**Plugin:** download `figma-bridge-plugin.zip` from the [latest release](https://github.com/RoelStierum/figma-bridge/releases/latest), unzip it, and import its `manifest.json` as described above.

**Pairing:** run the plugin. It shows a code such as `4827-1930`. Tell your agent _"pair Figma with code 4827-1930"_.

Run `npx figma-bridge-mcp setup --dry-run` to see what setup would change without changing it. Other options:

- `--only=claude-code,cursor` registers the server in those clients only.
- `--no-clients` only unpacks the plugin.

Setup never removes other servers, and it saves a `.bak` copy of every config file it changes.

</details>

## Use it

```text
> Export the selected frame as PNG and tell me what's off with the spacing.
```

The agent calls `get_selection`, then `export_node_image`, and looks at the image itself.

## What's inside

| Tool                                                           | Does                                                               |
| -------------------------------------------------------------- | ------------------------------------------------------------------ |
| `bridge_status`                                                | Whether the plugin is connected, and to which file                 |
| `pair_plugin`                                                  | Pair the plugin using the code it shows (once per machine)         |
| `get_document_info`                                            | File name, current page and every page                             |
| `get_selection`                                                | The selected nodes on the current page                             |
| `get_node`                                                     | One node with its styles and children, to a chosen depth           |
| `find_nodes`                                                   | Search by name, type or pluginData on the page or the whole file   |
| `export_node_image`                                            | A node as PNG (returned as an image the agent can see) or as SVG   |
| `create_frame`                                                 | A frame, optionally with auto layout                               |
| `create_text`                                                  | A text layer; falls back to Inter when a font is missing           |
| `create_rectangle`, `create_ellipse`, `create_svg_node`        | Shapes and SVG markup                                              |
| `set_auto_layout`                                              | Direction, gap, padding, alignment, wrap and hug/fill sizing       |
| `set_fills`, `set_strokes`, `set_effects`, `set_corner_radius` | Hex colors, linear gradients, shadows, blurs, radii                |
| `resize`, `move`, `rename`, `reparent`, `delete_node`          | Layout and structure                                               |
| `import_layer_tree`                                            | Build nodes from `@builder.io/html-to-figma` output                |
| `list_local_components`                                        | Components and sets, with variants and component properties        |
| `create_component`                                             | A new component, or turn an existing node into one                 |
| `combine_as_variants`                                          | Components into a set, named `Prop=Value, …` from props objects    |
| `add_component_property`                                       | Boolean, text, instance-swap or variant property, bound to a layer |
| `create_instance`, `set_instance_properties`                   | Place an instance (pick a variant by props) and set its props      |
| `list_variables`                                               | Collections, modes and values per mode                             |
| `create_variable_collection`, `create_variable`                | Collections with named modes; variables with a value per mode      |
| `bind_variable`                                                | A variable on a fill/stroke color, radius, spacing, size …         |
| `batch`                                                        | Many operations in one round trip, with named refs                 |
| `sync_storybook`                                               | Upsert components from a Storybook export (see below)              |

Colors are hex (`#1E3A8A`, `#1E3A8A80`). New nodes go to the current page, centred in the viewport, unless you pass `parent`, `x` or `y`. In a `batch`, name a result with `ref` and use it later as `@ref`:

```json
{
  "operations": [
    {
      "op": "create_frame",
      "ref": "card",
      "args": { "width": 320, "height": 120, "autoLayout": { "direction": "vertical", "gap": 8, "padding": 16 } }
    },
    { "op": "create_text", "args": { "parent": "@card", "text": "Line 2", "fontStyle": "Bold", "fontSize": 18 } }
  ]
}
```

The free Starter plan allows one mode per variable collection. When a second mode is refused, `create_variable_collection` answers `PLAN_LIMIT` and keeps the collection with its first mode.

## Storybook → Figma

Turn any Storybook 8+ into real Figma components in two steps.

1. **Export.** In a clone of this repo, run `npm install` and `npx playwright install chromium`, then `npm run export` with `STORYBOOK_URL` set (see [Configuration](#configuration)). It renders every story in Playwright, converts the DOM to Figma layers with `@builder.io/html-to-figma`, and writes `exports/figma-export.json`. A Storybook with about 500 stories takes around 5 minutes.
2. **Sync.** Ask your agent: _"sync `exports/figma-export.json` into Figma"_. That calls `sync_storybook` with the file path or a URL. Pass `dryRun` to see what would change first.

The sync does the following:

- **Variants.** Each component becomes a component set. Its `select`, `radio` and `boolean` argTypes become variant properties (`size=small, loading=false`). When that would mean too many variants, it uses one variant per story instead (`Story=Default`).
- **Themes.** The theme colors become a **Storybook tokens** variable collection with one mode per theme. Fills and strokes that match a token in every theme are bound to it. On the Starter plan, which allows one mode, you get one collection per theme instead.
- **Re-syncing is safe.** Each component remembers its story id and a content hash. Unchanged stories are skipped, and changed ones are rebuilt in place, so their node ids stay and existing instances keep working. Stories that disappeared are reported as orphaned and never deleted.
- **Layout.** There is one section per category, with every set labelled. A re-sync only places new sets, so anything you moved by hand stays where it is.

There is no "run arbitrary JS" tool unless you set `FIGMA_BRIDGE_ALLOW_EVAL=1`.

## Configuration

| Variable                  | Default    | Purpose                                                |
| ------------------------- | ---------- | ------------------------------------------------------ |
| `FIGMA_BRIDGE_PORT`       | `3055`     | WebSocket port. The plugin manifest only allows `3055` |
| `FIGMA_BRIDGE_TOKEN`      | saved file | A fixed token instead of the one saved after pairing   |
| `FIGMA_BRIDGE_ALLOW_EVAL` | off        | Registers the `eval` tool                              |
| `STORYBOOK_URL`           |            | Storybook to export                                    |
| `STORYBOOK_AUTH`          |            | `user:password` for a Storybook behind Basic auth      |
| `STORYBOOK_INCLUDE`       | all        | Comma-separated title prefixes to export               |
| `STORYBOOK_EXCLUDE`       |            | Comma-separated title prefixes to skip                 |
| `STORYBOOK_CONCURRENCY`   | `4`        | Stories rendered in parallel                           |
| `STORYBOOK_THEME_GLOBAL`  | `theme`    | The Storybook global that switches themes              |

The token is saved in `%APPDATA%/figma-bridge/token` on Windows and in `~/.config/figma-bridge/token` elsewhere. When two clients start the server, the first one owns the port and the second one answers `NOT_CONNECTED`.

## FAQ

**Can I use Figma with Claude without a Figma API key?**
Yes. figma-bridge never calls the Figma REST API. It drives the Figma desktop app through a plugin you run yourself, so no API key or personal access token is involved.

**Does it hit Figma's MCP or API rate limits?**
No. Rate limits apply to the REST API and to Figma's hosted Dev Mode MCP. All figma-bridge traffic stays on your machine, between the MCP server and the plugin, over `127.0.0.1`.

**Does it work on the free Figma Starter plan?**
Yes. Development plugins work on every plan. Starter can't publish team libraries, though, so the Storybook sync writes components into the design file itself.

**Can the AI edit my design, or only read it?**
Both. Every tool is validated with zod. There is no tool that runs arbitrary code unless you turn it on with `FIGMA_BRIDGE_ALLOW_EVAL=1`.

**Is it safe to open a port on localhost?**
The server only listens on `127.0.0.1`. A plugin must be paired with a one-time code before it can do anything. The server generates that code and shows it only inside Figma, so a website you have open can't pair itself.

**How do I turn my Storybook into Figma components?**
Export it with `npm run export` (point `STORYBOOK_URL` at any Storybook 8+), then let your agent call `sync_storybook` on the file. Each component's argTypes become Figma variants, its themes become variable modes, and re-syncing updates the components in place. See [Storybook → Figma](#storybook--figma).

**How is this different from the official Figma MCP?**
The official Figma MCP needs a paid Dev Mode seat and is rate-limited. figma-bridge is free and unlimited, and it adds three things:

- token-safe pairing
- an npx install with zero dependencies
- a Storybook-to-components sync

## Repository layout

| Path                     | Purpose                                                                                      |
| ------------------------ | -------------------------------------------------------------------------------------------- |
| `src/shared/ops.ts`      | One zod schema per operation. Each entry is exposed as an MCP tool automatically.            |
| `src/shared/protocol.ts` | Bridge frames, error codes and chunking, shared by the server and the plugin.                |
| `src/server`             | The MCP server (stdio) and the WebSocket bridge on `127.0.0.1`: pairing, timeouts, progress. |
| `src/plugin`             | The Figma plugin. `code.ts` runs in the sandbox, and `ui.ts` relays the WebSocket.           |
| `test`                   | Vitest suites, including a mock plugin client, so the bridge is tested without Figma.        |

To add a tool, add a schema to `ops.ts` and a handler in `src/plugin/handlers/`, then map the handler in `code.ts`.

## Develop

```bash
npm install
npm run dev            # esbuild watch: server + plugin
npm run build          # dist/server.js (self-contained), plugin/code.js, plugin/ui.html
npm run typecheck      # tsc over server, shared, tests and plugin
npm run lint           # ESLint (flat config)
npm run format         # Prettier write
npm test               # vitest: protocol, schemas and the bridge against a mock plugin
```

Logs go to stderr, because stdout belongs to the MCP transport. To try a local build, point your MCP client at `node <repo>/dist/server.js` and import `plugin/manifest.json` from the repo.

## Releases

Push a `vX.Y.Z` tag that matches `package.json`. The release workflow then runs the checks and attaches `figma-bridge-plugin.zip` to a GitHub release. It also publishes `figma-bridge-mcp` to npm when the `NPM_TOKEN` secret is set.

<div align="center">
<br />
<sub>MIT licensed · Built by <a href="https://github.com/RoelStierum">Roel Stierum</a></sub>
</div>