figma-mcp-console 0.6.0 β†’ 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,8 +11,12 @@
11
11
 
12
12
  - πŸ–₯️ **Figma β†’ Code** β€” paste a link to a Figma frame, and the AI implements that exact screen in your codebase, exporting the design's icons and images into your project instead of inventing its own
13
13
  - 🎨 **Requirement β†’ Figma** β€” paste a requirement, and the AI draws the screen in Figma, then screenshots its own work and fixes what's off
14
- - πŸ” **Token sync** β€” pull design tokens into your theme config, or build a design system in Figma from your code
15
- - ✏️ **Bulk editing** β€” rename layers, replace text across a page, reorganize frames
14
+ - πŸ” **Token sync** β€” export Figma variables to CSS or design-tokens JSON (`export_tokens`), and import them back from your code (`import_tokens`), updating what changed instead of duplicating
15
+ - βœ… **Design checks** β€” `audit_design` lists layers that are cut off or overflow, text that spills or is truncated, text below WCAG contrast, and tap targets that are too small
16
+ - πŸ” **What changed in the design** β€” `diff_design` compares a frame with a checkpoint you save from the plugin window; `get_component_states` lists every state a screen's components define
17
+ - ✏️ **Bulk editing** β€” rename layers, replace text across a page, reorganize frames; `batch` runs many steps in one call
18
+ - 🎯 **Icons** β€” import SVG icons as editable vectors, resized and recolored, from your file's own components or an icon library
19
+ - πŸ”’ **Read-only by default** β€” the AI can read a file but not change it until you untick **Read-only** in the plugin window
16
20
 
17
21
  ---
18
22
 
@@ -180,7 +184,8 @@ Then, in both cases:
180
184
 
181
185
  2. In **Figma Desktop**: **Plugins β†’ Development β†’ Import plugin from manifest…** β†’ select `manifest.json` *(one-time step)*
182
186
  3. Run it: **Plugins β†’ Development β†’ Figma MCP Console** β€” and **keep the plugin window open** while you work. 🟒 Green dot = connected
183
- 4. Working with several Figma files at once? Run the plugin in **each** file β€” every window connects to the same local bridge, and the AI picks the right file per call
187
+ 4. **Untick Read-only** in the plugin window when you want the AI to change the design. It is ticked every time the plugin opens, so a file you only want read stays safe; reading, screenshots, exports and checks work either way
188
+ 5. Working with several Figma files at once? Run the plugin in **each** file β€” every window connects to the same local bridge, and the AI picks the right file per call
184
189
 
185
190
  ### Step 3 β€” Try it
186
191
 
@@ -200,7 +205,11 @@ cards, pricing with three plans, footer. Light theme, use auto-layout, then
200
205
  screenshot and fix anything off.
201
206
  ```
202
207
 
203
- > 🎯 Asking the AI to **screenshot and compare** at the end makes it check its own work instead of guessing.
208
+ > 🎯 Asking the AI to **run `audit_design`, then screenshot and compare** at the end makes it check its own work instead of guessing.
209
+
210
+ ### Updating
211
+
212
+ When you update the server (`figma-mcp-console@<version>`), **re-import the plugin** from that release's `plugin.zip`: a hand-installed plugin cannot update itself. The plugin window says *Plugin outdated* or *Server outdated* when the two do not match. Release notes: [CHANGELOG.md](CHANGELOG.md).
204
213
 
205
214
  ---
206
215
 
@@ -243,6 +252,10 @@ Exports follow the file extension the AI picks (`.svg` for vector, `.png`/`.jpg`
243
252
  | 🚫 The MCP server doesn't appear in your AI tool | Check Node.js 18+ is installed (`node -v`) |
244
253
  | πŸ“ Exported files end up in the wrong folder | Exports are written relative to where the server runs. Register it in the project-level config, or tell the AI an explicit export path |
245
254
  | πŸ”€ Font errors when creating text | The Figma file uses a font not installed on your machine β€” the error message names it |
255
+ | πŸ”’ "… was blocked: read-only mode is on" | **Read-only** is ticked in that file's plugin window (it is, every time the plugin opens). Untick it if the edit is intended |
256
+ | ⚠ "Plugin outdated" / "the plugin … is outdated" | Re-import the plugin from the latest release's `plugin.zip` and run it again |
257
+ | ⚠ "Server outdated" | Restart your AI client, or update the version in its MCP config |
258
+ | πŸ‘ The plugin will not run in a file | Figma runs plugins only for people who can edit the file. Duplicate it to your drafts, or copy the frames into a file you can edit |
246
259
 
247
260
  ## πŸ›  Contributing
248
261
 
Binary file
Binary file
Binary file
Binary file
@@ -563,6 +563,48 @@ function resolveBatchRefs(v, results) {
563
563
  // they only work as their own tool call.
564
564
  const NOT_BATCHABLE = ["batch", "download_assets", "import_image", "get_screenshot"];
565
565
 
566
+ // An SVG becomes editable vector layers (createImage takes only PNG, JPG and
567
+ // GIF), scaled as a whole so stroke widths keep their proportion, the way a
568
+ // designer scales an icon.
569
+ async function importSvg(params) {
570
+ if (params.node_id) {
571
+ throw new Error("an SVG becomes layers, not a fill: omit node_id, and pass parent_id to place it inside a node");
572
+ }
573
+ const n = figma.createNodeFromSvg(params.svg);
574
+ n.fills = []; // the wrapper frame; the SVG's own shapes are its children
575
+ if (params.name) n.name = params.name;
576
+ if (params.color) {
577
+ const c = hexToRGB(params.color);
578
+ // Icons draw with fills or strokes (lucide uses strokes); recolor every
579
+ // solid paint and keep its opacity.
580
+ const recolor = (paints) => paints.map((p) => (p.type === "SOLID" ? Object.assign({}, p, { color: c }) : p));
581
+ for (const d of n.findAll(() => true)) {
582
+ if ("fills" in d && Array.isArray(d.fills) && d.fills.length) d.fills = recolor(d.fills);
583
+ if ("strokes" in d && Array.isArray(d.strokes) && d.strokes.length) d.strokes = recolor(d.strokes);
584
+ }
585
+ }
586
+ const w = params.width > 0 ? params.width / n.width : 0;
587
+ const h = params.height > 0 ? params.height / n.height : 0;
588
+ const scale = w && h ? Math.min(w, h) : w || h;
589
+ if (scale && Math.abs(scale - 1) > 1e-6) n.rescale(scale);
590
+ n.x = params.x || 0;
591
+ n.y = params.y || 0;
592
+ (await parentOf(params)).appendChild(n);
593
+ return summarize(n);
594
+ }
595
+
596
+ // Figma's own wording for "could not load that data" blames the network,
597
+ // which sends people checking their connection. It shows up when a page that
598
+ // was never opened in this session is loaded, and for some ids that do not exist.
599
+ function explainError(message) {
600
+ if (/Unable to establish connection to Figma/i.test(message)) {
601
+ return message + " β€” Figma could not load the data for this request; the network is usually fine. " +
602
+ "If it reads another page, open that page once in Figma (or reopen the file) and retry; " +
603
+ "if it names a node id, check the id with find_nodes.";
604
+ }
605
+ return message;
606
+ }
607
+
566
608
  // ---------- command handlers (names match MCP tool names) ----------
567
609
 
568
610
  const handlers = {
@@ -585,6 +627,36 @@ const handlers = {
585
627
  };
586
628
  },
587
629
 
630
+ async create_page(params) {
631
+ if (!params.name) throw new Error("name is required");
632
+ const p = figma.createPage();
633
+ p.name = params.name;
634
+ if (params.index !== undefined && params.index !== null) figma.root.insertChild(params.index, p);
635
+ return { id: p.id, name: p.name, index: figma.root.children.indexOf(p) };
636
+ },
637
+
638
+ async rename_page(params) {
639
+ if (!params.name) throw new Error("name is required");
640
+ const p = await resolvePage(params.page);
641
+ const from = p.name;
642
+ p.name = params.name;
643
+ return { id: p.id, from, name: p.name };
644
+ },
645
+
646
+ // Figma cannot remove the open page or the last one: open a neighbour first.
647
+ async remove_page(params) {
648
+ const p = await resolvePage(params.page);
649
+ const pages = figma.root.children;
650
+ if (pages.length === 1) throw new Error("page " + p.name + " is the file's only page and cannot be removed");
651
+ if (p.id === figma.currentPage.id) {
652
+ const i = pages.indexOf(p);
653
+ await figma.setCurrentPageAsync(pages[i === 0 ? 1 : i - 1]);
654
+ }
655
+ const out = { removed: { id: p.id, name: p.name, layers: p.children.length }, currentPage: figma.currentPage.name };
656
+ p.remove();
657
+ return out;
658
+ },
659
+
588
660
  async set_current_page(params) {
589
661
  const p = await resolvePage(params.page);
590
662
  await figma.setCurrentPageAsync(p);
@@ -843,6 +915,7 @@ const handlers = {
843
915
  },
844
916
 
845
917
  async import_image(params) {
918
+ if (params.svg !== undefined) return importSvg(params);
846
919
  const image = figma.createImage(figma.base64Decode(params.data));
847
920
  const paint = { type: "IMAGE", imageHash: image.hash, scaleMode: params.scale_mode || "FILL" };
848
921
  let n;
@@ -1435,6 +1508,28 @@ const handlers = {
1435
1508
  };
1436
1509
  },
1437
1510
 
1511
+ // Removing a variable detaches it from every node bound to it; those nodes
1512
+ // keep the value they showed.
1513
+ async remove_variables(params) {
1514
+ const removed = [];
1515
+ for (const id of params.variable_ids || []) {
1516
+ const v = await figma.variables.getVariableByIdAsync(id);
1517
+ if (!v) throw new Error("variable not found: " + id + " (see get_variable_defs)");
1518
+ removed.push({ id: v.id, name: v.name });
1519
+ v.remove();
1520
+ }
1521
+ if (!removed.length) throw new Error("variable_ids is required");
1522
+ return { removed };
1523
+ },
1524
+
1525
+ async remove_variable_collection(params) {
1526
+ const c = await figma.variables.getVariableCollectionByIdAsync(params.collection_id);
1527
+ if (!c) throw new Error("variable collection not found: " + params.collection_id + " (see get_variable_defs)");
1528
+ const out = { removed: { id: c.id, name: c.name, variables: c.variableIds.length } };
1529
+ c.remove();
1530
+ return out;
1531
+ },
1532
+
1438
1533
  async create_variable_collection(params) {
1439
1534
  const c = figma.variables.createVariableCollection(params.name);
1440
1535
  if (params.mode_name) c.renameMode(c.defaultModeId, params.mode_name);
@@ -1699,7 +1794,7 @@ figma.ui.onmessage = async (msg) => {
1699
1794
  const result = await h(p);
1700
1795
  figma.ui.postMessage({ id: msg.id, result: result === undefined ? null : result });
1701
1796
  } catch (e) {
1702
- act.error = String((e && e.message) || e);
1797
+ act.error = explainError(String((e && e.message) || e));
1703
1798
  figma.ui.postMessage({ id: msg.id, error: act.error });
1704
1799
  }
1705
1800
  figma.ui.postMessage({ activity: act });
@@ -289,7 +289,7 @@
289
289
  // the status line also trigger an immediate attempt.
290
290
  const PORT = 2000,
291
291
  RETRY = 1000,
292
- PROTOCOL = 3; // must match bridge.ProtocolVersion in the Go server
292
+ PROTOCOL = 5; // must match bridge.ProtocolVersion in the Go server
293
293
  let ws = null; // open connection, null while disconnected
294
294
  let attempt = null; // socket currently trying to connect
295
295
  let reg = null; // {key, name} of this file, sent by the main thread
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "figma-mcp-console",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "scripts": {
5
5
  "prepublishOnly": "test -d bin/plugin && cd .. && go vet ./... && go test ./... && node --check plugin/code.js && cp README.md npm/README.md"
6
6
  },