SuperAPI AI Directory

localfig

Exposes the Figma desktop app's Plugin API on the open file: inline renders, design token reading and one undo step per call, without the cloud API.

Open website

About this tool

localfig's goal is to use the Figma desktop app as an MCP (Model Context Protocol) server, thereby giving AI agents full Figma Plugin API capabilities in the Figma file you currently have open. It consists of two parts: a very small development plugin installed in Figma, and an HTTP bridge bound only to the local loopback address, all running locally.

[Purpose] Let AI agents directly read from and write to the open Figma file: frames, text, auto layout, variables, components, image fills, export, undo, etc. Anything the Plugin API can do, the agent can do. It does not rely on the Figma cloud API, does not require a personal access token, and has no per-account quota; data never leaves your machine.

[Main capabilities]

  • Read and write files: execute code in the plugin sandbox via figma_eval; the code is wrapped in an async function and supports top-level await and return; the global objects figma and helpers are available.
  • helpers provides a series of convenience methods: createText (create text and correctly load fonts, resize first then set textAutoResize), setText, loadNodeFonts, set (batch assignment, handle layoutMode first then resize), rgb / rgba (hex to fill color), reveal (scroll and zoom the viewport to a newly created node), notify (show a toast), collection / token / bind (create a design token and bind a property in one line), importComponent / instance (team library components), query (a minimal selector, supporting TEXT, [name=X], [name*=X], A B, a, b, etc.), createAutoLayout, command (run typed commands inside the script, such as tokens, metadata, find, changes, export).
  • Design system awareness: figma_tokens returns file variables in a design-system way; figma_metadata reports each node's boundVariables, fillStyle / textStyle / effectStyle names, an instance's main component and its componentProperties when styles: true, and css: true also appends the CSS computed by Figma, helping agents build based on the design system rather than hardcoding values.
  • Images in and out: figma_place_image sends file bytes to the plugin UI (a full Chromium iframe), decodes any format the browser supports, scales by maxSide (default 4096, Figma's hard limit) with high-quality smoothing, and converts non-native formats to PNG; figma_export writes files to ~/.localfig/exports/ and attaches PNG/JPG (each ≤ 2 MB) to the result as images; JSON exports return the subtree in the Figma REST API structure.
  • Undo, versions, and change tracking: every modifying tool call uses figma.commitUndo to create a checkpoint, entering the file's undo history as a step that can be manually Ctrl+Z'd (the most recent call is committed 60 seconds after completion or on the next call); within that window, figma_history with action: "undo" can roll back from the agent side, triggerUndo returns to the most recent checkpoint, and action: "snapshot" saves a named version before risky edits. The plugin also records node changes on every page it has seen; figma_changes returns changes since a given seq, and edits caused by tool calls are heuristically marked as byPlugin by time window and hidden by default.
  • Multiple sessions: the first localfig process occupies the bridge port; subsequent processes detect it via /health and proxy forward as clients, with consistent tools; if the owner exits, the next tool call rebinds the port and takes over, and the plugin re-registers after reconnecting.

[How to use] Requirements: Node.js 18 or later; the Figma desktop app (development plugins cannot be imported in the browser); an MCP client (such as Claude Code, Cursor, Windsurf, Cline, Claude Desktop, etc.).

  1. Install and register: running npx localfig generates a local key and writes the plugin to ~/.localfig/plugin/, and register localfig with every MCP client it can find, then print the manifest path. --dry-run only shows what it will do without making changes, and --clients=cursor,vscode can limit registration to only the specified clients. You can also clone the repository and run git clone https://github.com/LucasGorgal/localfig.git && cd localfig && node server.mjs --setup. A client configuration folder is considered installed if it exists; setup merges into existing files instead of overwriting them, existing localfig entries keep their env, a .localfig.bak backup is written before changes; files that cannot be safely rewritten (such as settings.json with comments) are left as is and the entries to paste are provided; already-open clients need to be restarted.
  2. For clients not listed, you can add it to the MCP configuration with the command npx -y localfig. On Windows, use "command": "cmd", "args": ["/c", "npx", "-y", "localfig"] instead.
  3. Import the plugin (only once): open any design file in the desktop app (the Plugins menu only exists within a file), Figma menu → Plugins → Development → Import plugin from manifest…, or press Ctrl / (Cmd /) and enter import plugin from manifest, then select ~/.localfig/plugin/manifest.json. The manifest requests the two permissions teamlibrary and currentuser, and registers a restart button.
  4. Each time you use it: open the target file, press Ctrl / and select localfig (or Ctrl Alt P / Cmd Opt P to rerun the last plugin, or use the Reconnect localfig button in the file properties panel), and once a small panel appears and shows Connected to localfig, keep it open so the agent can perform Figma operations on the current file. Closing the panel or the file disconnects it, and you need to run the plugin again; this is the only manual step, because Figma does not allow plugins to be launched externally.

[Sandbox and Security] The bridge binds only to loopback addresses (127.0.0.1 and ::1). Every endpoint except /health requires a 32-character hexadecimal key generated on first run and written to ~/.localfig/token, which is also written to ~/.localfig/plugin/ui.html. You should edit the plugin/ui in the package.template.html, do not modify the generated ui.html. No data is sent to any server.

[Use cases] For teams and individuals who want AI agents to directly read and modify designs, create design tokens, bind properties, import team library components, export renders, and see the results in an open Figma file, while not wanting to use cloud APIs or tokens and caring about data localization.

[Limitations and notes]

  • The Figma desktop app is required; development plugins cannot be imported in a browser.
  • Each session requires manually running the plugin in Figma to establish a connection.
  • The plugin main thread has no network access, only the UI iframe does; therefore HTTP long polling is used instead of WebSocket; the Figma manifest validator does not accept a bare IP in networkAccess, so localhost is used, and the IPv6 mirror address is listened on to handle the case where Windows resolves to ::1 first.
  • Returning real nodes from figma_eval is collapsed to {id, name, type} to avoid the results being overwhelmed; the subtree can be inspected with figma_metadata.
  • Fonts must be loaded before modifying text; resize() on a TEXT node resets textAutoResize to NONE, and on an auto layout frame it sets both sizing modes to FIXED, so resize should be done first and then sizing set.
  • Binary stays binary on the plugin channel: exports go through POST /blob, images enter as Uint8Array via GET /asset, and only JSON goes through the command channel (renders are base64-encoded once in the MCP result as required by the protocol).
  • The home directory is used because the package may be located in the npx cache or a read-only global install, the imported plugin folder cannot move when the package is updated, and user state should not be placed inside the package.
  • The development and testing environment is Windows 11 plus the Figma desktop app; macOS and Linux should theoretically work (Node built-in modules only, no native code) but have not yet been actually verified.
  • MIT license is used.

[Not yet provided] Specific charging or pricing information, a complete list of other supported clients, performance benchmark data, and actual test results for macOS/Linux are not provided.