# localfig [Health: Active]

**Category:** 📐 Architecture & Design  
**Repository:** https://github.com/LucasGorgal/localfig  
**GitHub Stars:** 8  
**npm Downloads (last month):** 412  
**Views:** 6  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/localfig

## Description
The Figma desktop app as an MCP server: full Plugin API for AI agents. Local, no token, no quota.

## Tools
Capabilities this server exposes over MCP:

- **figma_status** — Check whether localfig can reach Figma and what the plugin is looking at. Call it first in a session, whenever another tool reports that no plugin is connected or times out, and after the person switches files. Read-only. Returns the bridge state: owner or client, version and export folder. When the Figma plugin is connected it also returns the file name, editor type, current page, all pages, the current selection, the top-level layers of the page with positions and sizes, the signed-in user's name when available, and whether code execution is available for figma_eval. When the plugin is not connected, the result explains how to start it in Figma.
- **figma_eval** — Run JavaScript against the Figma file where the localfig plugin is open, with the full Figma Plugin API. Use it to create, edit, move or delete nodes, and for anything the other tools do not cover. For reading a design, prefer figma_metadata, figma_find and figma_tokens; for images from disk, use figma_place_image.

Behavior: the code can change or delete anything in the file. Each call is one undo step for the person, and figma_history can undo it within 60 seconds. Returns the JSON-serialized value of your return statement. Return plain data such as ids, names and numbers, because Figma nodes collapse to {id, name, type}.

Code rules:
- The body runs inside an async function, so await and return both work. Globals: figma and helpers.
- Use await figma.getNodeByIdAsync(id); the synchronous getNodeById is unavailable. Switch pages with await figma.setCurrentPageAsync(page).
- Load fonts before changing text, or use helpers.setText.
- resize() resets text auto-resize and auto-layout sizing modes, so set those after resizing, or use helpers.set and helpers.createText, which do it in the right order.
- End with helpers.reveal(nodes) so the person sees what changed.

helpers: setText(node, chars), loadNodeFonts(node), createText({characters, font, fontSize, color, width, lineHeight, letterSpacing, name, parent, x, y}), set(node, props), rgb("#rrggbb"), rgba("#rrggbbaa"), query(root, selector), createAutoLayout(direction, props), reveal(nodes), notify(message), collection(name, modes), token(collection, name, type, value), bind(node, property, variable), importComponent(key), instance(key, parent, props), command(kind, payload).
- **figma_metadata** — Read the layer tree of a node or of the current page: ids, names, types, positions, sizes and text content. Use it to understand an existing design and to get node ids before editing with figma_eval. To search a large file by name or text, use figma_find instead; for the file's variables and styles, use figma_tokens. Read-only. With styles:true each node also lists its fills, strokes, effects, corner radius, auto-layout, fonts, bound variables, named styles and component properties; css:true adds the CSS Figma generates for each node. Returns {tree, nodeCount, truncated}; reading stops at maxNodes and sets truncated to true.
- **figma_export** — Render nodes to image or data files, to see a design or hand it off. Use PNG to check your work visually: PNG and JPG results up to 2 MB come back inline as images. Use SVG for icons and vector assets, PDF for print, and JSON for the node tree in Figma REST API format, which design-to-code tools read; SVG and JSON up to 200 KB also come back inline as text. For layer structure without rendering, use figma_metadata. Does not change the Figma file. Writes files to the localfig exports folder, replacing files with the same name. Omitting nodeIds exports the current selection. Returns {exported}: one entry per node with its file name, path, size in bytes and, for SVG or JSON, the text.
- **figma_tokens** — List the design system defined in the open file: every local variable collection with its modes and each variable's value per mode, plus local paint, text and effect styles. Use it before generating code from a design or building new screens, so you reuse existing tokens instead of hard-coding colors and sizes. Variables from team libraries are not included; use figma_library for those. To see which token a specific node uses, call figma_metadata with styles:true. Read-only. Colors are hex strings and aliases appear as {variable name}. Returns {collections, styles, counts}.
- **figma_find** — Search the file for nodes by type, layer name or text content. Use it to locate things in a large file before reading them with figma_metadata or editing them with figma_eval. To browse one known frame, use figma_metadata instead. Read-only. Filters combine, so a node must match every filter given; with no filters, every node is listed up to the limit. Searching all pages first loads every page, which is slower on big files. Returns {hits, scanned, pages, truncated}. Each hit has id, name, type, page, position and size, plus the first 120 characters for text nodes.
- **figma_changes** — Report what changed in the file since your last check: nodes created, deleted or edited, with the properties that changed. Use it before editing a design the person may have touched, so you do not overwrite their work, and pass the returned seq as since on the next call. Edits made by localfig's own tools are hidden unless includePlugin is true. They are recognized by timing, so an edit the person makes within two seconds of a tool call can be misattributed. Only pages the plugin has seen are tracked, and the buffer keeps the last 1000 changes. Read-only. Returns {seq, total, returned, summary, changes}, where summary groups the listed changes per node.
- **figma_history** — Save a restore point, or undo localfig's most recent edit. action "snapshot" saves a named version to the file's version history, which the person can restore from Figma; use it before large or risky changes. action "undo" reverts every edit made by the most recent figma_eval, figma_place_image or figma_library import, but only within 60 seconds of that call; after that, the person can still press Ctrl+Z in Figma, where each tool call is one undo step. Snapshot adds a version and changes nothing else; undo modifies the file. Returns {ok, action}, plus the title and version id for a snapshot.
- **figma_library** — Use components, styles and variables from the team libraries enabled for this file. action "collections" lists the library variable collections available; "variables" lists the variables in one collection; "import" copies one component, component set, style or variable into this file by its key and, for a component, can also place an instance. Use it to build with the team's design system instead of recreating parts. Component keys of existing instances come from figma_metadata with styles:true. Listing is read-only; import adds items to the file and counts as one undo step. Needs the teamlibrary permission, which the localfig plugin requests. Returns the list for collections and variables, or {id, name, kind} plus instanceId for an import.
- **figma_place_image** — Fill a node with a local image file, such as a photo or an illustration. Use it instead of figma_eval whenever the image comes from disk. The node must support fills, like a rectangle, ellipse or frame, and its existing fills are replaced by the image. Any format a browser can read works, including PNG, JPG, WebP, GIF, BMP and AVIF; images larger than maxSide are scaled down first, and formats Figma cannot read are converted to PNG. Counts as one undo step. Returns the image and node sizes, plus a prepared object describing any resizing or conversion.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "localfig": {
    "command": "npx",
    "args": ["-y","localfig"]
  }
}
```

## Documentation

## What localfig MCP server does

The localfig MCP server gives an MCP client access to the Figma Plugin API for the design file currently open in Figma Desktop. It supports both inspection and mutation: an agent can read document structure, text, geometry, styles, variables, components, and computed CSS, then create or modify content through Plugin API JavaScript.

The connection is local. Since operations target the file where the plugin is running, the server does not accept a file key to select another document remotely.

Available operations include searching nodes, tracking changes made by a person, saving named restore points, undoing the last tool call, using team-library assets, exporting selected nodes, and adding local images as fills.

## How it works

The MCP client starts the Node-based stdio server. That process communicates over localhost with a small development plugin running inside Figma Desktop, and the plugin calls the Figma Plugin API. The plugin panel must remain open while the connection is in use.

`figma_eval` runs asynchronous JavaScript in the plugin sandbox. The script can use the global `figma` object and provided helpers for common operations such as loading fonts, setting text, resizing nodes, creating variables, importing components, and revealing edited content. Results should be returned as plain data; Figma node references are reduced to basic identity fields.

## Setup and configuration

Install Node.js 18 or newer, Figma Desktop, and an MCP client that can launch a stdio server. Run `npx -y localfig --setup` once. Setup generates a local secret, writes the plugin files, and registers the server with detected supported clients. `--dry-run` previews changes, while `--clients=cursor,vscode` limits registration to selected clients. Existing configuration is merged and backed up before changes.

Import `~/.localfig/plugin/manifest.json` into Figma through Plugins, Development, and Import plugin from manifest. Open a design file, run the localfig plugin, and leave its panel open. Restart an MCP client that was already running after registration. For unsupported clients, add a stdio entry using `npx -y localfig`; Windows clients generally need `cmd /c` before `npx`.

## Tools and capabilities

The localfig MCP server provides these tools:

- `figma_status` reports the connected plugin, open file, page, selection, top-level frames, active user, and dynamic-code availability.
- `figma_metadata`, `figma_tokens`, and `figma_find` inspect structure, styles, variables, libraries, and matching nodes.
- `figma_eval` executes arbitrary Plugin API JavaScript for operations not covered by fixed commands.
- `figma_changes` separates intervening human edits from tool-generated edits, while `figma_history` provides snapshots and one-step undo for mutating calls.
- `figma_library` works with team-library variables, components, and styles.
- `figma_export` writes PNG, JPG, SVG, PDF, or JSON exports; image results can be returned inline.
- `figma_place_image` adds locally available PNG, JPG, WebP, GIF, BMP, or AVIF images to node fills and downsizes images above 4096 pixels per side.

## Limitations and notes

Figma Desktop is required because development plugins cannot be imported in the browser. The plugin must be started manually for each session and disconnects when its panel or the file closes. All actions affect the active plugin file. Team-library operations require the plugin's declared permissions, including `teamlibrary`; the manifest also requests `currentuser` to identify who is driving.

Dynamic-page access means scripts should use asynchronous node lookup where required. Text changes require fonts to be loaded first, and resizing can alter text auto-resize or auto-layout sizing, so the supplied helpers handle ordering for common cases.

_Full upstream README: https://allmcps.com/mcp/localfig/readme_

