@muloka/figma-console-mcp 0.5.7 → 0.6.1

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 (116) hide show
  1. package/README.md +120 -848
  2. package/dist/apps/design-system-dashboard/mcp-app.html +107 -94
  3. package/dist/apps/design-system-dashboard/server.d.ts +1 -1
  4. package/dist/apps/design-system-dashboard/server.d.ts.map +1 -1
  5. package/dist/apps/token-browser/mcp-app.html +95 -82
  6. package/dist/apps/token-browser/server.d.ts +1 -1
  7. package/dist/apps/token-browser/server.d.ts.map +1 -1
  8. package/dist/core/accessibility-tools.d.ts +1 -1
  9. package/dist/core/accessibility-tools.d.ts.map +1 -1
  10. package/dist/core/accessibility-tools.js +18 -15
  11. package/dist/core/accessibility-tools.js.map +1 -1
  12. package/dist/core/annotation-tools.d.ts +1 -1
  13. package/dist/core/annotation-tools.d.ts.map +1 -1
  14. package/dist/core/annotation-tools.js +35 -26
  15. package/dist/core/annotation-tools.js.map +1 -1
  16. package/dist/core/comment-tools.d.ts +2 -2
  17. package/dist/core/comment-tools.d.ts.map +1 -1
  18. package/dist/core/comment-tools.js +60 -51
  19. package/dist/core/comment-tools.js.map +1 -1
  20. package/dist/core/config.d.ts.map +1 -1
  21. package/dist/core/config.js +2 -17
  22. package/dist/core/config.js.map +1 -1
  23. package/dist/core/console-monitor.d.ts +1 -1
  24. package/dist/core/console-monitor.d.ts.map +1 -1
  25. package/dist/core/console-monitor.js +2 -2
  26. package/dist/core/console-monitor.js.map +1 -1
  27. package/dist/core/deep-component-tools.d.ts +1 -1
  28. package/dist/core/deep-component-tools.d.ts.map +1 -1
  29. package/dist/core/deep-component-tools.js +15 -9
  30. package/dist/core/deep-component-tools.js.map +1 -1
  31. package/dist/core/design-code-tools.d.ts +1 -1
  32. package/dist/core/design-code-tools.d.ts.map +1 -1
  33. package/dist/core/design-code-tools.js +53 -47
  34. package/dist/core/design-code-tools.js.map +1 -1
  35. package/dist/core/design-system-manifest.d.ts +37 -2
  36. package/dist/core/design-system-manifest.d.ts.map +1 -1
  37. package/dist/core/design-system-manifest.js +85 -0
  38. package/dist/core/design-system-manifest.js.map +1 -1
  39. package/dist/core/design-system-tools.d.ts +1 -1
  40. package/dist/core/design-system-tools.d.ts.map +1 -1
  41. package/dist/core/design-system-tools.js +39 -36
  42. package/dist/core/design-system-tools.js.map +1 -1
  43. package/dist/core/diagnose-tool.d.ts +8 -4
  44. package/dist/core/diagnose-tool.d.ts.map +1 -1
  45. package/dist/core/diagnose-tool.js +18 -15
  46. package/dist/core/diagnose-tool.js.map +1 -1
  47. package/dist/core/figjam-tools.d.ts +2 -2
  48. package/dist/core/figjam-tools.d.ts.map +1 -1
  49. package/dist/core/figjam-tools.js +159 -129
  50. package/dist/core/figjam-tools.js.map +1 -1
  51. package/dist/core/figma-connector.d.ts +14 -3
  52. package/dist/core/figma-connector.d.ts.map +1 -1
  53. package/dist/core/figma-tools.d.ts +1 -1
  54. package/dist/core/figma-tools.d.ts.map +1 -1
  55. package/dist/core/figma-tools.js +284 -267
  56. package/dist/core/figma-tools.js.map +1 -1
  57. package/dist/core/identity.d.ts +49 -9
  58. package/dist/core/identity.d.ts.map +1 -1
  59. package/dist/core/identity.js +137 -28
  60. package/dist/core/identity.js.map +1 -1
  61. package/dist/core/library-tools.d.ts +1 -1
  62. package/dist/core/library-tools.d.ts.map +1 -1
  63. package/dist/core/library-tools.js +45 -36
  64. package/dist/core/library-tools.js.map +1 -1
  65. package/dist/core/logger.d.ts +0 -1
  66. package/dist/core/logger.d.ts.map +1 -1
  67. package/dist/core/logger.js +1 -13
  68. package/dist/core/logger.js.map +1 -1
  69. package/dist/core/slides-tools.d.ts +2 -2
  70. package/dist/core/slides-tools.d.ts.map +1 -1
  71. package/dist/core/slides-tools.js +223 -172
  72. package/dist/core/slides-tools.js.map +1 -1
  73. package/dist/core/slot-tools.d.ts +1 -1
  74. package/dist/core/slot-tools.d.ts.map +1 -1
  75. package/dist/core/slot-tools.js +101 -86
  76. package/dist/core/slot-tools.js.map +1 -1
  77. package/dist/core/tokens/config.d.ts +88 -266
  78. package/dist/core/tokens/config.d.ts.map +1 -1
  79. package/dist/core/tokens/config.js +2 -3
  80. package/dist/core/tokens/config.js.map +1 -1
  81. package/dist/core/tokens/schemas.d.ts +104 -113
  82. package/dist/core/tokens/schemas.d.ts.map +1 -1
  83. package/dist/core/tokens/schemas.js +2 -2
  84. package/dist/core/tokens/schemas.js.map +1 -1
  85. package/dist/core/tokens-tools.d.ts +5 -3
  86. package/dist/core/tokens-tools.d.ts.map +1 -1
  87. package/dist/core/tokens-tools.js +13 -10
  88. package/dist/core/tokens-tools.js.map +1 -1
  89. package/dist/core/types/index.d.ts +1 -1
  90. package/dist/core/types/index.d.ts.map +1 -1
  91. package/dist/core/variable-resolver.d.ts +3 -3
  92. package/dist/core/variable-resolver.d.ts.map +1 -1
  93. package/dist/core/variable-resolver.js +6 -9
  94. package/dist/core/variable-resolver.js.map +1 -1
  95. package/dist/core/version-tools.d.ts +4 -4
  96. package/dist/core/version-tools.d.ts.map +1 -1
  97. package/dist/core/version-tools.js +162 -144
  98. package/dist/core/version-tools.js.map +1 -1
  99. package/dist/core/websocket-connector.d.ts +4 -7
  100. package/dist/core/websocket-connector.d.ts.map +1 -1
  101. package/dist/core/websocket-connector.js +28 -39
  102. package/dist/core/websocket-connector.js.map +1 -1
  103. package/dist/core/websocket-server.d.ts +36 -2
  104. package/dist/core/websocket-server.d.ts.map +1 -1
  105. package/dist/core/websocket-server.js +69 -8
  106. package/dist/core/websocket-server.js.map +1 -1
  107. package/dist/core/write-tools.d.ts +2 -2
  108. package/dist/core/write-tools.d.ts.map +1 -1
  109. package/dist/core/write-tools.js +564 -471
  110. package/dist/core/write-tools.js.map +1 -1
  111. package/dist/local.d.ts +8 -1
  112. package/dist/local.d.ts.map +1 -1
  113. package/dist/local.js +390 -302
  114. package/dist/local.js.map +1 -1
  115. package/figma-desktop-bridge/code.js +23 -2
  116. package/package.json +11 -19
@@ -51,7 +51,7 @@ export function sandboxSafeJson(json) {
51
51
  }
52
52
  /**
53
53
  * Register write/manipulation tools that require a Desktop Bridge connector.
54
- * Used by both local mode (src/local.ts) and cloud mode (src/index.ts).
54
+ * Registered by src/local.ts.
55
55
  * `getDesktopConnector(fileKey)` returns a connector bound to that file;
56
56
  * with no key, one that follows the active file.
57
57
  */
@@ -59,7 +59,8 @@ export function registerWriteTools(server, getDesktopConnector, options) {
59
59
  // ============================================================================
60
60
  // EXECUTION TOOL
61
61
  // ============================================================================
62
- server.tool("figma_execute", `Execute arbitrary JavaScript in Figma's plugin context with full access to the figma API. Use for complex operations not covered by other tools. Requires Desktop Bridge plugin. CAUTION: Can modify your document.
62
+ server.registerTool("figma_execute", {
63
+ description: `Execute arbitrary JavaScript in Figma's plugin context with full access to the figma API. Use for complex operations not covered by other tools. Requires Desktop Bridge plugin. CAUTION: Can modify your document.
63
64
 
64
65
  **COMPONENT INSTANCES:** For instances (node.type === 'INSTANCE'), use figma_set_instance_properties — direct text editing FAILS SILENTLY. Check instance.componentProperties for available props (may have #nodeId suffixes).
65
66
 
@@ -75,17 +76,19 @@ When creating: place inside a named Section, positioned BELOW or AWAY from exist
75
76
  After creating: screenshot to verify clean placement and no overlaps.
76
77
  On failure/retry: DELETE any partial artifacts (empty frames, orphaned layers, blank pages) before retrying. Use node.remove() to clean up.
77
78
  Pages: NEVER create a new page if one with that name already exists — use the existing one. If you created a blank page during a failed attempt, delete it.
78
- Layers: If your code creates helper frames, placeholder nodes, or intermediate layers that aren't part of the final result, remove them.`, {
79
- code: z
80
- .string()
81
- .describe("JavaScript code to execute. Has access to the 'figma' global object. " +
82
- "Example: 'const rect = figma.createRectangle(); rect.resize(100, 100); return { id: rect.id };'"),
83
- timeout: z
84
- .number()
85
- .optional()
86
- .default(5000)
87
- .describe("Execution timeout in milliseconds (default: 5000, max: 30000)"),
88
- fileKey: fileKeyArg,
79
+ Layers: If your code creates helper frames, placeholder nodes, or intermediate layers that aren't part of the final result, remove them.`,
80
+ inputSchema: z.object({
81
+ code: z
82
+ .string()
83
+ .describe("JavaScript code to execute. Has access to the 'figma' global object. " +
84
+ "Example: 'const rect = figma.createRectangle(); rect.resize(100, 100); return { id: rect.id };'"),
85
+ timeout: z
86
+ .number()
87
+ .optional()
88
+ .default(5000)
89
+ .describe("Execution timeout in milliseconds (default: 5000, max: 30000)"),
90
+ fileKey: fileKeyArg,
91
+ }),
89
92
  }, async ({ code, timeout, fileKey }) => {
90
93
  try {
91
94
  const connector = await getDesktopConnector(fileKey);
@@ -127,23 +130,26 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
127
130
  // VARIABLE MANAGEMENT TOOLS
128
131
  // ============================================================================
129
132
  // Tool: Update a variable's value
130
- server.tool("figma_update_variable", "Update a single variable's value and/or its description. Pass modeId+value to change the value in a mode; pass description to set the 'How to use this variable' text shown in the Variables panel (and exported as DTCG $description). At least one of {modeId+value} or {description} is required. For many value updates at once, use figma_batch_update_variables (10-50x faster). Use figma_get_variables first for IDs. COLOR: hex '#FF0000', FLOAT: number, STRING: text, BOOLEAN: true/false. Requires Desktop Bridge plugin.", {
131
- variableId: z
132
- .string()
133
- .describe("The variable ID to update (e.g., 'VariableID:123:456'). Get this from figma_get_variables."),
134
- modeId: z
135
- .string()
136
- .optional()
137
- .describe("The mode ID to update the value in (e.g., '1:0'). Required when updating a value. Get this from the variable's collection modes."),
138
- value: z
139
- .union([z.string(), z.number(), z.boolean()])
140
- .optional()
141
- .describe("The new value (requires modeId). For COLOR: hex string like '#FF0000'. For FLOAT: number. For STRING: text. For BOOLEAN: true/false."),
142
- description: z
143
- .string()
144
- .optional()
145
- .describe("Set the variable's description (the 'How to use this variable' field; exported as DTCG $description). Pass an empty string to clear it."),
146
- fileKey: fileKeyArg,
133
+ server.registerTool("figma_update_variable", {
134
+ description: "Update a single variable's value and/or its description. Pass modeId+value to change the value in a mode; pass description to set the 'How to use this variable' text shown in the Variables panel (and exported as DTCG $description). At least one of {modeId+value} or {description} is required. For many value updates at once, use figma_batch_update_variables (10-50x faster). Use figma_get_variables first for IDs. COLOR: hex '#FF0000', FLOAT: number, STRING: text, BOOLEAN: true/false. Requires Desktop Bridge plugin.",
135
+ inputSchema: z.object({
136
+ variableId: z
137
+ .string()
138
+ .describe("The variable ID to update (e.g., 'VariableID:123:456'). Get this from figma_get_variables."),
139
+ modeId: z
140
+ .string()
141
+ .optional()
142
+ .describe("The mode ID to update the value in (e.g., '1:0'). Required when updating a value. Get this from the variable's collection modes."),
143
+ value: z
144
+ .union([z.string(), z.number(), z.boolean()])
145
+ .optional()
146
+ .describe("The new value (requires modeId). For COLOR: hex string like '#FF0000'. For FLOAT: number. For STRING: text. For BOOLEAN: true/false."),
147
+ description: z
148
+ .string()
149
+ .optional()
150
+ .describe("Set the variable's description (the 'How to use this variable' field; exported as DTCG $description). Pass an empty string to clear it."),
151
+ fileKey: fileKeyArg,
152
+ }),
147
153
  }, async ({ variableId, modeId, value, description, fileKey }) => {
148
154
  try {
149
155
  const connector = await getDesktopConnector(fileKey);
@@ -211,25 +217,28 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
211
217
  }
212
218
  });
213
219
  // Tool: Create a new variable
214
- server.tool("figma_create_variable", "Create a single Figma variable. For multiple variables, use figma_batch_create_variables instead (10-50x faster). Use figma_get_variables first to get collection IDs. Supports COLOR, FLOAT, STRING, BOOLEAN. Requires Desktop Bridge plugin.", {
215
- name: z
216
- .string()
217
- .describe("Name for the new variable (e.g., 'primary-blue')"),
218
- collectionId: z
219
- .string()
220
- .describe("The collection ID to create the variable in (e.g., 'VariableCollectionId:123:456'). Get this from figma_get_variables."),
221
- resolvedType: z
222
- .enum(["COLOR", "FLOAT", "STRING", "BOOLEAN"])
223
- .describe("The variable type: COLOR, FLOAT, STRING, or BOOLEAN"),
224
- description: z
225
- .string()
226
- .optional()
227
- .describe("Optional description for the variable"),
228
- valuesByMode: z
229
- .record(z.string(), z.union([z.string(), z.number(), z.boolean()]))
230
- .optional()
231
- .describe("Optional initial values by mode ID. Example: { '1:0': '#FF0000', '1:1': '#0000FF' }"),
232
- fileKey: fileKeyArg,
220
+ server.registerTool("figma_create_variable", {
221
+ description: "Create a single Figma variable. For multiple variables, use figma_batch_create_variables instead (10-50x faster). Use figma_get_variables first to get collection IDs. Supports COLOR, FLOAT, STRING, BOOLEAN. Requires Desktop Bridge plugin.",
222
+ inputSchema: z.object({
223
+ name: z
224
+ .string()
225
+ .describe("Name for the new variable (e.g., 'primary-blue')"),
226
+ collectionId: z
227
+ .string()
228
+ .describe("The collection ID to create the variable in (e.g., 'VariableCollectionId:123:456'). Get this from figma_get_variables."),
229
+ resolvedType: z
230
+ .enum(["COLOR", "FLOAT", "STRING", "BOOLEAN"])
231
+ .describe("The variable type: COLOR, FLOAT, STRING, or BOOLEAN"),
232
+ description: z
233
+ .string()
234
+ .optional()
235
+ .describe("Optional description for the variable"),
236
+ valuesByMode: z
237
+ .record(z.string(), z.union([z.string(), z.number(), z.boolean()]))
238
+ .optional()
239
+ .describe("Optional initial values by mode ID. Example: { '1:0': '#FF0000', '1:1': '#0000FF' }"),
240
+ fileKey: fileKeyArg,
241
+ }),
233
242
  }, async ({ name, collectionId, resolvedType, description, valuesByMode, fileKey, }) => {
234
243
  try {
235
244
  const connector = await getDesktopConnector(fileKey);
@@ -273,19 +282,22 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
273
282
  }
274
283
  });
275
284
  // Tool: Create a new variable collection
276
- server.tool("figma_create_variable_collection", "Create an empty variable collection. To create a collection WITH variables and modes in one step, use figma_setup_design_tokens instead. Requires Desktop Bridge plugin.", {
277
- name: z
278
- .string()
279
- .describe("Name for the new collection (e.g., 'Brand Colors')"),
280
- initialModeName: z
281
- .string()
282
- .optional()
283
- .describe("Name for the initial mode (default mode is created automatically). Example: 'Light'"),
284
- additionalModes: z
285
- .array(z.string())
286
- .optional()
287
- .describe("Additional mode names to create. Example: ['Dark', 'High Contrast']"),
288
- fileKey: fileKeyArg,
285
+ server.registerTool("figma_create_variable_collection", {
286
+ description: "Create an empty variable collection. To create a collection WITH variables and modes in one step, use figma_setup_design_tokens instead. Requires Desktop Bridge plugin.",
287
+ inputSchema: z.object({
288
+ name: z
289
+ .string()
290
+ .describe("Name for the new collection (e.g., 'Brand Colors')"),
291
+ initialModeName: z
292
+ .string()
293
+ .optional()
294
+ .describe("Name for the initial mode (default mode is created automatically). Example: 'Light'"),
295
+ additionalModes: z
296
+ .array(z.string())
297
+ .optional()
298
+ .describe("Additional mode names to create. Example: ['Dark', 'High Contrast']"),
299
+ fileKey: fileKeyArg,
300
+ }),
289
301
  }, async ({ name, initialModeName, additionalModes, fileKey }) => {
290
302
  try {
291
303
  const connector = await getDesktopConnector(fileKey);
@@ -329,11 +341,14 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
329
341
  }
330
342
  });
331
343
  // Tool: Delete a variable
332
- server.tool("figma_delete_variable", "Delete a Figma variable. WARNING: This is a destructive operation that cannot be undone (except with Figma's undo). Use figma_get_variables first to get variable IDs. Requires the Desktop Bridge plugin to be running.", {
333
- variableId: z
334
- .string()
335
- .describe("The variable ID to delete (e.g., 'VariableID:123:456'). Get this from figma_get_variables."),
336
- fileKey: fileKeyArg,
344
+ server.registerTool("figma_delete_variable", {
345
+ description: "Delete a Figma variable. WARNING: This is a destructive operation that cannot be undone (except with Figma's undo). Use figma_get_variables first to get variable IDs. Requires the Desktop Bridge plugin to be running.",
346
+ inputSchema: z.object({
347
+ variableId: z
348
+ .string()
349
+ .describe("The variable ID to delete (e.g., 'VariableID:123:456'). Get this from figma_get_variables."),
350
+ fileKey: fileKeyArg,
351
+ }),
337
352
  }, async ({ variableId, fileKey }) => {
338
353
  try {
339
354
  const connector = await getDesktopConnector(fileKey);
@@ -375,11 +390,14 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
375
390
  }
376
391
  });
377
392
  // Tool: Delete a variable collection
378
- server.tool("figma_delete_variable_collection", "Delete a Figma variable collection and ALL its variables. WARNING: This is a destructive operation that deletes all variables in the collection and cannot be undone (except with Figma's undo). Requires the Desktop Bridge plugin to be running.", {
379
- collectionId: z
380
- .string()
381
- .describe("The collection ID to delete (e.g., 'VariableCollectionId:123:456'). Get this from figma_get_variables."),
382
- fileKey: fileKeyArg,
393
+ server.registerTool("figma_delete_variable_collection", {
394
+ description: "Delete a Figma variable collection and ALL its variables. WARNING: This is a destructive operation that deletes all variables in the collection and cannot be undone (except with Figma's undo). Requires the Desktop Bridge plugin to be running.",
395
+ inputSchema: z.object({
396
+ collectionId: z
397
+ .string()
398
+ .describe("The collection ID to delete (e.g., 'VariableCollectionId:123:456'). Get this from figma_get_variables."),
399
+ fileKey: fileKeyArg,
400
+ }),
383
401
  }, async ({ collectionId, fileKey }) => {
384
402
  try {
385
403
  const connector = await getDesktopConnector(fileKey);
@@ -421,14 +439,17 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
421
439
  }
422
440
  });
423
441
  // Tool: Rename a variable
424
- server.tool("figma_rename_variable", "Rename an existing Figma variable. This updates the variable's name while preserving all its values and settings. Requires the Desktop Bridge plugin to be running.", {
425
- variableId: z
426
- .string()
427
- .describe("The variable ID to rename (e.g., 'VariableID:123:456'). Get this from figma_get_variables."),
428
- newName: z
429
- .string()
430
- .describe("The new name for the variable. Can include slashes for grouping (e.g., 'colors/primary/background')."),
431
- fileKey: fileKeyArg,
442
+ server.registerTool("figma_rename_variable", {
443
+ description: "Rename an existing Figma variable. This updates the variable's name while preserving all its values and settings. Requires the Desktop Bridge plugin to be running.",
444
+ inputSchema: z.object({
445
+ variableId: z
446
+ .string()
447
+ .describe("The variable ID to rename (e.g., 'VariableID:123:456'). Get this from figma_get_variables."),
448
+ newName: z
449
+ .string()
450
+ .describe("The new name for the variable. Can include slashes for grouping (e.g., 'colors/primary/background')."),
451
+ fileKey: fileKeyArg,
452
+ }),
432
453
  }, async ({ variableId, newName, fileKey }) => {
433
454
  try {
434
455
  const connector = await getDesktopConnector(fileKey);
@@ -470,14 +491,17 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
470
491
  }
471
492
  });
472
493
  // Tool: Add a mode to a collection
473
- server.tool("figma_add_mode", "Add a new mode to an existing Figma variable collection. Modes allow variables to have different values for different contexts (e.g., Light/Dark themes, device sizes). Requires the Desktop Bridge plugin to be running.", {
474
- collectionId: z
475
- .string()
476
- .describe("The collection ID to add the mode to (e.g., 'VariableCollectionId:123:456'). Get this from figma_get_variables."),
477
- modeName: z
478
- .string()
479
- .describe("The name for the new mode (e.g., 'Dark', 'Mobile', 'High Contrast')."),
480
- fileKey: fileKeyArg,
494
+ server.registerTool("figma_add_mode", {
495
+ description: "Add a new mode to an existing Figma variable collection. Modes allow variables to have different values for different contexts (e.g., Light/Dark themes, device sizes). Requires the Desktop Bridge plugin to be running.",
496
+ inputSchema: z.object({
497
+ collectionId: z
498
+ .string()
499
+ .describe("The collection ID to add the mode to (e.g., 'VariableCollectionId:123:456'). Get this from figma_get_variables."),
500
+ modeName: z
501
+ .string()
502
+ .describe("The name for the new mode (e.g., 'Dark', 'Mobile', 'High Contrast')."),
503
+ fileKey: fileKeyArg,
504
+ }),
481
505
  }, async ({ collectionId, modeName, fileKey }) => {
482
506
  try {
483
507
  const connector = await getDesktopConnector(fileKey);
@@ -521,17 +545,20 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
521
545
  }
522
546
  });
523
547
  // Tool: Rename a mode in a collection
524
- server.tool("figma_rename_mode", "Rename an existing mode in a Figma variable collection. Requires the Desktop Bridge plugin to be running.", {
525
- collectionId: z
526
- .string()
527
- .describe("The collection ID containing the mode (e.g., 'VariableCollectionId:123:456'). Get this from figma_get_variables."),
528
- modeId: z
529
- .string()
530
- .describe("The mode ID to rename (e.g., '123:0'). Get this from the collection's modes array in figma_get_variables."),
531
- newName: z
532
- .string()
533
- .describe("The new name for the mode (e.g., 'Dark Theme', 'Tablet')."),
534
- fileKey: fileKeyArg,
548
+ server.registerTool("figma_rename_mode", {
549
+ description: "Rename an existing mode in a Figma variable collection. Requires the Desktop Bridge plugin to be running.",
550
+ inputSchema: z.object({
551
+ collectionId: z
552
+ .string()
553
+ .describe("The collection ID containing the mode (e.g., 'VariableCollectionId:123:456'). Get this from figma_get_variables."),
554
+ modeId: z
555
+ .string()
556
+ .describe("The mode ID to rename (e.g., '123:0'). Get this from the collection's modes array in figma_get_variables."),
557
+ newName: z
558
+ .string()
559
+ .describe("The new name for the mode (e.g., 'Dark Theme', 'Tablet')."),
560
+ fileKey: fileKeyArg,
561
+ }),
535
562
  }, async ({ collectionId, modeId, newName, fileKey }) => {
536
563
  try {
537
564
  const connector = await getDesktopConnector(fileKey);
@@ -579,29 +606,32 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
579
606
  // reducing per-operation overhead from ~60-170ms to near-zero.
580
607
  // Use these instead of calling individual tools repeatedly.
581
608
  // Tool: Batch create variables
582
- server.tool("figma_batch_create_variables", "Create multiple variables in one operation. Use instead of calling figma_create_variable repeatedly — up to 50x faster for bulk operations. Get collection IDs from figma_get_variables first. Requires Desktop Bridge plugin.", {
583
- collectionId: z
584
- .string()
585
- .describe("Collection ID to create all variables in (e.g., 'VariableCollectionId:123:456')"),
586
- variables: z
587
- .array(z.object({
588
- name: z.string().describe("Variable name (e.g., 'primary-blue')"),
589
- resolvedType: z
590
- .enum(["COLOR", "FLOAT", "STRING", "BOOLEAN"])
591
- .describe("Variable type"),
592
- description: z
609
+ server.registerTool("figma_batch_create_variables", {
610
+ description: "Create multiple variables in one operation. Use instead of calling figma_create_variable repeatedly — up to 50x faster for bulk operations. Get collection IDs from figma_get_variables first. Requires Desktop Bridge plugin.",
611
+ inputSchema: z.object({
612
+ collectionId: z
593
613
  .string()
594
- .optional()
595
- .describe("Optional description"),
596
- valuesByMode: z
597
- .record(z.string(), z.union([z.string(), z.number(), z.boolean()]))
598
- .optional()
599
- .describe("Values by mode ID. For COLOR: hex like '#FF0000'. Example: { '1:0': '#FF0000' }"),
600
- }))
601
- .min(1)
602
- .max(100)
603
- .describe("Array of variables to create (1-100)"),
604
- fileKey: fileKeyArg,
614
+ .describe("Collection ID to create all variables in (e.g., 'VariableCollectionId:123:456')"),
615
+ variables: z
616
+ .array(z.object({
617
+ name: z.string().describe("Variable name (e.g., 'primary-blue')"),
618
+ resolvedType: z
619
+ .enum(["COLOR", "FLOAT", "STRING", "BOOLEAN"])
620
+ .describe("Variable type"),
621
+ description: z
622
+ .string()
623
+ .optional()
624
+ .describe("Optional description"),
625
+ valuesByMode: z
626
+ .record(z.string(), z.union([z.string(), z.number(), z.boolean()]))
627
+ .optional()
628
+ .describe("Values by mode ID. For COLOR: hex like '#FF0000'. Example: { '1:0': '#FF0000' }"),
629
+ }))
630
+ .min(1)
631
+ .max(100)
632
+ .describe("Array of variables to create (1-100)"),
633
+ fileKey: fileKeyArg,
634
+ }),
605
635
  }, async ({ collectionId, variables, fileKey }) => {
606
636
  try {
607
637
  const connector = await getDesktopConnector(fileKey);
@@ -699,23 +729,26 @@ return {
699
729
  }
700
730
  });
701
731
  // Tool: Batch update variables
702
- server.tool("figma_batch_update_variables", "Update multiple variable values in one operation. Use instead of calling figma_update_variable repeatedly — up to 50x faster for bulk updates. Get variable/mode IDs from figma_get_variables first. Requires Desktop Bridge plugin.", {
703
- updates: z
704
- .array(z.object({
705
- variableId: z
706
- .string()
707
- .describe("Variable ID (e.g., 'VariableID:123:456')"),
708
- modeId: z
709
- .string()
710
- .describe("Mode ID (e.g., '1:0')"),
711
- value: z
712
- .union([z.string(), z.number(), z.boolean()])
713
- .describe("New value. COLOR: hex like '#FF0000'. FLOAT: number. STRING: text. BOOLEAN: true/false. A string starting with 'VariableID:' (e.g. from figma_get_variables) aliases that variable directly by id."),
714
- }))
715
- .min(1)
716
- .max(100)
717
- .describe("Array of updates to apply (1-100)"),
718
- fileKey: fileKeyArg,
732
+ server.registerTool("figma_batch_update_variables", {
733
+ description: "Update multiple variable values in one operation. Use instead of calling figma_update_variable repeatedly — up to 50x faster for bulk updates. Get variable/mode IDs from figma_get_variables first. Requires Desktop Bridge plugin.",
734
+ inputSchema: z.object({
735
+ updates: z
736
+ .array(z.object({
737
+ variableId: z
738
+ .string()
739
+ .describe("Variable ID (e.g., 'VariableID:123:456')"),
740
+ modeId: z
741
+ .string()
742
+ .describe("Mode ID (e.g., '1:0')"),
743
+ value: z
744
+ .union([z.string(), z.number(), z.boolean()])
745
+ .describe("New value. COLOR: hex like '#FF0000'. FLOAT: number. STRING: text. BOOLEAN: true/false. A string starting with 'VariableID:' (e.g. from figma_get_variables) aliases that variable directly by id."),
746
+ }))
747
+ .min(1)
748
+ .max(100)
749
+ .describe("Array of updates to apply (1-100)"),
750
+ fileKey: fileKeyArg,
751
+ }),
719
752
  }, async ({ updates, fileKey }) => {
720
753
  try {
721
754
  const connector = await getDesktopConnector(fileKey);
@@ -799,35 +832,38 @@ return {
799
832
  }
800
833
  });
801
834
  // Tool: Setup design tokens (collection + modes + variables atomically)
802
- server.tool("figma_setup_design_tokens", "Create a complete design token structure in one operation: collection, modes, and all variables. Ideal for importing CSS custom properties or design tokens into Figma. Values may be literals OR DTCG-style brace references ('{color.blue.600}', or set-qualified '{primitives.color.blue.600}') that resolve to variable ALIASES — first against variables created in this same call, then against existing local variables. Unresolvable references skip that value with a per-item warning (the rest of the batch still applies), so semantic collections referencing primitives no longer need raw figma_execute. Requires Desktop Bridge plugin.", {
803
- collectionName: z
804
- .string()
805
- .describe("Name for the token collection (e.g., 'Brand Tokens')"),
806
- modes: z
807
- .array(z.string())
808
- .min(1)
809
- .max(40)
810
- .describe("Mode names (first becomes default). Example: ['Light', 'Dark']. Your Figma plan's per-collection mode limit applies at RUNTIME (e.g. Professional 10, Organization 20) — exceeding it fails cleanly with the file's real ceiling in planModeLimit and no collection left behind."),
811
- tokens: z
812
- .array(z.object({
813
- name: z
814
- .string()
815
- .describe("Token name (e.g., 'color/primary')"),
816
- resolvedType: z
817
- .enum(["COLOR", "FLOAT", "STRING", "BOOLEAN"])
818
- .describe("Token type"),
819
- description: z
835
+ server.registerTool("figma_setup_design_tokens", {
836
+ description: "Create a complete design token structure in one operation: collection, modes, and all variables. Ideal for importing CSS custom properties or design tokens into Figma. Values may be literals OR DTCG-style brace references ('{color.blue.600}', or set-qualified '{primitives.color.blue.600}') that resolve to variable ALIASES — first against variables created in this same call, then against existing local variables. Unresolvable references skip that value with a per-item warning (the rest of the batch still applies), so semantic collections referencing primitives no longer need raw figma_execute. Requires Desktop Bridge plugin.",
837
+ inputSchema: z.object({
838
+ collectionName: z
820
839
  .string()
821
- .optional()
822
- .describe("Optional description"),
823
- values: z
824
- .record(z.string(), z.union([z.string(), z.number(), z.boolean()]))
825
- .describe("Values keyed by mode NAME (not ID). Example: { 'Light': '#FFFFFF', 'Dark': '#000000' }. A string value wrapped in braces is an ALIAS reference resolved to another variable: '{color.blue.600}' matches variable name 'color/blue/600' — first among variables created in THIS call, then existing local variables (exact match, then case-insensitive). Set-qualified references ('{primitives.color.blue.600}') strip the leading collection name. Unresolvable references skip that value and surface in the response's warnings[]. A string starting with 'VariableID:' (e.g. from figma_get_variables) aliases that variable directly by id."),
826
- }))
827
- .min(1)
828
- .max(100)
829
- .describe("Token definitions (1-100)"),
830
- fileKey: fileKeyArg,
840
+ .describe("Name for the token collection (e.g., 'Brand Tokens')"),
841
+ modes: z
842
+ .array(z.string())
843
+ .min(1)
844
+ .max(40)
845
+ .describe("Mode names (first becomes default). Example: ['Light', 'Dark']. Your Figma plan's per-collection mode limit applies at RUNTIME (e.g. Professional 10, Organization 20) — exceeding it fails cleanly with the file's real ceiling in planModeLimit and no collection left behind."),
846
+ tokens: z
847
+ .array(z.object({
848
+ name: z
849
+ .string()
850
+ .describe("Token name (e.g., 'color/primary')"),
851
+ resolvedType: z
852
+ .enum(["COLOR", "FLOAT", "STRING", "BOOLEAN"])
853
+ .describe("Token type"),
854
+ description: z
855
+ .string()
856
+ .optional()
857
+ .describe("Optional description"),
858
+ values: z
859
+ .record(z.string(), z.union([z.string(), z.number(), z.boolean()]))
860
+ .describe("Values keyed by mode NAME (not ID). Example: { 'Light': '#FFFFFF', 'Dark': '#000000' }. A string value wrapped in braces is an ALIAS reference resolved to another variable: '{color.blue.600}' matches variable name 'color/blue/600' — first among variables created in THIS call, then existing local variables (exact match, then case-insensitive). Set-qualified references ('{primitives.color.blue.600}') strip the leading collection name. Unresolvable references skip that value and surface in the response's warnings[]. A string starting with 'VariableID:' (e.g. from figma_get_variables) aliases that variable directly by id."),
861
+ }))
862
+ .min(1)
863
+ .max(100)
864
+ .describe("Token definitions (1-100)"),
865
+ fileKey: fileKeyArg,
866
+ }),
831
867
  }, async ({ collectionName, modes, tokens, fileKey }) => {
832
868
  try {
833
869
  const connector = await getDesktopConnector(fileKey);
@@ -1083,7 +1119,8 @@ return {
1083
1119
  // COMPONENT INSTANTIATION & PROPERTY TOOLS
1084
1120
  // ============================================================================
1085
1121
  // Tool: Instantiate Component
1086
- server.tool("figma_instantiate_component", `Create an instance of a component from the design system.
1122
+ server.registerTool("figma_instantiate_component", {
1123
+ description: `Create an instance of a component from the design system.
1087
1124
 
1088
1125
  **CRITICAL: Always pass BOTH componentKey AND nodeId together!**
1089
1126
  Search results return both identifiers. Pass both so the tool can automatically fall back to nodeId if the component isn't published to a library. Most local/unpublished components require nodeId.
@@ -1092,35 +1129,37 @@ Search results return both identifiers. Pass both so the tool can automatically
1092
1129
  NodeIds are session-specific and may be stale from previous conversations. ALWAYS search for components at the start of each design session to get current, valid identifiers.
1093
1130
 
1094
1131
  **VISUAL VALIDATION WORKFLOW:**
1095
- After instantiating components, use figma_take_screenshot to verify the result looks correct. Check placement, sizing, and visual balance.`, {
1096
- componentKey: z
1097
- .string()
1098
- .optional()
1099
- .describe("The component key from search results. Pass this WITH nodeId for automatic fallback."),
1100
- nodeId: z
1101
- .string()
1102
- .optional()
1103
- .describe("The node ID from search results. ALWAYS pass this alongside componentKey - most local components need it."),
1104
- variant: z
1105
- .record(z.string())
1106
- .optional()
1107
- .describe("Variant properties to set (e.g., { Type: 'Simple', State: 'Active' })"),
1108
- overrides: z
1109
- .record(z.string(), z.union([z.string(), z.number(), z.boolean()]))
1110
- .optional()
1111
- .describe("Property overrides (e.g., { 'Button Label': 'Click Me' })"),
1112
- position: z
1113
- .object({
1114
- x: z.number(),
1115
- y: z.number(),
1116
- })
1117
- .optional()
1118
- .describe("Position on canvas (default: 0, 0)"),
1119
- parentId: z
1120
- .string()
1121
- .optional()
1122
- .describe("Parent node ID to append the instance to"),
1123
- fileKey: fileKeyArg,
1132
+ After instantiating components, use figma_take_screenshot to verify the result looks correct. Check placement, sizing, and visual balance.`,
1133
+ inputSchema: z.object({
1134
+ componentKey: z
1135
+ .string()
1136
+ .optional()
1137
+ .describe("The component key from search results. Pass this WITH nodeId for automatic fallback."),
1138
+ nodeId: z
1139
+ .string()
1140
+ .optional()
1141
+ .describe("The node ID from search results. ALWAYS pass this alongside componentKey - most local components need it."),
1142
+ variant: z
1143
+ .record(z.string(), z.string())
1144
+ .optional()
1145
+ .describe("Variant properties to set (e.g., { Type: 'Simple', State: 'Active' })"),
1146
+ overrides: z
1147
+ .record(z.string(), z.union([z.string(), z.number(), z.boolean()]))
1148
+ .optional()
1149
+ .describe("Property overrides (e.g., { 'Button Label': 'Click Me' })"),
1150
+ position: z
1151
+ .object({
1152
+ x: z.number(),
1153
+ y: z.number(),
1154
+ })
1155
+ .optional()
1156
+ .describe("Position on canvas (default: 0, 0)"),
1157
+ parentId: z
1158
+ .string()
1159
+ .optional()
1160
+ .describe("Parent node ID to append the instance to"),
1161
+ fileKey: fileKeyArg,
1162
+ }),
1124
1163
  }, async ({ componentKey, nodeId, variant, overrides, position, parentId, fileKey, }) => {
1125
1164
  try {
1126
1165
  if (!componentKey && !nodeId) {
@@ -1177,16 +1216,19 @@ After instantiating components, use figma_take_screenshot to verify the result l
1177
1216
  // Component Property Management Tools
1178
1217
  // ============================================================================
1179
1218
  // Tool: Set Node Description
1180
- server.tool("figma_set_description", "Set the description text on a component, component set, or style. Descriptions appear in Dev Mode and help document design intent. Supports plain text and markdown formatting.", {
1181
- nodeId: z
1182
- .string()
1183
- .describe("The node ID of the component or style to update (e.g., '123:456')"),
1184
- description: z.string().describe("The plain text description to set"),
1185
- descriptionMarkdown: z
1186
- .string()
1187
- .optional()
1188
- .describe("Optional rich text description using markdown formatting"),
1189
- fileKey: fileKeyArg,
1219
+ server.registerTool("figma_set_description", {
1220
+ description: "Set the description text on a component, component set, or style. Descriptions appear in Dev Mode and help document design intent. Supports plain text and markdown formatting.",
1221
+ inputSchema: z.object({
1222
+ nodeId: z
1223
+ .string()
1224
+ .describe("The node ID of the component or style to update (e.g., '123:456')"),
1225
+ description: z.string().describe("The plain text description to set"),
1226
+ descriptionMarkdown: z
1227
+ .string()
1228
+ .optional()
1229
+ .describe("Optional rich text description using markdown formatting"),
1230
+ fileKey: fileKeyArg,
1231
+ }),
1190
1232
  }, async ({ nodeId, description, descriptionMarkdown, fileKey }) => {
1191
1233
  try {
1192
1234
  const connector = await getDesktopConnector(fileKey);
@@ -1224,30 +1266,33 @@ After instantiating components, use figma_take_screenshot to verify the result l
1224
1266
  }
1225
1267
  });
1226
1268
  // Tool: Add Component Property
1227
- server.tool("figma_add_component_property", "Add a new component property to a component or component set. Properties enable dynamic content and behavior in component instances. Supported types: BOOLEAN (toggle), TEXT (string), INSTANCE_SWAP (component swap), VARIANT (variant selection), SLOT (freeform slot — prefer figma_create_slot for new slots).", {
1228
- nodeId: z.string().describe("The component or component set node ID"),
1229
- propertyName: z
1230
- .string()
1231
- .describe("Name for the new property (e.g., 'Show Icon', 'Button Label', 'Content')"),
1232
- type: z
1233
- .enum(["BOOLEAN", "TEXT", "INSTANCE_SWAP", "VARIANT", "SLOT"])
1234
- .describe("Property type: BOOLEAN for toggles, TEXT for strings, INSTANCE_SWAP for component swaps, VARIANT for variant selection, SLOT for freeform slot areas"),
1235
- defaultValue: z
1236
- .union([z.string(), z.number(), z.boolean()])
1237
- .optional()
1238
- .describe("Default value. Required for TEXT (string), INSTANCE_SWAP (component id), and VARIANT (a non-empty variant option name — Figma rejects empty). Optional for BOOLEAN (defaults false). Omit for SLOT."),
1239
- description: z
1240
- .string()
1241
- .optional()
1242
- .describe("Property description (SLOT properties only)"),
1243
- preferredValues: z
1244
- .array(z.object({
1245
- type: z.enum(["COMPONENT", "COMPONENT_SET"]),
1246
- key: z.string(),
1247
- }))
1248
- .optional()
1249
- .describe("Preferred components (INSTANCE_SWAP and SLOT only)"),
1250
- fileKey: fileKeyArg,
1269
+ server.registerTool("figma_add_component_property", {
1270
+ description: "Add a new component property to a component or component set. Properties enable dynamic content and behavior in component instances. Supported types: BOOLEAN (toggle), TEXT (string), INSTANCE_SWAP (component swap), VARIANT (variant selection), SLOT (freeform slot — prefer figma_create_slot for new slots).",
1271
+ inputSchema: z.object({
1272
+ nodeId: z.string().describe("The component or component set node ID"),
1273
+ propertyName: z
1274
+ .string()
1275
+ .describe("Name for the new property (e.g., 'Show Icon', 'Button Label', 'Content')"),
1276
+ type: z
1277
+ .enum(["BOOLEAN", "TEXT", "INSTANCE_SWAP", "VARIANT", "SLOT"])
1278
+ .describe("Property type: BOOLEAN for toggles, TEXT for strings, INSTANCE_SWAP for component swaps, VARIANT for variant selection, SLOT for freeform slot areas"),
1279
+ defaultValue: z
1280
+ .union([z.string(), z.number(), z.boolean()])
1281
+ .optional()
1282
+ .describe("Default value. Required for TEXT (string), INSTANCE_SWAP (component id), and VARIANT (a non-empty variant option name — Figma rejects empty). Optional for BOOLEAN (defaults false). Omit for SLOT."),
1283
+ description: z
1284
+ .string()
1285
+ .optional()
1286
+ .describe("Property description (SLOT properties only)"),
1287
+ preferredValues: z
1288
+ .array(z.object({
1289
+ type: z.enum(["COMPONENT", "COMPONENT_SET"]),
1290
+ key: z.string(),
1291
+ }))
1292
+ .optional()
1293
+ .describe("Preferred components (INSTANCE_SWAP and SLOT only)"),
1294
+ fileKey: fileKeyArg,
1295
+ }),
1251
1296
  }, async ({ nodeId, propertyName, type, defaultValue, description, preferredValues, fileKey }) => {
1252
1297
  try {
1253
1298
  const connector = await getDesktopConnector(fileKey);
@@ -1305,30 +1350,33 @@ After instantiating components, use figma_take_screenshot to verify the result l
1305
1350
  }
1306
1351
  });
1307
1352
  // Tool: Edit Component Property
1308
- server.tool("figma_edit_component_property", "Edit an existing component property. Can change the name, default value, or preferred values (for INSTANCE_SWAP). Use the full property name including the unique suffix.", {
1309
- nodeId: z.string().describe("The component or component set node ID"),
1310
- propertyName: z
1311
- .string()
1312
- .describe("The full property name with suffix (e.g., 'Show Icon#123:456')"),
1313
- newValue: z
1314
- .object({
1315
- name: z.string().optional().describe("New name for the property"),
1316
- defaultValue: z
1317
- .union([z.string(), z.number(), z.boolean()])
1318
- .optional()
1319
- .describe("New default value"),
1320
- preferredValues: z
1321
- .array(z.object({
1322
- type: z
1323
- .enum(["COMPONENT", "COMPONENT_SET"])
1324
- .describe("Type of preferred value"),
1325
- key: z.string().describe("Component or component set key"),
1326
- }))
1327
- .optional()
1328
- .describe("Preferred values (INSTANCE_SWAP only)"),
1329
- })
1330
- .describe("Object with the values to update"),
1331
- fileKey: fileKeyArg,
1353
+ server.registerTool("figma_edit_component_property", {
1354
+ description: "Edit an existing component property. Can change the name, default value, or preferred values (for INSTANCE_SWAP). Use the full property name including the unique suffix.",
1355
+ inputSchema: z.object({
1356
+ nodeId: z.string().describe("The component or component set node ID"),
1357
+ propertyName: z
1358
+ .string()
1359
+ .describe("The full property name with suffix (e.g., 'Show Icon#123:456')"),
1360
+ newValue: z
1361
+ .object({
1362
+ name: z.string().optional().describe("New name for the property"),
1363
+ defaultValue: z
1364
+ .union([z.string(), z.number(), z.boolean()])
1365
+ .optional()
1366
+ .describe("New default value"),
1367
+ preferredValues: z
1368
+ .array(z.object({
1369
+ type: z
1370
+ .enum(["COMPONENT", "COMPONENT_SET"])
1371
+ .describe("Type of preferred value"),
1372
+ key: z.string().describe("Component or component set key"),
1373
+ }))
1374
+ .optional()
1375
+ .describe("Preferred values (INSTANCE_SWAP only)"),
1376
+ })
1377
+ .describe("Object with the values to update"),
1378
+ fileKey: fileKeyArg,
1379
+ }),
1332
1380
  }, async ({ nodeId, propertyName, newValue, fileKey }) => {
1333
1381
  try {
1334
1382
  const connector = await getDesktopConnector(fileKey);
@@ -1365,12 +1413,15 @@ After instantiating components, use figma_take_screenshot to verify the result l
1365
1413
  }
1366
1414
  });
1367
1415
  // Tool: Delete Component Property
1368
- server.tool("figma_delete_component_property", "Delete a component property. Works with BOOLEAN, TEXT, INSTANCE_SWAP, and SLOT properties (not VARIANT). This is a destructive operation.", {
1369
- nodeId: z.string().describe("The component or component set node ID"),
1370
- propertyName: z
1371
- .string()
1372
- .describe("The full property name with suffix (e.g., 'Show Icon#123:456')"),
1373
- fileKey: fileKeyArg,
1416
+ server.registerTool("figma_delete_component_property", {
1417
+ description: "Delete a component property. Works with BOOLEAN, TEXT, INSTANCE_SWAP, and SLOT properties (not VARIANT). This is a destructive operation.",
1418
+ inputSchema: z.object({
1419
+ nodeId: z.string().describe("The component or component set node ID"),
1420
+ propertyName: z
1421
+ .string()
1422
+ .describe("The full property name with suffix (e.g., 'Show Icon#123:456')"),
1423
+ fileKey: fileKeyArg,
1424
+ }),
1374
1425
  }, async ({ nodeId, propertyName, fileKey }) => {
1375
1426
  try {
1376
1427
  const connector = await getDesktopConnector(fileKey);
@@ -1410,16 +1461,19 @@ After instantiating components, use figma_take_screenshot to verify the result l
1410
1461
  // Node Manipulation Tools
1411
1462
  // ============================================================================
1412
1463
  // Tool: Resize Node
1413
- server.tool("figma_resize_node", "Resize a node to specific dimensions. By default respects child constraints; use withConstraints=false to ignore them.", {
1414
- nodeId: z.string().describe("The node ID to resize"),
1415
- width: z.number().describe("New width in pixels"),
1416
- height: z.number().describe("New height in pixels"),
1417
- withConstraints: z
1418
- .boolean()
1419
- .optional()
1420
- .default(true)
1421
- .describe("Whether to apply child constraints during resize (default: true)"),
1422
- fileKey: fileKeyArg,
1464
+ server.registerTool("figma_resize_node", {
1465
+ description: "Resize a node to specific dimensions. By default respects child constraints; use withConstraints=false to ignore them.",
1466
+ inputSchema: z.object({
1467
+ nodeId: z.string().describe("The node ID to resize"),
1468
+ width: z.number().describe("New width in pixels"),
1469
+ height: z.number().describe("New height in pixels"),
1470
+ withConstraints: z
1471
+ .boolean()
1472
+ .optional()
1473
+ .default(true)
1474
+ .describe("Whether to apply child constraints during resize (default: true)"),
1475
+ fileKey: fileKeyArg,
1476
+ }),
1423
1477
  }, async ({ nodeId, width, height, withConstraints, fileKey }) => {
1424
1478
  try {
1425
1479
  const connector = await getDesktopConnector(fileKey);
@@ -1456,11 +1510,14 @@ After instantiating components, use figma_take_screenshot to verify the result l
1456
1510
  }
1457
1511
  });
1458
1512
  // Tool: Move Node
1459
- server.tool("figma_move_node", "Move a node to a new position within its parent.", {
1460
- nodeId: z.string().describe("The node ID to move"),
1461
- x: z.number().describe("New X position"),
1462
- y: z.number().describe("New Y position"),
1463
- fileKey: fileKeyArg,
1513
+ server.registerTool("figma_move_node", {
1514
+ description: "Move a node to a new position within its parent.",
1515
+ inputSchema: z.object({
1516
+ nodeId: z.string().describe("The node ID to move"),
1517
+ x: z.number().describe("New X position"),
1518
+ y: z.number().describe("New Y position"),
1519
+ fileKey: fileKeyArg,
1520
+ }),
1464
1521
  }, async ({ nodeId, x, y, fileKey }) => {
1465
1522
  try {
1466
1523
  const connector = await getDesktopConnector(fileKey);
@@ -1497,28 +1554,31 @@ After instantiating components, use figma_take_screenshot to verify the result l
1497
1554
  }
1498
1555
  });
1499
1556
  // Tool: Set Node Fills
1500
- server.tool("figma_set_fills", "Set the fill colors on a node. Accepts hex color strings (e.g., '#FF0000'). To bind a fill to a design token / color variable, pass that fill's variableId — the variable drives the color and this works on any Figma plan via the bridge (no raw figma_execute needed).", {
1501
- nodeId: z.string().describe("The node ID to modify"),
1502
- fills: z
1503
- .array(z.object({
1504
- type: z
1505
- .literal("SOLID")
1506
- .describe("Fill type (currently only SOLID supported)"),
1507
- color: z
1508
- .string()
1509
- .optional()
1510
- .describe("Hex color string (e.g., '#FF0000', '#FF000080' for transparency). Optional when variableId is provided."),
1511
- opacity: z
1512
- .number()
1513
- .optional()
1514
- .describe("Opacity 0-1 (default: 1)"),
1515
- variableId: z
1516
- .string()
1517
- .optional()
1518
- .describe("Bind this fill's color to a Figma variable by id (e.g. 'VariableID:1:23' from figma_get_variables). When set, the variable drives the color. Import library variables first via figma_import_library_variable."),
1519
- }))
1520
- .describe("Array of fill objects"),
1521
- fileKey: fileKeyArg,
1557
+ server.registerTool("figma_set_fills", {
1558
+ description: "Set the fill colors on a node. Accepts hex color strings (e.g., '#FF0000'). To bind a fill to a design token / color variable, pass that fill's variableId — the variable drives the color and this works on any Figma plan via the bridge (no raw figma_execute needed).",
1559
+ inputSchema: z.object({
1560
+ nodeId: z.string().describe("The node ID to modify"),
1561
+ fills: z
1562
+ .array(z.object({
1563
+ type: z
1564
+ .literal("SOLID")
1565
+ .describe("Fill type (currently only SOLID supported)"),
1566
+ color: z
1567
+ .string()
1568
+ .optional()
1569
+ .describe("Hex color string (e.g., '#FF0000', '#FF000080' for transparency). Optional when variableId is provided."),
1570
+ opacity: z
1571
+ .number()
1572
+ .optional()
1573
+ .describe("Opacity 0-1 (default: 1)"),
1574
+ variableId: z
1575
+ .string()
1576
+ .optional()
1577
+ .describe("Bind this fill's color to a Figma variable by id (e.g. 'VariableID:1:23' from figma_get_variables). When set, the variable drives the color. Import library variables first via figma_import_library_variable."),
1578
+ }))
1579
+ .describe("Array of fill objects"),
1580
+ fileKey: fileKeyArg,
1581
+ }),
1522
1582
  }, async ({ nodeId, fills, fileKey }) => {
1523
1583
  try {
1524
1584
  const connector = await getDesktopConnector(fileKey);
@@ -1555,13 +1615,16 @@ After instantiating components, use figma_take_screenshot to verify the result l
1555
1615
  }
1556
1616
  });
1557
1617
  // Tool: Set Image Fill on nodes
1558
- server.tool("figma_set_image_fill", "Set an image fill on one or more Figma nodes. The imageData parameter accepts a base64-encoded " +
1559
- "image string (JPEG/PNG). The image is decoded in the browser bridge and passed " +
1560
- "as raw bytes to the Figma plugin. Requires Desktop Bridge plugin.", {
1561
- nodeIds: z.array(z.string()).describe("Array of node IDs to apply the image fill to"),
1562
- imageData: z.string().describe("Base64-encoded image data (JPEG/PNG)"),
1563
- scaleMode: z.enum(["FILL", "FIT", "CROP", "TILE"]).optional().describe("How the image fills the node (default: FILL)"),
1564
- fileKey: fileKeyArg,
1618
+ server.registerTool("figma_set_image_fill", {
1619
+ description: "Set an image fill on one or more Figma nodes. The imageData parameter accepts a base64-encoded " +
1620
+ "image string (JPEG/PNG). The image is decoded in the browser bridge and passed " +
1621
+ "as raw bytes to the Figma plugin. Requires Desktop Bridge plugin.",
1622
+ inputSchema: z.object({
1623
+ nodeIds: z.array(z.string()).describe("Array of node IDs to apply the image fill to"),
1624
+ imageData: z.string().describe("Base64-encoded image data (JPEG/PNG)"),
1625
+ scaleMode: z.enum(["FILL", "FIT", "CROP", "TILE"]).optional().describe("How the image fills the node (default: FILL)"),
1626
+ fileKey: fileKeyArg,
1627
+ }),
1565
1628
  }, async ({ nodeIds, imageData, scaleMode, fileKey }) => {
1566
1629
  try {
1567
1630
  const connector = await getDesktopConnector(fileKey);
@@ -1599,27 +1662,30 @@ After instantiating components, use figma_take_screenshot to verify the result l
1599
1662
  }
1600
1663
  });
1601
1664
  // Tool: Set Node Strokes
1602
- server.tool("figma_set_strokes", "Set the stroke (border) on a node. Accepts hex color strings and optional stroke weight. To bind a stroke to a design token / color variable, pass that stroke's variableId — works on any Figma plan via the bridge.", {
1603
- nodeId: z.string().describe("The node ID to modify"),
1604
- strokes: z
1605
- .array(z.object({
1606
- type: z.literal("SOLID").describe("Stroke type"),
1607
- color: z
1608
- .string()
1609
- .optional()
1610
- .describe("Hex color string. Optional when variableId is provided."),
1611
- opacity: z.number().optional().describe("Opacity 0-1"),
1612
- variableId: z
1613
- .string()
1665
+ server.registerTool("figma_set_strokes", {
1666
+ description: "Set the stroke (border) on a node. Accepts hex color strings and optional stroke weight. To bind a stroke to a design token / color variable, pass that stroke's variableId — works on any Figma plan via the bridge.",
1667
+ inputSchema: z.object({
1668
+ nodeId: z.string().describe("The node ID to modify"),
1669
+ strokes: z
1670
+ .array(z.object({
1671
+ type: z.literal("SOLID").describe("Stroke type"),
1672
+ color: z
1673
+ .string()
1674
+ .optional()
1675
+ .describe("Hex color string. Optional when variableId is provided."),
1676
+ opacity: z.number().optional().describe("Opacity 0-1"),
1677
+ variableId: z
1678
+ .string()
1679
+ .optional()
1680
+ .describe("Bind this stroke's color to a Figma variable by id (e.g. 'VariableID:1:23' from figma_get_variables). When set, the variable drives the color."),
1681
+ }))
1682
+ .describe("Array of stroke objects"),
1683
+ strokeWeight: z
1684
+ .number()
1614
1685
  .optional()
1615
- .describe("Bind this stroke's color to a Figma variable by id (e.g. 'VariableID:1:23' from figma_get_variables). When set, the variable drives the color."),
1616
- }))
1617
- .describe("Array of stroke objects"),
1618
- strokeWeight: z
1619
- .number()
1620
- .optional()
1621
- .describe("Stroke thickness in pixels"),
1622
- fileKey: fileKeyArg,
1686
+ .describe("Stroke thickness in pixels"),
1687
+ fileKey: fileKeyArg,
1688
+ }),
1623
1689
  }, async ({ nodeId, strokes, strokeWeight, fileKey }) => {
1624
1690
  try {
1625
1691
  const connector = await getDesktopConnector(fileKey);
@@ -1656,9 +1722,12 @@ After instantiating components, use figma_take_screenshot to verify the result l
1656
1722
  }
1657
1723
  });
1658
1724
  // Tool: Clone Node
1659
- server.tool("figma_clone_node", "Duplicate a node. The clone is placed at a slight offset from the original.", {
1660
- nodeId: z.string().describe("The node ID to clone"),
1661
- fileKey: fileKeyArg,
1725
+ server.registerTool("figma_clone_node", {
1726
+ description: "Duplicate a node. The clone is placed at a slight offset from the original.",
1727
+ inputSchema: z.object({
1728
+ nodeId: z.string().describe("The node ID to clone"),
1729
+ fileKey: fileKeyArg,
1730
+ }),
1662
1731
  }, async ({ nodeId, fileKey }) => {
1663
1732
  try {
1664
1733
  const connector = await getDesktopConnector(fileKey);
@@ -1695,9 +1764,12 @@ After instantiating components, use figma_take_screenshot to verify the result l
1695
1764
  }
1696
1765
  });
1697
1766
  // Tool: Delete Node
1698
- server.tool("figma_delete_node", "Delete a node from the canvas. WARNING: This is a destructive operation (can be undone with Figma's undo).", {
1699
- nodeId: z.string().describe("The node ID to delete"),
1700
- fileKey: fileKeyArg,
1767
+ server.registerTool("figma_delete_node", {
1768
+ description: "Delete a node from the canvas. WARNING: This is a destructive operation (can be undone with Figma's undo).",
1769
+ inputSchema: z.object({
1770
+ nodeId: z.string().describe("The node ID to delete"),
1771
+ fileKey: fileKeyArg,
1772
+ }),
1701
1773
  }, async ({ nodeId, fileKey }) => {
1702
1774
  try {
1703
1775
  const connector = await getDesktopConnector(fileKey);
@@ -1734,10 +1806,13 @@ After instantiating components, use figma_take_screenshot to verify the result l
1734
1806
  }
1735
1807
  });
1736
1808
  // Tool: Rename Node
1737
- server.tool("figma_rename_node", "Rename a node in the layer panel.", {
1738
- nodeId: z.string().describe("The node ID to rename"),
1739
- newName: z.string().describe("The new name for the node"),
1740
- fileKey: fileKeyArg,
1809
+ server.registerTool("figma_rename_node", {
1810
+ description: "Rename a node in the layer panel.",
1811
+ inputSchema: z.object({
1812
+ nodeId: z.string().describe("The node ID to rename"),
1813
+ newName: z.string().describe("The new name for the node"),
1814
+ fileKey: fileKeyArg,
1815
+ }),
1741
1816
  }, async ({ nodeId, newName, fileKey }) => {
1742
1817
  try {
1743
1818
  const connector = await getDesktopConnector(fileKey);
@@ -1774,19 +1849,22 @@ After instantiating components, use figma_take_screenshot to verify the result l
1774
1849
  }
1775
1850
  });
1776
1851
  // Tool: Set Text Content
1777
- server.tool("figma_set_text", "Set the text content of a text node. Optionally adjust font size and the font family/style. Font style names are space-sensitive ('Semi Bold', not 'SemiBold'), but this tool auto-corrects common no-space variants and falls back gracefully — so you don't need raw figma_execute to change typography.", {
1778
- nodeId: z.string().describe("The text node ID"),
1779
- text: z.string().describe("The new text content"),
1780
- fontSize: z.number().optional().describe("Optional font size to set"),
1781
- fontFamily: z
1782
- .string()
1783
- .optional()
1784
- .describe("Optional font family to apply (e.g., 'Inter')"),
1785
- fontStyle: z
1786
- .string()
1787
- .optional()
1788
- .describe("Optional font style/weight to apply (e.g., 'Bold', 'Semi Bold'). No-space variants like 'SemiBold' are auto-corrected."),
1789
- fileKey: fileKeyArg,
1852
+ server.registerTool("figma_set_text", {
1853
+ description: "Set the text content of a text node. Optionally adjust font size and the font family/style. Font style names are space-sensitive ('Semi Bold', not 'SemiBold'), but this tool auto-corrects common no-space variants and falls back gracefully — so you don't need raw figma_execute to change typography.",
1854
+ inputSchema: z.object({
1855
+ nodeId: z.string().describe("The text node ID"),
1856
+ text: z.string().describe("The new text content"),
1857
+ fontSize: z.number().optional().describe("Optional font size to set"),
1858
+ fontFamily: z
1859
+ .string()
1860
+ .optional()
1861
+ .describe("Optional font family to apply (e.g., 'Inter')"),
1862
+ fontStyle: z
1863
+ .string()
1864
+ .optional()
1865
+ .describe("Optional font style/weight to apply (e.g., 'Bold', 'Semi Bold'). No-space variants like 'SemiBold' are auto-corrected."),
1866
+ fileKey: fileKeyArg,
1867
+ }),
1790
1868
  }, async ({ nodeId, text, fontSize, fontFamily, fontStyle, fileKey }) => {
1791
1869
  try {
1792
1870
  const connector = await getDesktopConnector(fileKey);
@@ -1826,33 +1904,36 @@ After instantiating components, use figma_take_screenshot to verify the result l
1826
1904
  }
1827
1905
  });
1828
1906
  // Tool: Create Child Node
1829
- server.tool("figma_create_child", "Create a new child node inside a parent container. Always place inside an existing Section or Frame — never on a bare page. If no suitable parent exists, create a Section first. Clean up any empty or orphaned nodes if the operation fails.", {
1830
- parentId: z.string().describe("The parent node ID"),
1831
- nodeType: z
1832
- .enum(["RECTANGLE", "ELLIPSE", "FRAME", "TEXT", "LINE", "POLYGON", "STAR", "VECTOR"])
1833
- .describe("Type of node to create"),
1834
- properties: z
1835
- .object({
1836
- name: z.string().optional().describe("Name for the new node"),
1837
- x: z.number().optional().describe("X position within parent"),
1838
- y: z.number().optional().describe("Y position within parent"),
1839
- width: z.number().optional().describe("Width (default: 100)"),
1840
- height: z.number().optional().describe("Height (default: 100)"),
1841
- fills: z
1842
- .array(z.object({
1843
- type: z.literal("SOLID"),
1844
- color: z.string(),
1845
- }))
1846
- .optional()
1847
- .describe("Fill colors (hex strings)"),
1848
- text: z
1849
- .string()
1907
+ server.registerTool("figma_create_child", {
1908
+ description: "Create a new child node inside a parent container. Always place inside an existing Section or Frame — never on a bare page. If no suitable parent exists, create a Section first. Clean up any empty or orphaned nodes if the operation fails.",
1909
+ inputSchema: z.object({
1910
+ parentId: z.string().describe("The parent node ID"),
1911
+ nodeType: z
1912
+ .enum(["RECTANGLE", "ELLIPSE", "FRAME", "TEXT", "LINE", "POLYGON", "STAR", "VECTOR"])
1913
+ .describe("Type of node to create"),
1914
+ properties: z
1915
+ .object({
1916
+ name: z.string().optional().describe("Name for the new node"),
1917
+ x: z.number().optional().describe("X position within parent"),
1918
+ y: z.number().optional().describe("Y position within parent"),
1919
+ width: z.number().optional().describe("Width (default: 100)"),
1920
+ height: z.number().optional().describe("Height (default: 100)"),
1921
+ fills: z
1922
+ .array(z.object({
1923
+ type: z.literal("SOLID"),
1924
+ color: z.string(),
1925
+ }))
1926
+ .optional()
1927
+ .describe("Fill colors (hex strings)"),
1928
+ text: z
1929
+ .string()
1930
+ .optional()
1931
+ .describe("Text content (for TEXT nodes only)"),
1932
+ })
1850
1933
  .optional()
1851
- .describe("Text content (for TEXT nodes only)"),
1852
- })
1853
- .optional()
1854
- .describe("Properties for the new node"),
1855
- fileKey: fileKeyArg,
1934
+ .describe("Properties for the new node"),
1935
+ fileKey: fileKeyArg,
1936
+ }),
1856
1937
  }, async ({ parentId, nodeType, properties, fileKey }) => {
1857
1938
  try {
1858
1939
  const connector = await getDesktopConnector(fileKey);
@@ -2341,37 +2422,40 @@ return {
2341
2422
  // Tool: Arrange Component Set (Professional Layout with Native Visualization)
2342
2423
  // Rearranges variants IN PLACE (sets x/y on existing children) so the component
2343
2424
  // set's identity is preserved and placed instances are unaffected
2344
- server.tool("figma_arrange_component_set", `Organize a component set with Figma's native purple dashed visualization. Use after creating variants, adding states (hover/disabled/pressed), or when component sets need cleanup.
2345
-
2346
- Non-destructive: rearranges the existing variants in place (grid positions on the existing set's children), so the component set keeps its node ID and all placed instances remain intact. Arranges variants in a labeled grid (columns = last property like State, rows = other properties like Type+Size) and wraps the set in a white container with title, row/column labels. Safe to run on component sets with placed instances, and safe to re-run.`, {
2347
- componentSetId: z
2348
- .string()
2349
- .optional()
2350
- .describe("Node ID of the component set to arrange. If not provided, will look for a selected component set."),
2351
- componentSetName: z
2352
- .string()
2353
- .optional()
2354
- .describe("Name of the component set to find. Used if componentSetId not provided."),
2355
- options: z
2356
- .object({
2357
- gap: z
2358
- .number()
2359
- .optional()
2360
- .default(24)
2361
- .describe("Gap between grid cells in pixels (default: 24)"),
2362
- cellPadding: z
2363
- .number()
2425
+ server.registerTool("figma_arrange_component_set", {
2426
+ description: `Organize a component set with Figma's native purple dashed visualization. Use after creating variants, adding states (hover/disabled/pressed), or when component sets need cleanup.
2427
+
2428
+ Non-destructive: rearranges the existing variants in place (grid positions on the existing set's children), so the component set keeps its node ID and all placed instances remain intact. Arranges variants in a labeled grid (columns = last property like State, rows = other properties like Type+Size) and wraps the set in a white container with title, row/column labels. Safe to run on component sets with placed instances, and safe to re-run.`,
2429
+ inputSchema: z.object({
2430
+ componentSetId: z
2431
+ .string()
2364
2432
  .optional()
2365
- .default(20)
2366
- .describe("Padding inside each cell around the variant (default: 20)"),
2367
- columnProperty: z
2433
+ .describe("Node ID of the component set to arrange. If not provided, will look for a selected component set."),
2434
+ componentSetName: z
2368
2435
  .string()
2369
2436
  .optional()
2370
- .describe("Property to use for columns (default: auto-detect last property, usually 'State')"),
2371
- })
2372
- .optional()
2373
- .describe("Layout options"),
2374
- fileKey: fileKeyArg,
2437
+ .describe("Name of the component set to find. Used if componentSetId not provided."),
2438
+ options: z
2439
+ .object({
2440
+ gap: z
2441
+ .number()
2442
+ .optional()
2443
+ .default(24)
2444
+ .describe("Gap between grid cells in pixels (default: 24)"),
2445
+ cellPadding: z
2446
+ .number()
2447
+ .optional()
2448
+ .default(20)
2449
+ .describe("Padding inside each cell around the variant (default: 20)"),
2450
+ columnProperty: z
2451
+ .string()
2452
+ .optional()
2453
+ .describe("Property to use for columns (default: auto-detect last property, usually 'State')"),
2454
+ })
2455
+ .optional()
2456
+ .describe("Layout options"),
2457
+ fileKey: fileKeyArg,
2458
+ }),
2375
2459
  }, async ({ componentSetId, componentSetName, options, fileKey }) => {
2376
2460
  try {
2377
2461
  const connector = await getDesktopConnector(fileKey);
@@ -2412,7 +2496,8 @@ Non-destructive: rearranges the existing variants in place (grid positions on th
2412
2496
  });
2413
2497
  // Tool: Create Component Set with variants (structured command — no hand-written
2414
2498
  // figma_execute scripts, no 30s execution-cap juggling for callers)
2415
- server.tool("figma_create_component_set", `Create a component set with variants in one call — replaces hand-written figma.combineAsVariants scripts.
2499
+ server.registerTool("figma_create_component_set", {
2500
+ description: `Create a component set with variants in one call — replaces hand-written figma.combineAsVariants scripts.
2416
2501
 
2417
2502
  Two modes:
2418
2503
  1. **Generate from a base component**: pass baseComponentId + properties (variant axes). The base is cloned for every combination of the axes ({ State: ['default','hover','disabled'], Size: ['sm','lg'] } → 6 variants), each named 'Prop=Value' comma-joined (e.g. 'State=hover, Size=sm'), then combined into a set. The base component itself becomes the FIRST variant (same node ID), so existing instances of the base survive as instances of that variant.
@@ -2422,49 +2507,51 @@ Figma derives the variant property definitions from the names; they live on the
2422
2507
 
2423
2508
  Set autoArrange:true to lay the new set out as a labeled grid inside a white container (same layout as figma_arrange_component_set). Requires Desktop Bridge plugin.
2424
2509
 
2425
- SIZE GUIDANCE: hard cap 100 variants. The timeout auto-scales with variant count (~1.2s/variant, 30s floor / 2min cap), but above ~40 variants the single-pass clone+combine gets slow and heavy base components may still push the limit — prefer splitting large matrices into multiple sets (e.g. one set per Size).`, {
2426
- baseComponentId: z
2427
- .string()
2428
- .optional()
2429
- .describe("Node ID of an existing COMPONENT to use as the base. Cloned per property combination; becomes the set's first variant (keeps its node ID, so placed instances survive). Mutually exclusive with componentIds."),
2430
- properties: z
2431
- .record(z.string(), z.array(z.string()))
2432
- .optional()
2433
- .describe("Variant property axes — required with baseComponentId. Example: { State: ['default','hover','disabled'], Size: ['sm','lg'] } creates 6 variants. Max 100 combinations. Names and values must not contain '=' or ','."),
2434
- componentIds: z
2435
- .array(z.string())
2436
- .optional()
2437
- .describe("Node IDs of existing COMPONENT nodes to combine as variants. Mutually exclusive with baseComponentId. Components already inside a component set are rejected."),
2438
- variantProperties: z
2439
- .array(z.record(z.string()))
2440
- .optional()
2441
- .describe("Only with componentIds: one property map per component, aligned by index — e.g. [{ State: 'default' }, { State: 'hover' }]. Each component is renamed to 'Prop=Value, ...' before combining. Without this, existing names are kept (names lacking '=' become 'Property 1=<name>')."),
2442
- name: z
2443
- .string()
2444
- .optional()
2445
- .describe("Name for the component set (e.g., 'Button'). Defaults to Figma's derived name."),
2446
- parentId: z
2447
- .string()
2448
- .optional()
2449
- .describe("Node ID of the container (frame/section) to create the set in. Defaults to the current page."),
2450
- position: z
2451
- .object({ x: z.number(), y: z.number() })
2452
- .optional()
2453
- .describe("Position of the set within its parent."),
2454
- autoArrange: z
2455
- .boolean()
2456
- .optional()
2457
- .default(false)
2458
- .describe("If true, arrange the new set in a labeled grid (columns = last property, rows = other properties) inside a white container — same in-place layout as figma_arrange_component_set."),
2459
- arrangeOptions: z
2460
- .object({
2461
- gap: z.number().optional().describe("Gap between grid cells in pixels (default: 24)"),
2462
- cellPadding: z.number().optional().describe("Padding inside each cell around the variant (default: 20)"),
2463
- columnProperty: z.string().optional().describe("Property to use for columns (default: last property)"),
2464
- })
2465
- .optional()
2466
- .describe("Grid layout options, used when autoArrange is true."),
2467
- fileKey: fileKeyArg,
2510
+ SIZE GUIDANCE: hard cap 100 variants. The timeout auto-scales with variant count (~1.2s/variant, 30s floor / 2min cap), but above ~40 variants the single-pass clone+combine gets slow and heavy base components may still push the limit — prefer splitting large matrices into multiple sets (e.g. one set per Size).`,
2511
+ inputSchema: z.object({
2512
+ baseComponentId: z
2513
+ .string()
2514
+ .optional()
2515
+ .describe("Node ID of an existing COMPONENT to use as the base. Cloned per property combination; becomes the set's first variant (keeps its node ID, so placed instances survive). Mutually exclusive with componentIds."),
2516
+ properties: z
2517
+ .record(z.string(), z.array(z.string()))
2518
+ .optional()
2519
+ .describe("Variant property axes — required with baseComponentId. Example: { State: ['default','hover','disabled'], Size: ['sm','lg'] } creates 6 variants. Max 100 combinations. Names and values must not contain '=' or ','."),
2520
+ componentIds: z
2521
+ .array(z.string())
2522
+ .optional()
2523
+ .describe("Node IDs of existing COMPONENT nodes to combine as variants. Mutually exclusive with baseComponentId. Components already inside a component set are rejected."),
2524
+ variantProperties: z
2525
+ .array(z.record(z.string(), z.string()))
2526
+ .optional()
2527
+ .describe("Only with componentIds: one property map per component, aligned by index — e.g. [{ State: 'default' }, { State: 'hover' }]. Each component is renamed to 'Prop=Value, ...' before combining. Without this, existing names are kept (names lacking '=' become 'Property 1=<name>')."),
2528
+ name: z
2529
+ .string()
2530
+ .optional()
2531
+ .describe("Name for the component set (e.g., 'Button'). Defaults to Figma's derived name."),
2532
+ parentId: z
2533
+ .string()
2534
+ .optional()
2535
+ .describe("Node ID of the container (frame/section) to create the set in. Defaults to the current page."),
2536
+ position: z
2537
+ .object({ x: z.number(), y: z.number() })
2538
+ .optional()
2539
+ .describe("Position of the set within its parent."),
2540
+ autoArrange: z
2541
+ .boolean()
2542
+ .optional()
2543
+ .default(false)
2544
+ .describe("If true, arrange the new set in a labeled grid (columns = last property, rows = other properties) inside a white container — same in-place layout as figma_arrange_component_set."),
2545
+ arrangeOptions: z
2546
+ .object({
2547
+ gap: z.number().optional().describe("Gap between grid cells in pixels (default: 24)"),
2548
+ cellPadding: z.number().optional().describe("Padding inside each cell around the variant (default: 20)"),
2549
+ columnProperty: z.string().optional().describe("Property to use for columns (default: last property)"),
2550
+ })
2551
+ .optional()
2552
+ .describe("Grid layout options, used when autoArrange is true."),
2553
+ fileKey: fileKeyArg,
2554
+ }),
2468
2555
  }, async ({ baseComponentId, properties, componentIds, variantProperties, name, parentId, position, autoArrange, arrangeOptions, fileKey, }) => {
2469
2556
  try {
2470
2557
  if (!baseComponentId && (!componentIds || componentIds.length === 0)) {
@@ -2570,23 +2657,26 @@ SIZE GUIDANCE: hard cap 100 variants. The timeout auto-scales with variant count
2570
2657
  }
2571
2658
  });
2572
2659
  // Tool: Lint Design for accessibility and quality issues
2573
- server.tool("figma_lint_design", "Run comprehensive accessibility (WCAG 2.2) and design quality checks on the current page or a specific node tree. " +
2574
- "WCAG conformance checks (10 rules): color contrast (AA), non-text contrast (1.4.11), color-only differentiation (1.4.1), " +
2575
- "focus indicators (2.4.7), touch targets (2.5.8), image alt text (1.1.1), heading hierarchy (1.3.1), " +
2576
- "reflow/responsive (1.4.10), reading order (1.3.2), and disabled context (4.1.2). " +
2577
- "Best-practice readability hints (opt-in via rules: ['best-practice'] or ['all']): text sizing, line height, letter spacing, paragraph spacing. " +
2578
- "Note: line/paragraph spacing below 1.5x/2x is NOT a WCAG 1.4.12 failure — 1.4.12 requires supporting user spacing overrides without breaking (a code concern, see figma_scan_code_accessibility), not specific design values — so these are non-normative hints scoped to multi-line text only. " +
2579
- "Design system checks: hardcoded colors, missing text styles, default names, detached components. " +
2580
- "Layout checks: missing auto-layout, empty containers. " +
2581
- "Default audit runs WCAG + design-system + layout (best-practice hints excluded). " +
2582
- "Returns categorized findings with severity levels (critical/warning/info) and WCAG conformance level (a/aa/aaa/best-practice) so teams can filter by target level. " +
2583
- "Use natural language like 'check my design for accessibility issues' or 'lint this page'. " +
2584
- "Requires Desktop Bridge plugin.", {
2585
- nodeId: z.string().optional().describe("Node ID to lint (defaults to current page)"),
2586
- rules: z.array(z.string()).optional().describe("Rule filter. Default (omitted) = ['wcag','design-system','layout'] — real WCAG conformance plus quality checks, with best-practice hints excluded. Groups: ['wcag'] (10 conformance rules), ['best-practice'] (text-size, line-height, letter-spacing, paragraph-spacing), ['all'] (everything incl. best-practice), ['design-system'], ['layout']. Or specific rule IDs like ['wcag-contrast', 'wcag-focus-indicator', 'wcag-disabled-no-context']."),
2587
- maxDepth: z.number().optional().describe("Maximum tree depth to traverse (default: 10)"),
2588
- maxFindings: z.number().optional().describe("Maximum findings before stopping (default: 100)"),
2589
- fileKey: fileKeyArg,
2660
+ server.registerTool("figma_lint_design", {
2661
+ description: "Run comprehensive accessibility (WCAG 2.2) and design quality checks on the current page or a specific node tree. " +
2662
+ "WCAG conformance checks (10 rules): color contrast (AA), non-text contrast (1.4.11), color-only differentiation (1.4.1), " +
2663
+ "focus indicators (2.4.7), touch targets (2.5.8), image alt text (1.1.1), heading hierarchy (1.3.1), " +
2664
+ "reflow/responsive (1.4.10), reading order (1.3.2), and disabled context (4.1.2). " +
2665
+ "Best-practice readability hints (opt-in via rules: ['best-practice'] or ['all']): text sizing, line height, letter spacing, paragraph spacing. " +
2666
+ "Note: line/paragraph spacing below 1.5x/2x is NOT a WCAG 1.4.12 failure — 1.4.12 requires supporting user spacing overrides without breaking (a code concern, see figma_scan_code_accessibility), not specific design values — so these are non-normative hints scoped to multi-line text only. " +
2667
+ "Design system checks: hardcoded colors, missing text styles, default names, detached components. " +
2668
+ "Layout checks: missing auto-layout, empty containers. " +
2669
+ "Default audit runs WCAG + design-system + layout (best-practice hints excluded). " +
2670
+ "Returns categorized findings with severity levels (critical/warning/info) and WCAG conformance level (a/aa/aaa/best-practice) so teams can filter by target level. " +
2671
+ "Use natural language like 'check my design for accessibility issues' or 'lint this page'. " +
2672
+ "Requires Desktop Bridge plugin.",
2673
+ inputSchema: z.object({
2674
+ nodeId: z.string().optional().describe("Node ID to lint (defaults to current page)"),
2675
+ rules: z.array(z.string()).optional().describe("Rule filter. Default (omitted) = ['wcag','design-system','layout'] — real WCAG conformance plus quality checks, with best-practice hints excluded. Groups: ['wcag'] (10 conformance rules), ['best-practice'] (text-size, line-height, letter-spacing, paragraph-spacing), ['all'] (everything incl. best-practice), ['design-system'], ['layout']. Or specific rule IDs like ['wcag-contrast', 'wcag-focus-indicator', 'wcag-disabled-no-context']."),
2676
+ maxDepth: z.number().optional().describe("Maximum tree depth to traverse (default: 10)"),
2677
+ maxFindings: z.number().optional().describe("Maximum findings before stopping (default: 100)"),
2678
+ fileKey: fileKeyArg,
2679
+ }),
2590
2680
  }, async ({ nodeId, rules, maxDepth, maxFindings, fileKey }) => {
2591
2681
  try {
2592
2682
  const connector = await getDesktopConnector(fileKey);
@@ -2620,15 +2710,18 @@ SIZE GUIDANCE: hard cap 100 variants. The timeout auto-scales with variant count
2620
2710
  }
2621
2711
  });
2622
2712
  // Tool: Audit Component Accessibility
2623
- server.tool("figma_audit_component_accessibility", "Deep accessibility audit for a specific component or component set. Produces a scorecard covering: " +
2624
- "state coverage (default/hover/focus/disabled/error/active/loading), focus indicator quality and contrast, " +
2625
- "non-color differentiation (WCAG 1.4.1), target size consistency (WCAG 2.5.8), annotation completeness, " +
2626
- "and color-blind simulation (protanopia/deuteranopia/tritanopia). Returns per-category scores (0-100) " +
2627
- "and prioritized recommendations. Use after designing a component to validate accessibility before handoff. " +
2628
- "Requires Desktop Bridge plugin.", {
2629
- nodeId: z.string().optional().describe("Node ID of a COMPONENT_SET, COMPONENT, or INSTANCE to audit. Falls back to current selection if omitted."),
2630
- targetSize: z.number().optional().describe("Minimum touch target size in px (default: 24 per WCAG 2.5.8). Use 44 for iOS or 48 for Android guidelines."),
2631
- fileKey: fileKeyArg,
2713
+ server.registerTool("figma_audit_component_accessibility", {
2714
+ description: "Deep accessibility audit for a specific component or component set. Produces a scorecard covering: " +
2715
+ "state coverage (default/hover/focus/disabled/error/active/loading), focus indicator quality and contrast, " +
2716
+ "non-color differentiation (WCAG 1.4.1), target size consistency (WCAG 2.5.8), annotation completeness, " +
2717
+ "and color-blind simulation (protanopia/deuteranopia/tritanopia). Returns per-category scores (0-100) " +
2718
+ "and prioritized recommendations. Use after designing a component to validate accessibility before handoff. " +
2719
+ "Requires Desktop Bridge plugin.",
2720
+ inputSchema: z.object({
2721
+ nodeId: z.string().optional().describe("Node ID of a COMPONENT_SET, COMPONENT, or INSTANCE to audit. Falls back to current selection if omitted."),
2722
+ targetSize: z.number().optional().describe("Minimum touch target size in px (default: 24 per WCAG 2.5.8). Use 44 for iOS or 48 for Android guidelines."),
2723
+ fileKey: fileKeyArg,
2724
+ }),
2632
2725
  }, async ({ nodeId, targetSize, fileKey }) => {
2633
2726
  try {
2634
2727
  const connector = await getDesktopConnector(fileKey);