mcp-figma-toolkit 1.0.14 → 1.0.15

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/plugin/plugin.js +28 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-figma-toolkit",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "MCP server that enables AI agents to manipulate Figma documents - create shapes, text, styles, components, variables, and more",
5
5
  "type": "module",
6
6
  "main": "dist/server.js",
package/plugin/plugin.js CHANGED
@@ -1375,43 +1375,49 @@ function createVariable({ collectionId, name, resolvedType, values, scopes }) {
1375
1375
  };
1376
1376
  }
1377
1377
 
1378
- function getLocalVariableCollections() {
1379
- const collections = figma.variables.getLocalVariableCollections();
1380
- return collections.map(c => ({
1381
- collectionId: c.id,
1382
- name: c.name,
1383
- modes: c.modes.map(m => ({ modeId: m.modeId, name: m.name })),
1384
- variableIds: c.variableIds
1385
- }));
1378
+ async function getLocalVariableCollections() {
1379
+ var collections = await figma.variables.getLocalVariableCollectionsAsync();
1380
+ return collections.map(function(c) {
1381
+ return {
1382
+ collectionId: c.id,
1383
+ name: c.name,
1384
+ modes: c.modes.map(function(m) { return { modeId: m.modeId, name: m.name }; }),
1385
+ variableIds: c.variableIds
1386
+ };
1387
+ });
1386
1388
  }
1387
1389
 
1388
- function getLocalVariables({ collectionId } = {}) {
1389
- const variables = figma.variables.getLocalVariables();
1390
- const filtered = collectionId
1391
- ? variables.filter(v => v.variableCollectionId === collectionId)
1390
+ async function getLocalVariables(input) {
1391
+ var collectionId = input != null ? input.collectionId : undefined;
1392
+ var variables = await figma.variables.getLocalVariablesAsync();
1393
+ var filtered = collectionId
1394
+ ? variables.filter(function(v) { return v.variableCollectionId === collectionId; })
1392
1395
  : variables;
1393
1396
 
1394
- return filtered.map(v => {
1395
- const valuesByMode = {};
1396
- const collection = figma.variables.getVariableCollectionById(v.variableCollectionId);
1397
+ var results = [];
1398
+ for (var i = 0; i < filtered.length; i++) {
1399
+ var v = filtered[i];
1400
+ var valuesByMode = {};
1401
+ var collection = await figma.variables.getVariableCollectionByIdAsync(v.variableCollectionId);
1397
1402
  if (collection) {
1398
- for (const mode of collection.modes) {
1399
- let val = v.valuesByMode[mode.modeId];
1400
- // Convert RGB back to hex for COLOR type
1403
+ for (var j = 0; j < collection.modes.length; j++) {
1404
+ var mode = collection.modes[j];
1405
+ var val = v.valuesByMode[mode.modeId];
1401
1406
  if (v.resolvedType === "COLOR" && val && typeof val === "object" && "r" in val) {
1402
1407
  val = rgbToHex(val);
1403
1408
  }
1404
1409
  valuesByMode[mode.modeId] = val;
1405
1410
  }
1406
1411
  }
1407
- return {
1412
+ results.push({
1408
1413
  variableId: v.id,
1409
1414
  name: v.name,
1410
1415
  resolvedType: v.resolvedType,
1411
1416
  collectionId: v.variableCollectionId,
1412
- valuesByMode
1413
- };
1414
- });
1417
+ valuesByMode: valuesByMode
1418
+ });
1419
+ }
1420
+ return results;
1415
1421
  }
1416
1422
 
1417
1423
  function setVariableValue({ variableId, modeId, value }) {