How FigmaMCP is built: architecture, design choices and fixes
This page describes the FigmaMCP architecture for people who build or run AI agents. It names the parts, says why each write is checked the way it is, and lists real problems we hit while building it, with the fix for each.
If you only want to know what happens when you ask your agent for a change, read how Figma MCP works instead. That page is the short user view. This one is the build story.
The FigmaMCP architecture in five parts
A request goes down a chain of five parts. Each hop has one job. The agent never touches the Figma file directly.
| Part | Where it runs | Its job |
|---|---|---|
| AI agent | Claude Code or Codex | Reads your request, picks tools, reads before it writes. |
| MCP server | A process your AI app starts, talking stdio | Lists the tools, checks the shape of each input, and forwards the call. |
| Relay | A small local service that the Mac app keeps running | Holds a channel per open file and routes each command and its answer between one plugin and its AI sessions. |
| Plugin | Inside the Figma desktop app | Runs every safety check, then reads or edits the file. |
| Your file | Figma desktop app | The live document. You and teammates can change it at any time. |
Why a relay sits in the middle
A Figma plugin cannot listen on a port. It can only connect out. The MCP server cannot connect to the plugin, so both connect to a third process, the relay, on localhost. Each channel is named after the file key. The relay keeps one plugin per channel and lets up to four AI sessions share it when the plugin allows that (FigmaMCP allows it by default). The relay checks that the server and plugin are from the same release line before it routes anything.
The relay is a separate process that the Mac app keeps running with launchd. Each AI app starts its own MCP server process, and all of them reach the one plugin for a file through the relay.
Design choices and why we made them
FigmaMCP is a fork of figma-edit-mcp by Neo Product LLC. The plugin-side safety model, scope lock, name checks and batch checks, comes from that project, and we kept all of it. FigmaMCP added the installer and Mac app, a new way to connect to the plugin, and different defaults. The table shows which is which.
| Choice | Origin | Why |
|---|---|---|
| Checks run in the plugin | Kept from upstream | The plugin is the only layer every call must pass. |
| Scope locked at connect time | Kept; FigmaMCP changed the default to the whole file | The agent cannot widen what it may edit. |
| Name check on every write | Kept from upstream | Catches stale or invented layer IDs. |
| Batches checked before any change | Kept from upstream | One bad item stops the batch before it starts. |
| Bind to the open plugin, no code to copy | Added in FigmaMCP | The only step left for a person is to open the plugin. |
| Patch versions work together | Added in FigmaMCP | An update must not break a running AI session. |
The plugin is the trust boundary
The agent is not trusted to judge whether an edit is safe. It may hold an old node ID or guess a name. So the plugin checks mechanical facts it can prove: where the target is, which layer it is, what type it is and whether it is locked. The MCP server also validates input shapes, but that is only for clear early errors. A client that skips the server still meets every check in the plugin.
Scope lock
Scope is fixed when the plugin connects and stays fixed for the session. In FigmaMCP a blank link means the whole file is editable. Pages and the document root still cannot be deleted, moved or copied, and locked layers are protected. When you turn off the plugin’s AI can edit this file switch, the session is read-only and any write returns READ_ONLY_MODE. A write to a node outside a narrower scope returns OUTSIDE_SCOPE. Variables and styles have their own permission switches.
Name verification
Every write against an existing object carries that object’s current name, read from node_info, page_info, variable_list or style_list. The plugin looks up the object by ID and refuses the write if the name differs, with NAME_MISMATCH. Creation checks the parent’s name in the same way. It works like a text editor tool that refuses an edit when the old text no longer matches: the agent reads again and retries with fresh data. In a shared file someone can rename a layer between two calls, and this catches it.
Batch validation
Batch tools such as text_set_content and annotation_set check every item first: does it exist, is it in scope, does its name match, is it the right type. If one item fails, nothing changes. After the batch starts, items run in order and each gets its own result row. (node_delete gets the same first check, then deletes in parallel chunks.) We do not claim rollback: a failure in the middle returns partial_success with one row per item, and any change the plugin could not undo is reported as a partial mutation.
Structured error codes
An agent cannot recover from a vague message. So each refusal carries a code that says what to do next. Every error result is also marked as an error in the MCP response, so a client does not read it as success.
| Code | Meaning | What the agent should do |
|---|---|---|
NAME_MISMATCH | The name sent does not match the layer. | Read the layer again, then retry with its real name. |
OUTSIDE_SCOPE | The target is outside the editable scope. | Pick another target, or ask the user to reconnect. |
READ_ONLY_MODE | The edit switch in the plugin is off. | Tell the user. Only reads work. |
CHANNEL_NOT_BOUND | The session has no file yet, for example because several files have the plugin open. | Call channel_join with a link to the right file. |
CONNECTION_NOT_READY | The relay connection did not open in time. | Ask the user to open the Mac app and the plugin, then retry once. |
VERSION_MISMATCH | Server and plugin are from different release lines. | Tell the user which side is older: reconnect the AI session, or reopen the plugin. |
Binding to the open plugin
Upstream paired the agent and the plugin with a short channel code that the user copied from the plugin. FigmaMCP drops that step. The plugin names its channel after the file key, and any tool call binds to the open plugin when only one file has it open. If several files are open, the call returns CHANNEL_NOT_BOUND with the list of open files, and the agent calls channel_join with a link. After a plugin reload, the next call rejoins the same file with the same scope. It never moves a session to another file.
What went wrong on the way
These are real problems from FigmaMCP’s own commits and release notes, each with the fix that shipped.
An early channel_join failed with no code
A fresh MCP server opens its relay socket in the background. A
channel_joinsent before the socket was open came back asUNKNOWN_ERROR“Not connected to Figma.” A tester reported it on 0.1.11.Fix (2026-11-17):
channel_joinnow waits up to 5 seconds for the socket, the same waitpage_infoalready used. If it still is not open, it fails with the coded errorCONNECTION_NOT_READY. The same change marks every error result as an error.A patch update broke running AI sessions
After an update, the plugin reloads the new version, but an AI session keeps the server process it started with. The relay refused any pair of unequal versions, so every call failed with
VERSION_MISMATCH. The message told users to reinstall the plugin, which could not help.Fix (2026-11-11): patch releases share one wire contract, so the relay now admits the same major and minor version. A refusal names the older side and the step that fixes it.
Upgrading over a running relay failed
Setup stops the old relay with launchd and starts the new one.
launchctl bootoutreturns before the old service is gone, so starting the new one failed with “Bootstrap error 5” until the user ran setup again.Fix (2026-11-09): setup retries the start while launchd removes the old relay.
The plugin said “Connected” when no agent was there
In 0.1.20 the plugin showed its first-run hint as soon as the plugin reached the relay. It said “Connected” even when no AI app had FigmaMCP loaded, so a new user could wait for an agent that was not there.
Fix (0.1.21, 2026-11-21): the plugin waits 4 seconds for the relay’s notice that an AI session is present. Without it, the plugin tells the user to quit Claude Code or Codex and open it again.
What this means if you build agents
- Read before you write, and pass names back exactly as read. A stale name is refused, not guessed.
- Treat a refusal as a stop signal with a next step, not as a prompt to retry the same call.
- After a partial mutation, read the reported state before you retry.
- Know what is not checked: a wrong edit that follows every rule still goes through. See is Figma MCP safe for the limits.
Download for Mac Version 0.1.25 macOS 14+ · Intel & Apple Silicon · ~155 MB
Questions
Is the FigmaMCP code public?
Does FigmaMCP use the Figma REST API or a Figma access token?
Can an agent switch to another file in the middle of a session?
Why not do the safety checks in the MCP server?
Does FigmaMCP call Figma’s own MCP server?
Related: How Figma MCP works · Is Figma MCP safe · Changelog · Tools
Last updated: