figme-mcp 1.1.0 → 1.1.2
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 +223 -626
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,626 +1,223 @@
|
|
|
1
|
-
# figme
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
- **
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
```json
|
|
78
|
-
{
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
```json
|
|
149
|
-
{
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
**
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
**
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
> React component.
|
|
225
|
-
|
|
226
|
-
A good agent then works roughly in this order:
|
|
227
|
-
|
|
228
|
-
1. **`fig_render`** — see it. The fastest orientation there is; check the `approximated` and
|
|
229
|
-
`unsupported` lists before trusting fine detail.
|
|
230
|
-
2. **`fig_node`** — size, corner radii, auto-layout, constraints, children.
|
|
231
|
-
3. **`fig_style`** — resolved fills, strokes, effects and typography, already shaped for code.
|
|
232
|
-
4. **`fig_text`** — the exact copy, including per-run styling.
|
|
233
|
-
5. **`fig_instance`** — if the node is an INSTANCE, what it came from and what is overridden.
|
|
234
|
-
This is what decides *reusable component* against *one-off*.
|
|
235
|
-
6. **`fig_variables`** — token names, so the code references your theme instead of raw hex.
|
|
236
|
-
7. **`fig_render` again**, and compare it against a screenshot of what you built.
|
|
237
|
-
|
|
238
|
-
That last step is why the renderer exists: you get a pixel oracle, not just a description.
|
|
239
|
-
|
|
240
|
-
### If the guid does not resolve
|
|
241
|
-
|
|
242
|
-
Node ids are intrinsic to the document, so the id in the link should be the id in the saved
|
|
243
|
-
file. If it is reported missing anyway you are most likely in the wrong file — compare
|
|
244
|
-
`fig_overview`'s document name with the link's slug — or find the layer by name with `fig_find`,
|
|
245
|
-
or browse the page with `fig_tree`.
|
|
246
|
-
|
|
247
|
-
### Do not let an agent fetch the link
|
|
248
|
-
|
|
249
|
-
A Figma URL is auth-gated and rendered by JavaScript, so fetching it yields nothing useful.
|
|
250
|
-
Worse, the slug reads like a description, which is enough for a model to invent a plausible
|
|
251
|
-
component and present it with confidence. The server says as much to every agent at connect
|
|
252
|
-
time; if yours reaches for the web regardless, tell it not to.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
## From source
|
|
256
|
-
|
|
257
|
-
For development, or to run a revision that is not published yet:
|
|
258
|
-
|
|
259
|
-
```bash
|
|
260
|
-
git clone https://github.com/ntson9p/figme-mcp.git
|
|
261
|
-
cd figme-mcp
|
|
262
|
-
npm install
|
|
263
|
-
npm run build # tsc -> dist/
|
|
264
|
-
npm test # builds, then runs the full node:test suite
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
Register `node /abs/path/to/figme-mcp/dist/mcp/server.js` in place of `npx -y figme-mcp`. This
|
|
268
|
-
repository ships a `.mcp.json` that already does so for Claude Code.
|
|
269
|
-
|
|
270
|
-
---
|
|
271
|
-
|
|
272
|
-
## Tools
|
|
273
|
-
|
|
274
|
-
Every tool takes `file` (path to the `.fig`). Node references are **guid strings** of the form
|
|
275
|
-
`"sessionID:localID"`, e.g. `"2:1339"`. Responses that were cut set `truncated: true` and return
|
|
276
|
-
an opaque `nextCursor` you can pass back.
|
|
277
|
-
|
|
278
|
-
The intended workflow: **`fig_overview` → `fig_tree` a page → `fig_node` / `fig_style` a guid**,
|
|
279
|
-
with `fig_find` to jump straight to something by name or copy, and `fig_render` whenever seeing
|
|
280
|
-
the thing is faster than reading it.
|
|
281
|
-
|
|
282
|
-
### 1. `fig_overview` — orient yourself
|
|
283
|
-
|
|
284
|
-
Document name, export date, format version, node counts by type, the page list, and how many
|
|
285
|
-
components / variables / images the file holds.
|
|
286
|
-
|
|
287
|
-
```jsonc
|
|
288
|
-
// → fig_overview { "file": "figma-input/sample.fig" }
|
|
289
|
-
{
|
|
290
|
-
"name": "Sample Design", "formatVersion": 106, "nodes": 116142,
|
|
291
|
-
"pages": [ { "guid": "0:2", "name": "Page 1", "children": 1137 }, /* … */ ],
|
|
292
|
-
"nodeTypes": { "INSTANCE": 38164, "FRAME": 32160, "TEXT": 16894, /* … */ },
|
|
293
|
-
"components": 2046, "variables": 273, "images": 212, "blobs": 9651
|
|
294
|
-
}
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
### 2. `fig_tree` — explore structure
|
|
298
|
-
|
|
299
|
-
`root` (default DOCUMENT), `depth` (default 2, max 6), `types` filter, `format`, `cursor`.
|
|
300
|
-
Returns a **flat list in document order**; each entry has `depth` (relative to the root) and
|
|
301
|
-
`parent`, so the hierarchy is reconstructable, plus `children` (a count) so you can see where
|
|
302
|
-
it is worth going deeper.
|
|
303
|
-
|
|
304
|
-
```
|
|
305
|
-
// → fig_tree { "file": "…", "root": "2:1339", "depth": 3, "format": "outline" }
|
|
306
|
-
root 2:1339 "Frame 39" depth<=3
|
|
307
|
-
[FRAME] 134x40 "Frame 39" (2:1339) x4
|
|
308
|
-
[INSTANCE] 16x16 "lv1/ic/setting" (2:1340)
|
|
309
|
-
[TEXT] 64x24 "text" (2:1341)
|
|
310
|
-
[INSTANCE] 6x6 "lv1/ic/arrow-down" (2:1342)
|
|
311
|
-
[FRAME] 28x24 "Frame 6" (2:1343) x1
|
|
312
|
-
[INSTANCE] 28x22 "lv2/notification" (2:1344)
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
`format: "outline"` is roughly 4× denser than JSON and is the best way to browse.
|
|
316
|
-
|
|
317
|
-
### 3. `fig_node` — inspect one node
|
|
318
|
-
|
|
319
|
-
`detail` is `summary`, `full` (default) or `raw`.
|
|
320
|
-
|
|
321
|
-
```jsonc
|
|
322
|
-
// → fig_node { "file": "…", "guid": "2:1339" }
|
|
323
|
-
{
|
|
324
|
-
"guid": "2:1339", "type": "FRAME", "name": "Frame 39",
|
|
325
|
-
"page": "Page 1", "path": "Page 1 / lv2/tab/large",
|
|
326
|
-
"geometry": { "width": 134, "height": 40, "x": 0, "y": 0, "absoluteX": 0, "absoluteY": 0 },
|
|
327
|
-
"cornerRadius": 4, "strokeWeight": 1,
|
|
328
|
-
"strokes": [ { "type": "SOLID", "color": "#FFFFFF",
|
|
329
|
-
"colorVar": { "variable": "tab/large/underline", "guid": "2:1319",
|
|
330
|
-
"values": { "active": "#FFFFFF", "inactive": "#333333" } } } ],
|
|
331
|
-
"autoLayout": { "mode": "HORIZONTAL", "spacing": 8,
|
|
332
|
-
"padding": { "top": 8, "right": 16, "bottom": 8, "left": 16 },
|
|
333
|
-
"primaryAlign": "CENTER", "counterAlign": "CENTER" },
|
|
334
|
-
"children": [ { "guid": "2:1340", "type": "INSTANCE", "name": "lv1/ic/setting", "size": "16x16" } ]
|
|
335
|
-
}
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
`detail: "raw"` returns the decoded Figma record verbatim (bytes as hex, int64 as strings). It
|
|
339
|
-
is the forward-compatibility escape hatch: anything the mappers do not understand yet is still
|
|
340
|
-
reachable there. Limited to one node per call.
|
|
341
|
-
|
|
342
|
-
### 4. `fig_find` — search names and copy
|
|
343
|
-
|
|
344
|
-
`query` (case-insensitive substring, matched against layer names **and** text content), plus
|
|
345
|
-
optional `types`, `scope`, `limit`, `cursor`. Omit `query` to list all nodes of some types.
|
|
346
|
-
|
|
347
|
-
```jsonc
|
|
348
|
-
// → fig_find { "file": "…", "query": "sample", "types": ["TEXT"], "limit": 3 }
|
|
349
|
-
{ "totalMatches": 1428, "returned": 3, "results": [
|
|
350
|
-
{ "guid": "8917:139951", "type": "TEXT", "name": "#number1", "size": "224x24",
|
|
351
|
-
"matchedOn": "text", "page": "Page 1",
|
|
352
|
-
"path": "Page 1 / Popup/Variant 7 / Frame 2608806 / …",
|
|
353
|
-
"text": "Sample notification text" } ] }
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
### 5. `fig_text` — copy inventory
|
|
357
|
-
|
|
358
|
-
All text in the file or in one `scope`, in document order, with a compact style block.
|
|
359
|
-
`includeRuns: true` adds the **styled runs** — the mixed-format spans Figma stores per UTF-16
|
|
360
|
-
code unit — each showing only the fields it overrides.
|
|
361
|
-
|
|
362
|
-
```jsonc
|
|
363
|
-
// → fig_text { "file": "…", "scope": "2:7098", "includeRuns": true }
|
|
364
|
-
{ "totalTextNodes": 2, "texts": [
|
|
365
|
-
{ "guid": "2:7099", "name": "✏️ Time", "characters": "Yesterday 9:41",
|
|
366
|
-
"page": "Page 1", "hasStyledRuns": true,
|
|
367
|
-
"style": { "font": "SF Pro Text Regular", "size": 11, "lineHeight": "13px", "color": "#3C3C43" },
|
|
368
|
-
"runs": [ { "start": 0, "end": 9, "text": "Yesterday", "styleID": 12,
|
|
369
|
-
"style": { "styles": { "text": { "name": "Caption2/Medium" } } } },
|
|
370
|
-
{ "start": 9, "end": 10, "text": " ", "styleID": 10, /* … */ },
|
|
371
|
-
{ "start": 10, "end": 11, "text": "9", "styleID": 9, /* … */ },
|
|
372
|
-
{ "start": 11, "end": 14, "text": ":41", "styleID": 10 } ] } ] }
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
### 6. `fig_style` — resolved style, shaped for code
|
|
376
|
-
|
|
377
|
-
Auto-layout translated into CSS flexbox terms, paints as hex, typography flattened, plus how
|
|
378
|
-
the node behaves inside its parent's layout.
|
|
379
|
-
|
|
380
|
-
```jsonc
|
|
381
|
-
// → fig_style { "file": "…", "guid": "2:1339" }
|
|
382
|
-
{ "style": {
|
|
383
|
-
"guid": "2:1339", "type": "FRAME", "width": 134, "height": 40, "cornerRadius": 4,
|
|
384
|
-
"strokes": [ { "type": "SOLID", "color": "#FFFFFF", "colorVar": { "variable": "tab/large/underline" } } ],
|
|
385
|
-
"strokeWeight": 1, "strokeAlign": "INSIDE",
|
|
386
|
-
"layout": { "display": "flex", "direction": "row", "gap": 8, "padding": "8px 16px",
|
|
387
|
-
"justifyContent": "center", "alignItems": "center", "primarySizing": "fixed" },
|
|
388
|
-
"inParentLayout": { "flexGrow": 1, "alignSelf": "stretch" } } }
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
For TEXT nodes it also returns `typography` and resolves shared text/fill styles to the values
|
|
392
|
-
they define (`styles.text.defines`).
|
|
393
|
-
|
|
394
|
-
### 7. `fig_components` — the component catalogue
|
|
395
|
-
|
|
396
|
-
SYMBOL nodes with their component set, property definitions and defaults, and instance counts —
|
|
397
|
-
most-used first, so the load-bearing parts of the design system come back first.
|
|
398
|
-
|
|
399
|
-
```jsonc
|
|
400
|
-
// → fig_components { "file": "…", "query": "lv2/tab/large" }
|
|
401
|
-
{ "totalComponents": 2046, "components": [
|
|
402
|
-
{ "guid": "2:1337", "name": "lv2/tab/large", "page": "Page 1",
|
|
403
|
-
"size": "134x40", "instances": 599,
|
|
404
|
-
"propDefs": [ { "name": "show badge(🔴)", "type": "BOOL", "default": false },
|
|
405
|
-
{ "name": "icon", "type": "INSTANCE_SWAP" } ] } ] }
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
### 8. `fig_instance` — how an instance differs from its component
|
|
409
|
-
|
|
410
|
-
```jsonc
|
|
411
|
-
// → fig_instance { "file": "…", "guid": "2:1329" }
|
|
412
|
-
{ "instance": { "guid": "2:1329", "name": "lv1/color/GL/#FFFFFF",
|
|
413
|
-
"page": "Page 1",
|
|
414
|
-
"symbol": { "guid": "2:1325", "name": "lv1/color/GL/#FFFFFF", "inFile": true } },
|
|
415
|
-
"overrideCount": 1,
|
|
416
|
-
"overrides": [ { "path": ["0:2528"], "targetGuid": "2:1325", "targetName": "lv1/color/GL/#FFFFFF",
|
|
417
|
-
"fields": { "size": "22x22", "fillsCleared": true } } ] }
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
An instance that sets component properties reports them with the names resolved, e.g.
|
|
421
|
-
`propAssignments: [ { "defID": "108:1543", "name": "text", "type": "TEXT", "value": "Back" } ]`.
|
|
422
|
-
A path segment is the target's `overrideKey` when it has one and its guid otherwise, and a
|
|
423
|
-
nested path is walked through swapped instances exactly as the renderer expands them.
|
|
424
|
-
|
|
425
|
-
### 9. `fig_variables` — design tokens
|
|
426
|
-
|
|
427
|
-
Every collection with its modes, and every variable with a value per mode. Alias chains are
|
|
428
|
-
followed when the target lives in the same file.
|
|
429
|
-
|
|
430
|
-
```jsonc
|
|
431
|
-
// → fig_variables { "file": "…", "query": "tab/large" }
|
|
432
|
-
{ "totalSets": 27, "totalVariables": 273,
|
|
433
|
-
"sets": [ { "guid": "2:1312", "name": "active/inactive",
|
|
434
|
-
"modes": [ { "id": "509:1300", "name": "active" }, { "id": "509:1301", "name": "inactive" } ],
|
|
435
|
-
"variableCount": 38 } ],
|
|
436
|
-
"variables": [ { "guid": "2:1313", "name": "tab/large/bg", "type": "COLOR", "set": "active/inactive",
|
|
437
|
-
"values": { "active": "#FFFFFF", "inactive": "#EEEEEE" } } ] }
|
|
438
|
-
```
|
|
439
|
-
|
|
440
|
-
### 10. `fig_image` — embedded bitmaps
|
|
441
|
-
|
|
442
|
-
Pass `hash` (the 40-hex id that `fig_node` / `fig_style` report on image paints), or `guid` to
|
|
443
|
-
use the images on a node, or `hash: "thumbnail"` for the document preview. Images ≤ 2 MB come
|
|
444
|
-
back as viewable image content; larger ones return metadata, and `savePath` writes the exact
|
|
445
|
-
bytes to disk.
|
|
446
|
-
|
|
447
|
-
```jsonc
|
|
448
|
-
// → fig_image { "file": "…", "hash": "01ef2f8cd2d276901473acb9ddd7afb2421198e3" }
|
|
449
|
-
// [image content] + { "mime": "image/png", "byteLength": 4553, "width": 88, "height": 84 }
|
|
450
|
-
```
|
|
451
|
-
|
|
452
|
-
### 11. `fig_blob` — raw payload bytes
|
|
453
|
-
|
|
454
|
-
`index` into the file's blob table (`fig_node` reports these as `vector.networkBlob` /
|
|
455
|
-
`vector.fillBlobs`), `encoding` (`base64` | `hex`), `maxBytes` (default 65536).
|
|
456
|
-
|
|
457
|
-
```jsonc
|
|
458
|
-
// → fig_blob { "file": "…", "index": 16, "maxBytes": 8, "encoding": "hex" }
|
|
459
|
-
{ "index": 16, "byteLength": 96, "returnedBytes": 8, "data": "0100000000020080",
|
|
460
|
-
"truncated": true, "blobCount": 9651 }
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
### 12. `fig_render` — a picture of a node
|
|
464
|
-
|
|
465
|
-
`guid` (any node, or a page), `format` (`png` | `svg`, default `png`), `scale` (default 2),
|
|
466
|
-
`maxSize` (longest edge, default 1568), `background` (`transparent` | `page`), `savePath`,
|
|
467
|
-
`maxNodes` (default 20000, counted in layers).
|
|
468
|
-
|
|
469
|
-
```jsonc
|
|
470
|
-
// → fig_render { "file": "…", "guid": "2:1339" }
|
|
471
|
-
// [image content, 268x80 PNG]
|
|
472
|
-
{ "root": { "guid": "2:1339", "name": "Frame 39", "type": "FRAME" },
|
|
473
|
-
"bounds": { "x": 0, "y": 0, "w": 134, "h": 40 }, "width": 268, "height": 80, "scale": 2,
|
|
474
|
-
"nodesVisited": 9, "nodesDrawn": 8, "svgBytes": 4757, "renderMs": 4.6, "rasterMs": 55.3,
|
|
475
|
-
"unsupported": [], "approximated": [], "format": "png" }
|
|
476
|
-
```
|
|
477
|
-
|
|
478
|
-
---
|
|
479
|
-
|
|
480
|
-
## Rendering (`fig_render`)
|
|
481
|
-
|
|
482
|
-
Nothing is fetched and no font is needed: Figma stores outlined strokes, combined booleans,
|
|
483
|
-
per-glyph outlines and per-instance resolved geometry in the file, so the renderer consumes
|
|
484
|
-
what Figma already computed. The SVG it builds is rasterized by
|
|
485
|
-
[`@resvg/resvg-wasm`](https://github.com/yisibl/resvg-js), an **optional** dependency — with it
|
|
486
|
-
uninstalled, everything still works and `fig_render` returns SVG instead of PNG.
|
|
487
|
-
|
|
488
|
-
**Exact**: solid fills, linear and radial gradients, image fills in all four scale modes,
|
|
489
|
-
strokes including inside/outside alignment, boolean operations, text (glyph outlines, per-run
|
|
490
|
-
colours, underline and strikethrough, truncation with an ellipsis), component instances with
|
|
491
|
-
their overrides, their component properties (text, visibility, instance swap) and the sizes the
|
|
492
|
-
enclosing instance gives them, colour and effect styles resolved to their live definition, frame
|
|
493
|
-
clipping, layer opacity, the fifteen shared blend modes, drop and inner shadows, layer blur,
|
|
494
|
-
and all three mask types.
|
|
495
|
-
|
|
496
|
-
**Approximated, and always reported**: background blur (drawn flat — a backdrop filter cannot
|
|
497
|
-
see behind an isolated subtree), `LINEAR_DODGE` and `LINEAR_BURN` (drawn as `screen` and
|
|
498
|
-
`multiply`), angular and diamond gradients (drawn as their average colour), image crop and
|
|
499
|
-
image rotation.
|
|
500
|
-
|
|
501
|
-
**Skipped, and always reported**: emoji glyphs, FigJam-style nodes (`WIDGET`, `CONNECTOR`,
|
|
502
|
-
`SHAPE_WITH_TEXT`), text without stored outlines (including a text property whose words have
|
|
503
|
-
no outlines in the file), and strokes on text.
|
|
504
|
-
|
|
505
|
-
Fidelity was measured against a Figma export of a 1440×3026 form built from component
|
|
506
|
-
instances: 0.18 % of pixels differ, all anti-aliasing. That export came from a design that
|
|
507
|
-
is not public, so it is not distributed here — `npm run visual` runs levels 1-2 until you
|
|
508
|
-
supply your own export.
|
|
509
|
-
|
|
510
|
-
Every response carries `unsupported` and `approximated` lists naming the feature and up to five
|
|
511
|
-
example guids. An empty pair means the renderer believes it drew the node exactly. Exact values
|
|
512
|
-
always remain available from `fig_node`, `fig_style` and `fig_text`.
|
|
513
|
-
|
|
514
|
-
There is also a CLI for the same thing:
|
|
515
|
-
|
|
516
|
-
```bash
|
|
517
|
-
npm run build
|
|
518
|
-
node scripts/render.mjs figma-input/sample.fig 2:1339 out.png --scale 2 --background page
|
|
519
|
-
```
|
|
520
|
-
|
|
521
|
-
---
|
|
522
|
-
|
|
523
|
-
## How it stays inside a context window
|
|
524
|
-
|
|
525
|
-
- Default response budget **20,000 characters**, hard cap **50,000**.
|
|
526
|
-
- Never more than **300 nodes** per response, and never more than **one** `raw` node per call.
|
|
527
|
-
- Trees are **shallow by default** (depth 2) and every entry carries a child count, so the agent
|
|
528
|
-
chooses where to spend tokens.
|
|
529
|
-
- Unset fields are omitted, floats are rounded to 2 decimals, colours become `#RRGGBB`, and
|
|
530
|
-
sizes collapse to `"134x40"`.
|
|
531
|
-
- Anything cut sets `truncated: true` and returns an opaque `nextCursor`; paging is stable
|
|
532
|
-
because it follows document order.
|
|
533
|
-
- There is deliberately **no "dump everything" tool**.
|
|
534
|
-
|
|
535
|
-
## How it works
|
|
536
|
-
|
|
537
|
-
```
|
|
538
|
-
.fig bytes
|
|
539
|
-
├─ Stage A container ZIP? unwrap canvas.fig (+ meta.json, thumbnail.png, images/<sha1>)
|
|
540
|
-
├─ Stage B framing "fig-kiwi" magic, u32 version, length-prefixed chunks
|
|
541
|
-
├─ Stage C codec sniffed per chunk: zstd / raw deflate / zlib / stored
|
|
542
|
-
├─ Stage D Kiwi chunk[0] = the binary SCHEMA, chunk[1] = the data decoded WITH it
|
|
543
|
-
└─ Stage E tree rebuild the layer tree from parentIndex + fractional-index order
|
|
544
|
-
```
|
|
545
|
-
|
|
546
|
-
The decisive detail is Stage D: **the schema ships inside the file**. Nothing here hardcodes a
|
|
547
|
-
field id, so Figma's constant schema additions do not break the reader.
|
|
548
|
-
|
|
549
|
-
```
|
|
550
|
-
src/
|
|
551
|
-
fig/ LAYER 1 — mechanical decode, knows bytes, knows nothing about design
|
|
552
|
-
bytebuffer.ts Kiwi primitives (varuint, zigzag, the rotated float32, NUL strings)
|
|
553
|
-
zip.ts central-directory ZIP reader (Figma zeroes the local-header sizes)
|
|
554
|
-
container.ts container sniffing, chunk framing, per-chunk decompression
|
|
555
|
-
kiwi.ts binary-schema decode + schema-driven data decode
|
|
556
|
-
imagemeta.ts image magic-byte + dimension sniffing
|
|
557
|
-
invariants.ts post-parse checks; warnings, not failures
|
|
558
|
-
parse.ts the whole pipeline in one call
|
|
559
|
-
model/ LAYER 2 — Figma semantics, never touches bytes
|
|
560
|
-
tree.ts guid keys, tree build, fractional-index sibling order
|
|
561
|
-
index.ts FileIndex: by-guid, by-type, by-asset-key, override keys, prop defs, search
|
|
562
|
-
access.ts typed accessors over open records + presentation helpers
|
|
563
|
-
summarize.ts node summary / full detail / style block builders
|
|
564
|
-
text.ts characters + styled-run resolution
|
|
565
|
-
instance.ts what an instance looks like: identity paths, records, property assignments
|
|
566
|
-
components.ts symbols, instances, the fig_instance view
|
|
567
|
-
variables.ts collections, modes, alias chains
|
|
568
|
-
render/ LAYER 2½ — fig_render: node subtree → SVG → (optional) PNG
|
|
569
|
-
export.ts the traversal; instance.ts / style.ts / bounds.ts / text.ts / paint.ts /
|
|
570
|
-
effects.ts each own one concern; report.ts the frozen feature vocabulary
|
|
571
|
-
mcp/ LAYER 3 — protocol
|
|
572
|
-
create.ts server factory (used by the entry point and by tests)
|
|
573
|
-
server.ts stdio entry point
|
|
574
|
-
respond.ts budgets, cursors, truncation
|
|
575
|
-
tools/*.ts one file per tool
|
|
576
|
-
cache.ts LRU of parsed files, invalidated on mtime/size change
|
|
577
|
-
```
|
|
578
|
-
|
|
579
|
-
`mcp/` and `model/` never touch bytes; `fig/` knows nothing about Figma semantics.
|
|
580
|
-
|
|
581
|
-
## Testing
|
|
582
|
-
|
|
583
|
-
```bash
|
|
584
|
-
npm test # build + full node:test suite (unit + golden)
|
|
585
|
-
npm run typecheck # type-checks src, test and scripts
|
|
586
|
-
npm run smoke # spawns the built server and walks the demo script over real stdio
|
|
587
|
-
npm run crosscheck # deep-compares our decode against the official kiwi-schema package
|
|
588
|
-
```
|
|
589
|
-
|
|
590
|
-
- **Unit tests** need no asset: Kiwi primitives against a transcribed reference encoder, a
|
|
591
|
-
synthetic ZIP with data-descriptor entries, fractional-index ordering, the response budgeter,
|
|
592
|
-
image sniffing, and corrupt-input handling.
|
|
593
|
-
- **Golden tests** run against `figma-input/sample.fig` and assert measured values (116,142
|
|
594
|
-
nodes, 638 schema definitions, 10 pages, specific node geometry, …). They **skip with a clear
|
|
595
|
-
message** if the asset is absent.
|
|
596
|
-
- **Fixture identifiers are placeholders.** The design this was developed against is not
|
|
597
|
-
public. Page, component, variable and layer names in this README, in `docs/` and in the
|
|
598
|
-
golden tests were replaced with neutral stand-ins, and node guids were renumbered. The
|
|
599
|
-
structure and the measured numbers are real; the names are not, so the string assertions
|
|
600
|
-
will not match your own `.fig` until you update them.
|
|
601
|
-
- **Cross-check** decodes the same buffers with Evan Wallace's official `kiwi-schema` package and
|
|
602
|
-
deep-compares every field: currently **0 differences across 17,353,242 compared values**. It
|
|
603
|
-
skips cleanly if `kiwi-schema` is not installed.
|
|
604
|
-
|
|
605
|
-
`tools/fig2json.mjs` is the original dependency-free reference CLI that Layer 1 was ported from.
|
|
606
|
-
It is kept working as a debugging aid:
|
|
607
|
-
|
|
608
|
-
```bash
|
|
609
|
-
node tools/fig2json.mjs figma-input/sample.fig /tmp/out
|
|
610
|
-
# writes schema.kiwi.txt, nodes.ndjson, tree-outline.txt, meta.json
|
|
611
|
-
```
|
|
612
|
-
|
|
613
|
-
Dumping `schema.kiwi.txt` is the fastest way to look up a field this server does not map yet;
|
|
614
|
-
then read it with `fig_node detail:"raw"`.
|
|
615
|
-
|
|
616
|
-
## Documentation
|
|
617
|
-
|
|
618
|
-
- [`docs/fig-reading-solution.md`](docs/fig-reading-solution.md) — the byte-level reading
|
|
619
|
-
procedure, verified end to end.
|
|
620
|
-
- [`docs/mcp-implementation-plan.md`](docs/mcp-implementation-plan.md) — the plan this server
|
|
621
|
-
implements, including the golden values in Appendix A.
|
|
622
|
-
- [`docs/fig-file-format.md`](docs/fig-file-format.md) — the measurement log and evidence.
|
|
623
|
-
|
|
624
|
-
## License
|
|
625
|
-
|
|
626
|
-
MIT.
|
|
1
|
+
# figme
|
|
2
|
+
|
|
3
|
+
An [MCP](https://modelcontextprotocol.io) server that lets your AI agent read Figma `.fig`
|
|
4
|
+
files — offline, with no Figma account or API token.
|
|
5
|
+
|
|
6
|
+
[](https://www.npmjs.com/package/figme-mcp)
|
|
7
|
+
[](https://nodejs.org)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
Save a design from Figma as a `.fig` file, and your agent can read everything in it: layers and
|
|
11
|
+
layout, colours, text, components, design tokens and images. figme can also draw any frame as a
|
|
12
|
+
picture, so the agent can compare what it built with the design.
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
you: "what does the tab component in design.fig look like?"
|
|
16
|
+
|
|
17
|
+
fig_overview → 10 pages, 2,046 components, 273 variables, 212 images
|
|
18
|
+
fig_find → "lv2/tab/large" is 2:1337, on page "Page 1"
|
|
19
|
+
fig_style → display:flex, direction:row, gap:8, padding:"8px 16px",
|
|
20
|
+
cornerRadius:4, stroke #FFFFFF bound to variable "tab/large/underline"
|
|
21
|
+
(active #FFFFFF / inactive #333333)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Why figme
|
|
25
|
+
|
|
26
|
+
- **No account, token or network.** figme reads the file on your disk and never contacts
|
|
27
|
+
figma.com.
|
|
28
|
+
- **Everything in the file.** Layers and geometry, auto-layout, fills, strokes, effects, text with
|
|
29
|
+
mixed styles, components and instances, variables, prototype links and images. Layout comes
|
|
30
|
+
back as CSS flexbox, colours as hex, and colours bound to variables keep their token names.
|
|
31
|
+
- **Pictures as well as numbers.** `fig_render` draws any layer as a PNG or SVG.
|
|
32
|
+
- **Small responses.** Even on a 116,000-node file, a response stays around 20 KB. Results are
|
|
33
|
+
shallow by default, filterable and paged.
|
|
34
|
+
- **Robust to Figma updates.** Every `.fig` carries the schema that describes it, and figme decodes
|
|
35
|
+
the file with that schema, so fields Figma adds later don't break it.
|
|
36
|
+
|
|
37
|
+
## Quick start
|
|
38
|
+
|
|
39
|
+
You need [Node.js](https://nodejs.org) 22.15 or newer.
|
|
40
|
+
|
|
41
|
+
**1. Save the design as a `.fig` file.** In Figma, choose **File → Save local copy…** If it's a
|
|
42
|
+
Community file, click **Open in Figma** first.
|
|
43
|
+
|
|
44
|
+
**2. Add figme to your agent.** In Claude Code:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
claude mcp add figme -- npx -y figme-mcp
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For Cursor, VS Code, Windsurf and other clients, see [Set up your client](#set-up-your-client).
|
|
51
|
+
|
|
52
|
+
**3. Ask.** Give the full path to the file, and paste a Figma link if you have one:
|
|
53
|
+
|
|
54
|
+
> Using figme, read /Users/me/Desktop/App.fig and build this frame as a React component:
|
|
55
|
+
> https://www.figma.com/design/AbC123/App?node-id=3017-121
|
|
56
|
+
|
|
57
|
+
The agent picks the tools from there. A few more things to try:
|
|
58
|
+
|
|
59
|
+
- *"List the pages and the most-used components in /Users/me/Desktop/App.fig."*
|
|
60
|
+
- *"Turn the colour variables in /Users/me/Desktop/App.fig into CSS custom properties."*
|
|
61
|
+
- *"Render the sign-in screen in /Users/me/Desktop/App.fig to /Users/me/Desktop/sign-in.png."*
|
|
62
|
+
|
|
63
|
+
## Set up your client
|
|
64
|
+
|
|
65
|
+
Every client runs the same command, `npx -y figme-mcp`. Only the place you put it changes.
|
|
66
|
+
|
|
67
|
+
<details>
|
|
68
|
+
<summary><b>Claude Code</b></summary>
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
claude mcp add figme -- npx -y figme-mcp # this project
|
|
72
|
+
claude mcp add -s user figme -- npx -y figme-mcp # every project
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
To share the server with everyone who works on a repository, commit a `.mcp.json` at its root:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"mcpServers": {
|
|
80
|
+
"figme": { "command": "npx", "args": ["-y", "figme-mcp"] }
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The Claude Code extensions for VS Code and JetBrains use this same configuration. They don't read
|
|
86
|
+
the editor's own MCP settings.
|
|
87
|
+
|
|
88
|
+
</details>
|
|
89
|
+
|
|
90
|
+
<details>
|
|
91
|
+
<summary><b>Cursor</b></summary>
|
|
92
|
+
|
|
93
|
+
Add this to `~/.cursor/mcp.json` for every project, or to `.cursor/mcp.json` for one:
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"mcpServers": {
|
|
98
|
+
"figme": { "command": "npx", "args": ["-y", "figme-mcp"] }
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
</details>
|
|
104
|
+
|
|
105
|
+
<details>
|
|
106
|
+
<summary><b>VS Code (GitHub Copilot)</b></summary>
|
|
107
|
+
|
|
108
|
+
From a terminal:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
code --add-mcp '{"name":"figme","command":"npx","args":["-y","figme-mcp"]}'
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Or add this to `.vscode/mcp.json`. VS Code uses the key `servers`, not `mcpServers`:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"servers": {
|
|
119
|
+
"figme": { "type": "stdio", "command": "npx", "args": ["-y", "figme-mcp"] }
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Then switch the Chat view to **Agent** mode.
|
|
125
|
+
|
|
126
|
+
</details>
|
|
127
|
+
|
|
128
|
+
<details>
|
|
129
|
+
<summary><b>Windsurf</b></summary>
|
|
130
|
+
|
|
131
|
+
Add this to `~/.codeium/windsurf/mcp_config.json`:
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"mcpServers": {
|
|
136
|
+
"figme": { "command": "npx", "args": ["-y", "figme-mcp"] }
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
</details>
|
|
142
|
+
|
|
143
|
+
<details>
|
|
144
|
+
<summary><b>Other clients</b></summary>
|
|
145
|
+
|
|
146
|
+
Any client that can start a local (stdio) MCP server works. Give it:
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
{ "command": "npx", "args": ["-y", "figme-mcp"] }
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Config file locations change between client releases. If a path above doesn't match what you
|
|
153
|
+
see, check your client's MCP documentation.
|
|
154
|
+
|
|
155
|
+
</details>
|
|
156
|
+
|
|
157
|
+
**On Windows**, some clients can't find `npx` by themselves. If the server doesn't start, run it
|
|
158
|
+
through `cmd`:
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
{ "command": "cmd", "args": ["/c", "npx", "-y", "figme-mcp"] }
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Tips
|
|
165
|
+
|
|
166
|
+
- **Always give the full path to the file, even with a link.** A Figma link can't tell figme which
|
|
167
|
+
file on your disk it belongs to, and a relative path is resolved from wherever your client
|
|
168
|
+
started the server.
|
|
169
|
+
- **Don't let the agent open the Figma link.** The page needs a login, so the agent gets nothing
|
|
170
|
+
useful back, and it may then invent a design from the words in the URL. figme tells agents not
|
|
171
|
+
to; if yours tries anyway, stop it.
|
|
172
|
+
- **"Node not found"** usually means the saved file isn't the one the link points to. Compare the
|
|
173
|
+
document name that `fig_overview` reports with the name in the link, or ask the agent to find
|
|
174
|
+
the layer by name instead.
|
|
175
|
+
- **Big files need memory.** A 39 MB `.fig` takes about 900 MB of RAM once parsed, and figme keeps
|
|
176
|
+
up to 4 parsed files. On a smaller machine, keep just one:
|
|
177
|
+
|
|
178
|
+
```json
|
|
179
|
+
{ "command": "npx", "args": ["-y", "figme-mcp", "--max-files", "1"] }
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Tools
|
|
183
|
+
|
|
184
|
+
Your agent picks these on its own; you don't need to name them.
|
|
185
|
+
|
|
186
|
+
| Tool | What it gives the agent |
|
|
187
|
+
|---|---|
|
|
188
|
+
| `fig_overview` | The pages, node counts, and how many components, variables and images the file has |
|
|
189
|
+
| `fig_tree` | The layer tree under a node, a few levels at a time |
|
|
190
|
+
| `fig_node` | One layer in detail: size, position, corner radii, auto-layout, children |
|
|
191
|
+
| `fig_find` | Layers whose name or text contains a string |
|
|
192
|
+
| `fig_text` | All the text, with fonts and mixed styles |
|
|
193
|
+
| `fig_style` | Fills, strokes, effects and typography, with auto-layout as CSS flexbox |
|
|
194
|
+
| `fig_components` | The components, their properties, and how often each is used |
|
|
195
|
+
| `fig_instance` | What an instance changes from its component |
|
|
196
|
+
| `fig_variables` | Design tokens: every collection, mode and value |
|
|
197
|
+
| `fig_image` | Embedded images, and the file's thumbnail |
|
|
198
|
+
| `fig_blob` | Raw vector data, for anything the other tools don't decode |
|
|
199
|
+
| `fig_render` | A PNG or SVG picture of any layer or page |
|
|
200
|
+
|
|
201
|
+
Parameters and example responses for each are in [docs/tools.md](docs/tools.md).
|
|
202
|
+
|
|
203
|
+
## Limitations
|
|
204
|
+
|
|
205
|
+
- **Read-only.** figme never changes your `.fig`. It writes a file only when you ask `fig_image`
|
|
206
|
+
or `fig_render` to save one.
|
|
207
|
+
- **A snapshot, not a live link.** A `.fig` holds the design as it was when you saved it. When the
|
|
208
|
+
design changes, save it again; figme picks up the new file.
|
|
209
|
+
- **Rendering is close, not pixel-perfect.** `fig_render` approximates a few effects, such as
|
|
210
|
+
background blur and angular gradients, and skips a few things, such as emoji. Every render
|
|
211
|
+
lists what it approximated or skipped. See [docs/rendering.md](docs/rendering.md).
|
|
212
|
+
- **Libraries from other files aren't included.** Styles, variables and components published from
|
|
213
|
+
another file show up as references, without their values.
|
|
214
|
+
- **Vector paths aren't decoded.** `fig_blob` returns their raw bytes.
|
|
215
|
+
|
|
216
|
+
## Contributing
|
|
217
|
+
|
|
218
|
+
Issues and pull requests are welcome. [CONTRIBUTING.md](CONTRIBUTING.md) explains how to build
|
|
219
|
+
from source and run the tests, and how the parser works.
|
|
220
|
+
|
|
221
|
+
## License
|
|
222
|
+
|
|
223
|
+
[MIT](LICENSE)
|