@muloka/figma-console-mcp 0.5.4 → 0.5.6
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 +5 -4
- package/dist/apps/design-system-dashboard/mcp-app.html +26 -26
- package/dist/apps/token-browser/mcp-app.html +34 -34
- package/dist/core/http-request-guard.d.ts.map +1 -1
- package/dist/core/http-request-guard.js +12 -14
- package/dist/core/http-request-guard.js.map +1 -1
- package/dist/core/port-discovery.d.ts.map +1 -1
- package/dist/core/port-discovery.js +151 -52
- package/dist/core/port-discovery.js.map +1 -1
- package/dist/core/websocket-server.d.ts.map +1 -1
- package/dist/core/websocket-server.js +9 -1
- package/dist/core/websocket-server.js.map +1 -1
- package/dist/core/write-tools.d.ts +5 -1
- package/dist/core/write-tools.d.ts.map +1 -1
- package/dist/core/write-tools.js +113 -83
- package/dist/core/write-tools.js.map +1 -1
- package/dist/local.d.ts.map +1 -1
- package/dist/local.js +9 -2
- package/dist/local.js.map +1 -1
- package/figma-desktop-bridge/code.js +10 -2
- package/figma-desktop-bridge/ui.html +82 -8
- package/package.json +1 -1
- package/dist/cloudflare/apps/design-system-dashboard/scoring/accessibility.js +0 -277
- package/dist/cloudflare/apps/design-system-dashboard/scoring/component-metadata.js +0 -357
- package/dist/cloudflare/apps/design-system-dashboard/scoring/consistency.js +0 -341
- package/dist/cloudflare/apps/design-system-dashboard/scoring/coverage.js +0 -230
- package/dist/cloudflare/apps/design-system-dashboard/scoring/engine.js +0 -92
- package/dist/cloudflare/apps/design-system-dashboard/scoring/naming-semantics.js +0 -308
- package/dist/cloudflare/apps/design-system-dashboard/scoring/token-architecture.js +0 -349
- package/dist/cloudflare/apps/design-system-dashboard/scoring/types.js +0 -40
- package/dist/cloudflare/apps/design-system-dashboard/server.js +0 -159
- package/dist/cloudflare/apps/token-browser/server.js +0 -136
- package/dist/cloudflare/browser-manager.js +0 -157
- package/dist/cloudflare/core/accessibility-tools.js +0 -361
- package/dist/cloudflare/core/annotation-tools.js +0 -230
- package/dist/cloudflare/core/cloud-websocket-connector.js +0 -419
- package/dist/cloudflare/core/cloud-websocket-relay.js +0 -198
- package/dist/cloudflare/core/comment-tools.js +0 -292
- package/dist/cloudflare/core/config.js +0 -153
- package/dist/cloudflare/core/console-monitor.js +0 -427
- package/dist/cloudflare/core/deep-component-tools.js +0 -128
- package/dist/cloudflare/core/design-code-tools.js +0 -2793
- package/dist/cloudflare/core/design-system-manifest.js +0 -265
- package/dist/cloudflare/core/design-system-tools.js +0 -882
- package/dist/cloudflare/core/diagnose-tool.js +0 -100
- package/dist/cloudflare/core/diff/changelog-formatter.js +0 -275
- package/dist/cloudflare/core/diff/diff-engine.js +0 -334
- package/dist/cloudflare/core/diff/property-compare.js +0 -36
- package/dist/cloudflare/core/diff/version-cache.js +0 -74
- package/dist/cloudflare/core/enrichment/enrichment-service.js +0 -374
- package/dist/cloudflare/core/enrichment/index.js +0 -7
- package/dist/cloudflare/core/enrichment/relationship-mapper.js +0 -351
- package/dist/cloudflare/core/enrichment/style-resolver.js +0 -346
- package/dist/cloudflare/core/figjam-tools.js +0 -547
- package/dist/cloudflare/core/figma-api.js +0 -509
- package/dist/cloudflare/core/figma-connector.js +0 -7
- package/dist/cloudflare/core/figma-reconstruction-spec.js +0 -402
- package/dist/cloudflare/core/figma-style-extractor.js +0 -311
- package/dist/cloudflare/core/figma-tools.js +0 -3353
- package/dist/cloudflare/core/identity.js +0 -96
- package/dist/cloudflare/core/library-tools.js +0 -580
- package/dist/cloudflare/core/logger.js +0 -53
- package/dist/cloudflare/core/port-discovery.js +0 -935
- package/dist/cloudflare/core/resolve-package-root.js +0 -11
- package/dist/cloudflare/core/slides-tools.js +0 -714
- package/dist/cloudflare/core/slot-tools.js +0 -334
- package/dist/cloudflare/core/snippet-injector.js +0 -96
- package/dist/cloudflare/core/tokens/alias-resolver.js +0 -205
- package/dist/cloudflare/core/tokens/config.js +0 -294
- package/dist/cloudflare/core/tokens/dialect.js +0 -232
- package/dist/cloudflare/core/tokens/figma-converter.js +0 -323
- package/dist/cloudflare/core/tokens/formatters/css-vars.js +0 -338
- package/dist/cloudflare/core/tokens/formatters/dtcg.js +0 -376
- package/dist/cloudflare/core/tokens/formatters/index.js +0 -45
- package/dist/cloudflare/core/tokens/formatters/json.js +0 -205
- package/dist/cloudflare/core/tokens/formatters/less.js +0 -4
- package/dist/cloudflare/core/tokens/formatters/scss.js +0 -258
- package/dist/cloudflare/core/tokens/formatters/stubs.js +0 -13
- package/dist/cloudflare/core/tokens/formatters/style-dictionary-v3.js +0 -213
- package/dist/cloudflare/core/tokens/formatters/tailwind-v3.js +0 -237
- package/dist/cloudflare/core/tokens/formatters/tailwind-v4.js +0 -335
- package/dist/cloudflare/core/tokens/formatters/tokens-studio.js +0 -256
- package/dist/cloudflare/core/tokens/formatters/ts-module.js +0 -198
- package/dist/cloudflare/core/tokens/index.js +0 -16
- package/dist/cloudflare/core/tokens/parsers/css-vars.js +0 -4
- package/dist/cloudflare/core/tokens/parsers/dtcg.js +0 -280
- package/dist/cloudflare/core/tokens/parsers/index.js +0 -138
- package/dist/cloudflare/core/tokens/parsers/json.js +0 -7
- package/dist/cloudflare/core/tokens/parsers/scss.js +0 -4
- package/dist/cloudflare/core/tokens/parsers/stubs.js +0 -20
- package/dist/cloudflare/core/tokens/parsers/style-dictionary-v3.js +0 -4
- package/dist/cloudflare/core/tokens/parsers/tailwind-v3.js +0 -4
- package/dist/cloudflare/core/tokens/parsers/tailwind-v4.js +0 -4
- package/dist/cloudflare/core/tokens/parsers/tokens-studio.js +0 -4
- package/dist/cloudflare/core/tokens/schemas.js +0 -152
- package/dist/cloudflare/core/tokens/transforms/color.js +0 -12
- package/dist/cloudflare/core/tokens/transforms/index.js +0 -29
- package/dist/cloudflare/core/tokens/transforms/size.js +0 -7
- package/dist/cloudflare/core/tokens/types.js +0 -18
- package/dist/cloudflare/core/tokens-tools.js +0 -1788
- package/dist/cloudflare/core/types/design-code.js +0 -4
- package/dist/cloudflare/core/types/enriched.js +0 -5
- package/dist/cloudflare/core/types/index.js +0 -4
- package/dist/cloudflare/core/variable-resolver.js +0 -85
- package/dist/cloudflare/core/version-tools.js +0 -1199
- package/dist/cloudflare/core/websocket-connector.js +0 -436
- package/dist/cloudflare/core/websocket-server.js +0 -1009
- package/dist/cloudflare/core/write-tools.js +0 -2506
- package/dist/cloudflare/index.js +0 -3010
package/dist/core/write-tools.js
CHANGED
|
@@ -2,7 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { createChildLogger } from "./logger.js";
|
|
3
3
|
const logger = createChildLogger({ component: "write-tools" });
|
|
4
4
|
/**
|
|
5
|
-
* Optional target file (TECH-32), on
|
|
5
|
+
* Optional target file (TECH-32), on all write tools. Without it a tool
|
|
6
6
|
* runs in the active file, as before. With it, the connector is built for that
|
|
7
7
|
* file and every command it sends goes only to that file's plugin.
|
|
8
8
|
*/
|
|
@@ -12,13 +12,31 @@ const fileKeyArg = z
|
|
|
12
12
|
.describe("Run in this file (its fileKey, as figma_list_open_files reports it) instead of the active file. " +
|
|
13
13
|
"Fails if that file's Desktop Bridge plugin is not connected; never falls back to the active file. " +
|
|
14
14
|
"Ignores the active file and the target lock. Leave it out to use the active file.");
|
|
15
|
+
/**
|
|
16
|
+
* Shared inline JS helper embedded in batch variable scripts.
|
|
17
|
+
* Validates 3/4/6/8-digit hex strings instead of silently producing NaN channels.
|
|
18
|
+
*/
|
|
19
|
+
const HEX_TO_RGBA_HELPER = `function hexToRgba(hex) {
|
|
20
|
+
if (typeof hex !== 'string') throw new Error('Invalid color value: expected hex string, got ' + typeof hex);
|
|
21
|
+
let h = hex.trim().replace(/^#/, '');
|
|
22
|
+
if (h.length === 3 || h.length === 4) h = h.split('').map(c => c + c).join('');
|
|
23
|
+
if (!/^[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/.test(h)) {
|
|
24
|
+
throw new Error('Invalid hex color: "' + hex + '" (expected #RGB, #RGBA, #RRGGBB, or #RRGGBBAA)');
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
r: parseInt(h.substring(0, 2), 16) / 255,
|
|
28
|
+
g: parseInt(h.substring(2, 4), 16) / 255,
|
|
29
|
+
b: parseInt(h.substring(4, 6), 16) / 255,
|
|
30
|
+
a: h.length === 8 ? parseInt(h.substring(6, 8), 16) / 255 : 1
|
|
31
|
+
};
|
|
32
|
+
}`;
|
|
15
33
|
/**
|
|
16
34
|
* Register write/manipulation tools that require a Desktop Bridge connector.
|
|
17
35
|
* Used by both local mode (src/local.ts) and cloud mode (src/index.ts).
|
|
18
36
|
* `getDesktopConnector(fileKey)` returns a connector bound to that file;
|
|
19
37
|
* with no key, one that follows the active file.
|
|
20
38
|
*/
|
|
21
|
-
export function registerWriteTools(server, getDesktopConnector) {
|
|
39
|
+
export function registerWriteTools(server, getDesktopConnector, options) {
|
|
22
40
|
// ============================================================================
|
|
23
41
|
// EXECUTION TOOL
|
|
24
42
|
// ============================================================================
|
|
@@ -106,9 +124,10 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
106
124
|
.string()
|
|
107
125
|
.optional()
|
|
108
126
|
.describe("Set the variable's description (the 'How to use this variable' field; exported as DTCG $description). Pass an empty string to clear it."),
|
|
109
|
-
|
|
127
|
+
fileKey: fileKeyArg,
|
|
128
|
+
}, async ({ variableId, modeId, value, description, fileKey }) => {
|
|
110
129
|
try {
|
|
111
|
-
const connector = await getDesktopConnector();
|
|
130
|
+
const connector = await getDesktopConnector(fileKey);
|
|
112
131
|
const hasValueUpdate = modeId !== undefined && value !== undefined;
|
|
113
132
|
const hasDescriptionUpdate = description !== undefined;
|
|
114
133
|
if ((modeId !== undefined) !== (value !== undefined)) {
|
|
@@ -140,6 +159,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
140
159
|
variable = result.variable || variable;
|
|
141
160
|
updated.push("description");
|
|
142
161
|
}
|
|
162
|
+
options?.onVariableWrite?.();
|
|
143
163
|
return {
|
|
144
164
|
content: [
|
|
145
165
|
{
|
|
@@ -190,9 +210,10 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
190
210
|
.record(z.string(), z.union([z.string(), z.number(), z.boolean()]))
|
|
191
211
|
.optional()
|
|
192
212
|
.describe("Optional initial values by mode ID. Example: { '1:0': '#FF0000', '1:1': '#0000FF' }"),
|
|
193
|
-
|
|
213
|
+
fileKey: fileKeyArg,
|
|
214
|
+
}, async ({ name, collectionId, resolvedType, description, valuesByMode, fileKey, }) => {
|
|
194
215
|
try {
|
|
195
|
-
const connector = await getDesktopConnector();
|
|
216
|
+
const connector = await getDesktopConnector(fileKey);
|
|
196
217
|
const result = await connector.createVariable(name, collectionId, resolvedType, {
|
|
197
218
|
description,
|
|
198
219
|
valuesByMode,
|
|
@@ -200,6 +221,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
200
221
|
if (!result.success) {
|
|
201
222
|
throw new Error(result.error || "Failed to create variable");
|
|
202
223
|
}
|
|
224
|
+
options?.onVariableWrite?.();
|
|
203
225
|
return {
|
|
204
226
|
content: [
|
|
205
227
|
{
|
|
@@ -244,9 +266,10 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
244
266
|
.array(z.string())
|
|
245
267
|
.optional()
|
|
246
268
|
.describe("Additional mode names to create. Example: ['Dark', 'High Contrast']"),
|
|
247
|
-
|
|
269
|
+
fileKey: fileKeyArg,
|
|
270
|
+
}, async ({ name, initialModeName, additionalModes, fileKey }) => {
|
|
248
271
|
try {
|
|
249
|
-
const connector = await getDesktopConnector();
|
|
272
|
+
const connector = await getDesktopConnector(fileKey);
|
|
250
273
|
const result = await connector.createVariableCollection(name, {
|
|
251
274
|
initialModeName,
|
|
252
275
|
additionalModes,
|
|
@@ -254,6 +277,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
254
277
|
if (!result.success) {
|
|
255
278
|
throw new Error(result.error || "Failed to create variable collection");
|
|
256
279
|
}
|
|
280
|
+
options?.onVariableWrite?.();
|
|
257
281
|
return {
|
|
258
282
|
content: [
|
|
259
283
|
{
|
|
@@ -298,6 +322,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
298
322
|
if (!result.success) {
|
|
299
323
|
throw new Error(result.error || "Failed to delete variable");
|
|
300
324
|
}
|
|
325
|
+
options?.onVariableWrite?.();
|
|
301
326
|
return {
|
|
302
327
|
content: [
|
|
303
328
|
{
|
|
@@ -335,13 +360,15 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
335
360
|
collectionId: z
|
|
336
361
|
.string()
|
|
337
362
|
.describe("The collection ID to delete (e.g., 'VariableCollectionId:123:456'). Get this from figma_get_variables."),
|
|
338
|
-
|
|
363
|
+
fileKey: fileKeyArg,
|
|
364
|
+
}, async ({ collectionId, fileKey }) => {
|
|
339
365
|
try {
|
|
340
|
-
const connector = await getDesktopConnector();
|
|
366
|
+
const connector = await getDesktopConnector(fileKey);
|
|
341
367
|
const result = await connector.deleteVariableCollection(collectionId);
|
|
342
368
|
if (!result.success) {
|
|
343
369
|
throw new Error(result.error || "Failed to delete variable collection");
|
|
344
370
|
}
|
|
371
|
+
options?.onVariableWrite?.();
|
|
345
372
|
return {
|
|
346
373
|
content: [
|
|
347
374
|
{
|
|
@@ -390,6 +417,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
390
417
|
if (!result.success) {
|
|
391
418
|
throw new Error(result.error || "Failed to rename variable");
|
|
392
419
|
}
|
|
420
|
+
options?.onVariableWrite?.();
|
|
393
421
|
return {
|
|
394
422
|
content: [
|
|
395
423
|
{
|
|
@@ -430,15 +458,17 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
430
458
|
modeName: z
|
|
431
459
|
.string()
|
|
432
460
|
.describe("The name for the new mode (e.g., 'Dark', 'Mobile', 'High Contrast')."),
|
|
433
|
-
|
|
461
|
+
fileKey: fileKeyArg,
|
|
462
|
+
}, async ({ collectionId, modeName, fileKey }) => {
|
|
434
463
|
try {
|
|
435
|
-
const connector = await getDesktopConnector();
|
|
464
|
+
const connector = await getDesktopConnector(fileKey);
|
|
436
465
|
const result = await connector.addMode(collectionId, modeName);
|
|
437
466
|
// Keep the plugin's error text intact — for a plan-limit failure it
|
|
438
467
|
// carries the file's real ceiling ("in addMode: Limited to N modes only").
|
|
439
468
|
if (!result.success) {
|
|
440
469
|
throw new Error(result.error || "Failed to add mode");
|
|
441
470
|
}
|
|
471
|
+
options?.onVariableWrite?.();
|
|
442
472
|
return {
|
|
443
473
|
content: [
|
|
444
474
|
{
|
|
@@ -482,13 +512,15 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
482
512
|
newName: z
|
|
483
513
|
.string()
|
|
484
514
|
.describe("The new name for the mode (e.g., 'Dark Theme', 'Tablet')."),
|
|
485
|
-
|
|
515
|
+
fileKey: fileKeyArg,
|
|
516
|
+
}, async ({ collectionId, modeId, newName, fileKey }) => {
|
|
486
517
|
try {
|
|
487
|
-
const connector = await getDesktopConnector();
|
|
518
|
+
const connector = await getDesktopConnector(fileKey);
|
|
488
519
|
const result = await connector.renameMode(collectionId, modeId, newName);
|
|
489
520
|
if (!result.success) {
|
|
490
521
|
throw new Error(result.error || "Failed to rename mode");
|
|
491
522
|
}
|
|
523
|
+
options?.onVariableWrite?.();
|
|
492
524
|
return {
|
|
493
525
|
content: [
|
|
494
526
|
{
|
|
@@ -559,16 +591,7 @@ const results = [];
|
|
|
559
591
|
const collectionId = ${JSON.stringify(collectionId)};
|
|
560
592
|
const vars = ${JSON.stringify(variables)};
|
|
561
593
|
|
|
562
|
-
|
|
563
|
-
hex = hex.replace('#', '');
|
|
564
|
-
if (hex.length === 3) hex = hex.split('').map(c => c + c).join('');
|
|
565
|
-
return {
|
|
566
|
-
r: parseInt(hex.substring(0, 2), 16) / 255,
|
|
567
|
-
g: parseInt(hex.substring(2, 4), 16) / 255,
|
|
568
|
-
b: parseInt(hex.substring(4, 6), 16) / 255,
|
|
569
|
-
a: hex.length === 8 ? parseInt(hex.substring(6, 8), 16) / 255 : 1
|
|
570
|
-
};
|
|
571
|
-
}
|
|
594
|
+
${HEX_TO_RGBA_HELPER}
|
|
572
595
|
|
|
573
596
|
const collection = await figma.variables.getVariableCollectionByIdAsync(collectionId);
|
|
574
597
|
if (!collection) return { created: 0, failed: vars.length, results: vars.map(v => ({ success: false, name: v.name, error: 'Collection not found: ' + collectionId })) };
|
|
@@ -622,6 +645,7 @@ return {
|
|
|
622
645
|
isError: true,
|
|
623
646
|
};
|
|
624
647
|
}
|
|
648
|
+
options?.onVariableWrite?.();
|
|
625
649
|
return {
|
|
626
650
|
content: [
|
|
627
651
|
{
|
|
@@ -667,7 +691,7 @@ return {
|
|
|
667
691
|
.describe("Mode ID (e.g., '1:0')"),
|
|
668
692
|
value: z
|
|
669
693
|
.union([z.string(), z.number(), z.boolean()])
|
|
670
|
-
.describe("New value. COLOR: hex like '#FF0000'. FLOAT: number. STRING: text. BOOLEAN: true/false."),
|
|
694
|
+
.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."),
|
|
671
695
|
}))
|
|
672
696
|
.min(1)
|
|
673
697
|
.max(100)
|
|
@@ -680,23 +704,18 @@ return {
|
|
|
680
704
|
const results = [];
|
|
681
705
|
const updates = ${JSON.stringify(updates)};
|
|
682
706
|
|
|
683
|
-
|
|
684
|
-
hex = hex.replace('#', '');
|
|
685
|
-
if (hex.length === 3) hex = hex.split('').map(c => c + c).join('');
|
|
686
|
-
return {
|
|
687
|
-
r: parseInt(hex.substring(0, 2), 16) / 255,
|
|
688
|
-
g: parseInt(hex.substring(2, 4), 16) / 255,
|
|
689
|
-
b: parseInt(hex.substring(4, 6), 16) / 255,
|
|
690
|
-
a: hex.length === 8 ? parseInt(hex.substring(6, 8), 16) / 255 : 1
|
|
691
|
-
};
|
|
692
|
-
}
|
|
707
|
+
${HEX_TO_RGBA_HELPER}
|
|
693
708
|
|
|
694
709
|
for (const u of updates) {
|
|
695
710
|
try {
|
|
696
711
|
const variable = await figma.variables.getVariableByIdAsync(u.variableId);
|
|
697
712
|
if (!variable) throw new Error('Variable not found: ' + u.variableId);
|
|
698
|
-
|
|
699
|
-
|
|
713
|
+
let processed = u.value;
|
|
714
|
+
if (typeof u.value === 'string' && u.value.startsWith('VariableID:')) {
|
|
715
|
+
processed = { type: 'VARIABLE_ALIAS', id: u.value };
|
|
716
|
+
} else if (variable.resolvedType === 'COLOR' && typeof u.value === 'string') {
|
|
717
|
+
processed = hexToRgba(u.value);
|
|
718
|
+
}
|
|
700
719
|
variable.setValueForMode(u.modeId, processed);
|
|
701
720
|
results.push({ success: true, variableId: u.variableId, name: variable.name });
|
|
702
721
|
} catch (err) {
|
|
@@ -726,6 +745,7 @@ return {
|
|
|
726
745
|
isError: true,
|
|
727
746
|
};
|
|
728
747
|
}
|
|
748
|
+
options?.onVariableWrite?.();
|
|
729
749
|
return {
|
|
730
750
|
content: [
|
|
731
751
|
{
|
|
@@ -797,16 +817,7 @@ const collectionName = ${JSON.stringify(collectionName)};
|
|
|
797
817
|
const modeNames = ${JSON.stringify(modes)};
|
|
798
818
|
const tokenDefs = ${JSON.stringify(tokens)};
|
|
799
819
|
|
|
800
|
-
|
|
801
|
-
hex = hex.replace('#', '');
|
|
802
|
-
if (hex.length === 3) hex = hex.split('').map(c => c + c).join('');
|
|
803
|
-
return {
|
|
804
|
-
r: parseInt(hex.substring(0, 2), 16) / 255,
|
|
805
|
-
g: parseInt(hex.substring(2, 4), 16) / 255,
|
|
806
|
-
b: parseInt(hex.substring(4, 6), 16) / 255,
|
|
807
|
-
a: hex.length === 8 ? parseInt(hex.substring(6, 8), 16) / 255 : 1
|
|
808
|
-
};
|
|
809
|
-
}
|
|
820
|
+
${HEX_TO_RGBA_HELPER}
|
|
810
821
|
|
|
811
822
|
// Step 1: Create collection
|
|
812
823
|
const collection = figma.variables.createVariableCollection(collectionName);
|
|
@@ -1015,6 +1026,7 @@ return {
|
|
|
1015
1026
|
isError: true,
|
|
1016
1027
|
};
|
|
1017
1028
|
}
|
|
1029
|
+
options?.onVariableWrite?.();
|
|
1018
1030
|
return {
|
|
1019
1031
|
content: [
|
|
1020
1032
|
{
|
|
@@ -1089,12 +1101,13 @@ After instantiating components, use figma_take_screenshot to verify the result l
|
|
|
1089
1101
|
.string()
|
|
1090
1102
|
.optional()
|
|
1091
1103
|
.describe("Parent node ID to append the instance to"),
|
|
1092
|
-
|
|
1104
|
+
fileKey: fileKeyArg,
|
|
1105
|
+
}, async ({ componentKey, nodeId, variant, overrides, position, parentId, fileKey, }) => {
|
|
1093
1106
|
try {
|
|
1094
1107
|
if (!componentKey && !nodeId) {
|
|
1095
1108
|
throw new Error("Either componentKey or nodeId is required");
|
|
1096
1109
|
}
|
|
1097
|
-
const connector = await getDesktopConnector();
|
|
1110
|
+
const connector = await getDesktopConnector(fileKey);
|
|
1098
1111
|
const result = await connector.instantiateComponent(componentKey || "", {
|
|
1099
1112
|
nodeId,
|
|
1100
1113
|
position,
|
|
@@ -1154,9 +1167,10 @@ After instantiating components, use figma_take_screenshot to verify the result l
|
|
|
1154
1167
|
.string()
|
|
1155
1168
|
.optional()
|
|
1156
1169
|
.describe("Optional rich text description using markdown formatting"),
|
|
1157
|
-
|
|
1170
|
+
fileKey: fileKeyArg,
|
|
1171
|
+
}, async ({ nodeId, description, descriptionMarkdown, fileKey }) => {
|
|
1158
1172
|
try {
|
|
1159
|
-
const connector = await getDesktopConnector();
|
|
1173
|
+
const connector = await getDesktopConnector(fileKey);
|
|
1160
1174
|
const result = await connector.setNodeDescription(nodeId, description, descriptionMarkdown);
|
|
1161
1175
|
if (!result.success) {
|
|
1162
1176
|
throw new Error(result.error || "Failed to set description");
|
|
@@ -1214,9 +1228,10 @@ After instantiating components, use figma_take_screenshot to verify the result l
|
|
|
1214
1228
|
}))
|
|
1215
1229
|
.optional()
|
|
1216
1230
|
.describe("Preferred components (INSTANCE_SWAP and SLOT only)"),
|
|
1217
|
-
|
|
1231
|
+
fileKey: fileKeyArg,
|
|
1232
|
+
}, async ({ nodeId, propertyName, type, defaultValue, description, preferredValues, fileKey }) => {
|
|
1218
1233
|
try {
|
|
1219
|
-
const connector = await getDesktopConnector();
|
|
1234
|
+
const connector = await getDesktopConnector(fileKey);
|
|
1220
1235
|
const options = {};
|
|
1221
1236
|
if (description)
|
|
1222
1237
|
options.description = description;
|
|
@@ -1294,9 +1309,10 @@ After instantiating components, use figma_take_screenshot to verify the result l
|
|
|
1294
1309
|
.describe("Preferred values (INSTANCE_SWAP only)"),
|
|
1295
1310
|
})
|
|
1296
1311
|
.describe("Object with the values to update"),
|
|
1297
|
-
|
|
1312
|
+
fileKey: fileKeyArg,
|
|
1313
|
+
}, async ({ nodeId, propertyName, newValue, fileKey }) => {
|
|
1298
1314
|
try {
|
|
1299
|
-
const connector = await getDesktopConnector();
|
|
1315
|
+
const connector = await getDesktopConnector(fileKey);
|
|
1300
1316
|
const result = await connector.editComponentProperty(nodeId, propertyName, newValue);
|
|
1301
1317
|
if (!result.success) {
|
|
1302
1318
|
throw new Error(result.error || "Failed to edit property");
|
|
@@ -1335,9 +1351,10 @@ After instantiating components, use figma_take_screenshot to verify the result l
|
|
|
1335
1351
|
propertyName: z
|
|
1336
1352
|
.string()
|
|
1337
1353
|
.describe("The full property name with suffix (e.g., 'Show Icon#123:456')"),
|
|
1338
|
-
|
|
1354
|
+
fileKey: fileKeyArg,
|
|
1355
|
+
}, async ({ nodeId, propertyName, fileKey }) => {
|
|
1339
1356
|
try {
|
|
1340
|
-
const connector = await getDesktopConnector();
|
|
1357
|
+
const connector = await getDesktopConnector(fileKey);
|
|
1341
1358
|
const result = await connector.deleteComponentProperty(nodeId, propertyName);
|
|
1342
1359
|
if (!result.success) {
|
|
1343
1360
|
throw new Error(result.error || "Failed to delete property");
|
|
@@ -1383,9 +1400,10 @@ After instantiating components, use figma_take_screenshot to verify the result l
|
|
|
1383
1400
|
.optional()
|
|
1384
1401
|
.default(true)
|
|
1385
1402
|
.describe("Whether to apply child constraints during resize (default: true)"),
|
|
1386
|
-
|
|
1403
|
+
fileKey: fileKeyArg,
|
|
1404
|
+
}, async ({ nodeId, width, height, withConstraints, fileKey }) => {
|
|
1387
1405
|
try {
|
|
1388
|
-
const connector = await getDesktopConnector();
|
|
1406
|
+
const connector = await getDesktopConnector(fileKey);
|
|
1389
1407
|
const result = await connector.resizeNode(nodeId, width, height, withConstraints);
|
|
1390
1408
|
if (!result.success) {
|
|
1391
1409
|
throw new Error(result.error || "Failed to resize node");
|
|
@@ -1423,9 +1441,10 @@ After instantiating components, use figma_take_screenshot to verify the result l
|
|
|
1423
1441
|
nodeId: z.string().describe("The node ID to move"),
|
|
1424
1442
|
x: z.number().describe("New X position"),
|
|
1425
1443
|
y: z.number().describe("New Y position"),
|
|
1426
|
-
|
|
1444
|
+
fileKey: fileKeyArg,
|
|
1445
|
+
}, async ({ nodeId, x, y, fileKey }) => {
|
|
1427
1446
|
try {
|
|
1428
|
-
const connector = await getDesktopConnector();
|
|
1447
|
+
const connector = await getDesktopConnector(fileKey);
|
|
1429
1448
|
const result = await connector.moveNode(nodeId, x, y);
|
|
1430
1449
|
if (!result.success) {
|
|
1431
1450
|
throw new Error(result.error || "Failed to move node");
|
|
@@ -1480,9 +1499,10 @@ After instantiating components, use figma_take_screenshot to verify the result l
|
|
|
1480
1499
|
.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."),
|
|
1481
1500
|
}))
|
|
1482
1501
|
.describe("Array of fill objects"),
|
|
1483
|
-
|
|
1502
|
+
fileKey: fileKeyArg,
|
|
1503
|
+
}, async ({ nodeId, fills, fileKey }) => {
|
|
1484
1504
|
try {
|
|
1485
|
-
const connector = await getDesktopConnector();
|
|
1505
|
+
const connector = await getDesktopConnector(fileKey);
|
|
1486
1506
|
const result = await connector.setNodeFills(nodeId, fills);
|
|
1487
1507
|
if (!result.success) {
|
|
1488
1508
|
throw new Error(result.error || "Failed to set fills");
|
|
@@ -1522,9 +1542,10 @@ After instantiating components, use figma_take_screenshot to verify the result l
|
|
|
1522
1542
|
nodeIds: z.array(z.string()).describe("Array of node IDs to apply the image fill to"),
|
|
1523
1543
|
imageData: z.string().describe("Base64-encoded image data (JPEG/PNG)"),
|
|
1524
1544
|
scaleMode: z.enum(["FILL", "FIT", "CROP", "TILE"]).optional().describe("How the image fills the node (default: FILL)"),
|
|
1525
|
-
|
|
1545
|
+
fileKey: fileKeyArg,
|
|
1546
|
+
}, async ({ nodeIds, imageData, scaleMode, fileKey }) => {
|
|
1526
1547
|
try {
|
|
1527
|
-
const connector = await getDesktopConnector();
|
|
1548
|
+
const connector = await getDesktopConnector(fileKey);
|
|
1528
1549
|
const result = await connector.setImageFill(nodeIds, imageData, scaleMode || "FILL");
|
|
1529
1550
|
if (!result.success) {
|
|
1530
1551
|
throw new Error(result.error || "Failed to set image fill");
|
|
@@ -1579,9 +1600,10 @@ After instantiating components, use figma_take_screenshot to verify the result l
|
|
|
1579
1600
|
.number()
|
|
1580
1601
|
.optional()
|
|
1581
1602
|
.describe("Stroke thickness in pixels"),
|
|
1582
|
-
|
|
1603
|
+
fileKey: fileKeyArg,
|
|
1604
|
+
}, async ({ nodeId, strokes, strokeWeight, fileKey }) => {
|
|
1583
1605
|
try {
|
|
1584
|
-
const connector = await getDesktopConnector();
|
|
1606
|
+
const connector = await getDesktopConnector(fileKey);
|
|
1585
1607
|
const result = await connector.setNodeStrokes(nodeId, strokes, strokeWeight);
|
|
1586
1608
|
if (!result.success) {
|
|
1587
1609
|
throw new Error(result.error || "Failed to set strokes");
|
|
@@ -1617,9 +1639,10 @@ After instantiating components, use figma_take_screenshot to verify the result l
|
|
|
1617
1639
|
// Tool: Clone Node
|
|
1618
1640
|
server.tool("figma_clone_node", "Duplicate a node. The clone is placed at a slight offset from the original.", {
|
|
1619
1641
|
nodeId: z.string().describe("The node ID to clone"),
|
|
1620
|
-
|
|
1642
|
+
fileKey: fileKeyArg,
|
|
1643
|
+
}, async ({ nodeId, fileKey }) => {
|
|
1621
1644
|
try {
|
|
1622
|
-
const connector = await getDesktopConnector();
|
|
1645
|
+
const connector = await getDesktopConnector(fileKey);
|
|
1623
1646
|
const result = await connector.cloneNode(nodeId);
|
|
1624
1647
|
if (!result.success) {
|
|
1625
1648
|
throw new Error(result.error || "Failed to clone node");
|
|
@@ -1655,9 +1678,10 @@ After instantiating components, use figma_take_screenshot to verify the result l
|
|
|
1655
1678
|
// Tool: Delete Node
|
|
1656
1679
|
server.tool("figma_delete_node", "Delete a node from the canvas. WARNING: This is a destructive operation (can be undone with Figma's undo).", {
|
|
1657
1680
|
nodeId: z.string().describe("The node ID to delete"),
|
|
1658
|
-
|
|
1681
|
+
fileKey: fileKeyArg,
|
|
1682
|
+
}, async ({ nodeId, fileKey }) => {
|
|
1659
1683
|
try {
|
|
1660
|
-
const connector = await getDesktopConnector();
|
|
1684
|
+
const connector = await getDesktopConnector(fileKey);
|
|
1661
1685
|
const result = await connector.deleteNode(nodeId);
|
|
1662
1686
|
if (!result.success) {
|
|
1663
1687
|
throw new Error(result.error || "Failed to delete node");
|
|
@@ -1743,9 +1767,10 @@ After instantiating components, use figma_take_screenshot to verify the result l
|
|
|
1743
1767
|
.string()
|
|
1744
1768
|
.optional()
|
|
1745
1769
|
.describe("Optional font style/weight to apply (e.g., 'Bold', 'Semi Bold'). No-space variants like 'SemiBold' are auto-corrected."),
|
|
1746
|
-
|
|
1770
|
+
fileKey: fileKeyArg,
|
|
1771
|
+
}, async ({ nodeId, text, fontSize, fontFamily, fontStyle, fileKey }) => {
|
|
1747
1772
|
try {
|
|
1748
|
-
const connector = await getDesktopConnector();
|
|
1773
|
+
const connector = await getDesktopConnector(fileKey);
|
|
1749
1774
|
const result = await connector.setTextContent(nodeId, text, fontSize || fontFamily || fontStyle
|
|
1750
1775
|
? { fontSize, fontFamily, fontStyle }
|
|
1751
1776
|
: undefined);
|
|
@@ -1808,9 +1833,10 @@ After instantiating components, use figma_take_screenshot to verify the result l
|
|
|
1808
1833
|
})
|
|
1809
1834
|
.optional()
|
|
1810
1835
|
.describe("Properties for the new node"),
|
|
1811
|
-
|
|
1836
|
+
fileKey: fileKeyArg,
|
|
1837
|
+
}, async ({ parentId, nodeType, properties, fileKey }) => {
|
|
1812
1838
|
try {
|
|
1813
|
-
const connector = await getDesktopConnector();
|
|
1839
|
+
const connector = await getDesktopConnector(fileKey);
|
|
1814
1840
|
const result = await connector.createChildNode(parentId, nodeType, properties);
|
|
1815
1841
|
if (!result.success) {
|
|
1816
1842
|
throw new Error(result.error || "Failed to create node");
|
|
@@ -2326,9 +2352,10 @@ Non-destructive: rearranges the existing variants in place (grid positions on th
|
|
|
2326
2352
|
})
|
|
2327
2353
|
.optional()
|
|
2328
2354
|
.describe("Layout options"),
|
|
2329
|
-
|
|
2355
|
+
fileKey: fileKeyArg,
|
|
2356
|
+
}, async ({ componentSetId, componentSetName, options, fileKey }) => {
|
|
2330
2357
|
try {
|
|
2331
|
-
const connector = await getDesktopConnector();
|
|
2358
|
+
const connector = await getDesktopConnector(fileKey);
|
|
2332
2359
|
const code = buildArrangeComponentSetCode(componentSetId ?? null, componentSetName ?? null, options);
|
|
2333
2360
|
const result = await connector.executeCodeViaUI(code, 25000);
|
|
2334
2361
|
if (!result.success) {
|
|
@@ -2418,7 +2445,8 @@ SIZE GUIDANCE: hard cap 100 variants. The timeout auto-scales with variant count
|
|
|
2418
2445
|
})
|
|
2419
2446
|
.optional()
|
|
2420
2447
|
.describe("Grid layout options, used when autoArrange is true."),
|
|
2421
|
-
|
|
2448
|
+
fileKey: fileKeyArg,
|
|
2449
|
+
}, async ({ baseComponentId, properties, componentIds, variantProperties, name, parentId, position, autoArrange, arrangeOptions, fileKey, }) => {
|
|
2422
2450
|
try {
|
|
2423
2451
|
if (!baseComponentId && (!componentIds || componentIds.length === 0)) {
|
|
2424
2452
|
throw new Error("Provide either baseComponentId + properties (generate variants from a base) or componentIds (combine existing components)");
|
|
@@ -2442,7 +2470,7 @@ SIZE GUIDANCE: hard cap 100 variants. The timeout auto-scales with variant count
|
|
|
2442
2470
|
const sizeWarning = requestedVariantCount > 40
|
|
2443
2471
|
? `${requestedVariantCount} variants requested — large sets are slow to build (timeout scales automatically, ~1.2s/variant, 2min cap) and heavy base components may still time out. Consider splitting into multiple sets (e.g. one per Size).`
|
|
2444
2472
|
: undefined;
|
|
2445
|
-
const connector = await getDesktopConnector();
|
|
2473
|
+
const connector = await getDesktopConnector(fileKey);
|
|
2446
2474
|
const result = await connector.createComponentSet({
|
|
2447
2475
|
baseComponentId,
|
|
2448
2476
|
properties,
|
|
@@ -2539,9 +2567,10 @@ SIZE GUIDANCE: hard cap 100 variants. The timeout auto-scales with variant count
|
|
|
2539
2567
|
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']."),
|
|
2540
2568
|
maxDepth: z.number().optional().describe("Maximum tree depth to traverse (default: 10)"),
|
|
2541
2569
|
maxFindings: z.number().optional().describe("Maximum findings before stopping (default: 100)"),
|
|
2542
|
-
|
|
2570
|
+
fileKey: fileKeyArg,
|
|
2571
|
+
}, async ({ nodeId, rules, maxDepth, maxFindings, fileKey }) => {
|
|
2543
2572
|
try {
|
|
2544
|
-
const connector = await getDesktopConnector();
|
|
2573
|
+
const connector = await getDesktopConnector(fileKey);
|
|
2545
2574
|
const result = await connector.lintDesign(nodeId, rules || ['wcag', 'design-system', 'layout'], maxDepth || 10, maxFindings || 100);
|
|
2546
2575
|
if (!result.success) {
|
|
2547
2576
|
throw new Error(result.error || "Lint failed");
|
|
@@ -2580,9 +2609,10 @@ SIZE GUIDANCE: hard cap 100 variants. The timeout auto-scales with variant count
|
|
|
2580
2609
|
"Requires Desktop Bridge plugin.", {
|
|
2581
2610
|
nodeId: z.string().optional().describe("Node ID of a COMPONENT_SET, COMPONENT, or INSTANCE to audit. Falls back to current selection if omitted."),
|
|
2582
2611
|
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."),
|
|
2583
|
-
|
|
2612
|
+
fileKey: fileKeyArg,
|
|
2613
|
+
}, async ({ nodeId, targetSize, fileKey }) => {
|
|
2584
2614
|
try {
|
|
2585
|
-
const connector = await getDesktopConnector();
|
|
2615
|
+
const connector = await getDesktopConnector(fileKey);
|
|
2586
2616
|
const result = await connector.auditComponentAccessibility(nodeId, targetSize);
|
|
2587
2617
|
if (!result.success) {
|
|
2588
2618
|
throw new Error(result.error || "Audit failed");
|