figma-mcp-console 0.6.0 → 0.7.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.
Binary file
Binary file
Binary file
Binary file
@@ -563,6 +563,36 @@ 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
+
566
596
  // ---------- command handlers (names match MCP tool names) ----------
567
597
 
568
598
  const handlers = {
@@ -843,6 +873,7 @@ const handlers = {
843
873
  },
844
874
 
845
875
  async import_image(params) {
876
+ if (params.svg !== undefined) return importSvg(params);
846
877
  const image = figma.createImage(figma.base64Decode(params.data));
847
878
  const paint = { type: "IMAGE", imageHash: image.hash, scaleMode: params.scale_mode || "FILL" };
848
879
  let n;
@@ -1435,6 +1466,28 @@ const handlers = {
1435
1466
  };
1436
1467
  },
1437
1468
 
1469
+ // Removing a variable detaches it from every node bound to it; those nodes
1470
+ // keep the value they showed.
1471
+ async remove_variables(params) {
1472
+ const removed = [];
1473
+ for (const id of params.variable_ids || []) {
1474
+ const v = await figma.variables.getVariableByIdAsync(id);
1475
+ if (!v) throw new Error("variable not found: " + id + " (see get_variable_defs)");
1476
+ removed.push({ id: v.id, name: v.name });
1477
+ v.remove();
1478
+ }
1479
+ if (!removed.length) throw new Error("variable_ids is required");
1480
+ return { removed };
1481
+ },
1482
+
1483
+ async remove_variable_collection(params) {
1484
+ const c = await figma.variables.getVariableCollectionByIdAsync(params.collection_id);
1485
+ if (!c) throw new Error("variable collection not found: " + params.collection_id + " (see get_variable_defs)");
1486
+ const out = { removed: { id: c.id, name: c.name, variables: c.variableIds.length } };
1487
+ c.remove();
1488
+ return out;
1489
+ },
1490
+
1438
1491
  async create_variable_collection(params) {
1439
1492
  const c = figma.variables.createVariableCollection(params.name);
1440
1493
  if (params.mode_name) c.renameMode(c.defaultModeId, params.mode_name);
@@ -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 = 4; // 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.7.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
  },