figme-mcp 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -533
- package/dist/mcp/create.js +3 -0
- package/dist/mcp/tools/context.d.ts +10 -0
- package/dist/mcp/tools/context.js +27 -0
- package/dist/mcp/tools/find.js +36 -6
- package/dist/mcp/tools/image.js +3 -2
- package/dist/mcp/tools/instance.js +6 -3
- package/dist/mcp/tools/node.js +8 -4
- package/dist/mcp/tools/render.js +2 -1
- package/dist/mcp/tools/style.js +5 -3
- package/dist/mcp/tools/text.js +29 -6
- package/dist/mcp/tools/tree.js +25 -11
- package/dist/model/components.d.ts +8 -1
- package/dist/model/components.js +68 -28
- package/dist/model/scene.d.ts +41 -0
- package/dist/model/scene.js +182 -0
- package/dist/model/styles.d.ts +56 -0
- package/dist/model/styles.js +90 -0
- package/dist/model/summarize.d.ts +44 -5
- package/dist/model/summarize.js +243 -46
- package/dist/model/text.d.ts +5 -1
- package/dist/model/text.js +13 -3
- package/dist/model/tree.d.ts +12 -3
- package/dist/model/tree.js +24 -7
- package/dist/render/export.d.ts +20 -0
- package/dist/render/export.js +17 -6
- package/dist/render/index.js +25 -4
- package/dist/render/style.d.ts +8 -14
- package/dist/render/style.js +3 -40
- package/package.json +66 -66
package/README.md
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
# figme
|
|
1
|
+
# figme
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
strokes, effects, auto-layout, text (including mixed-format runs), components and instances,
|
|
6
|
-
variables, prototype links and embedded bitmaps.
|
|
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.
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
[](https://www.npmjs.com/package/figme-mcp)
|
|
7
|
+
[](https://nodejs.org)
|
|
8
|
+
[](LICENSE)
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
with
|
|
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.
|
|
14
13
|
|
|
15
14
|
```
|
|
16
15
|
you: "what does the tab component in design.fig look like?"
|
|
@@ -22,605 +21,206 @@ fig_style → display:flex, direction:row, gap:8, padding:"8px 16px",
|
|
|
22
21
|
(active #FFFFFF / inactive #333333)
|
|
23
22
|
```
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
## Why figme
|
|
26
25
|
|
|
27
|
-
|
|
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
|
+
- **What Figma shows, not just what it stores.** The layers inside a component instance come
|
|
32
|
+
back with the instance's overrides applied, under the ids Figma itself gives them, and a
|
|
33
|
+
shared style reports its live value rather than the stale copy cached beside it.
|
|
34
|
+
- **Pictures as well as numbers.** `fig_render` draws any layer as a PNG or SVG.
|
|
35
|
+
- **Small responses.** Even on a 116,000-node file, a response stays around 20 KB. Results are
|
|
36
|
+
shallow by default, filterable and paged.
|
|
37
|
+
- **Robust to Figma updates.** Every `.fig` carries the schema that describes it, and figme decodes
|
|
38
|
+
the file with that schema, so fields Figma adds later don't break it.
|
|
28
39
|
|
|
29
|
-
|
|
40
|
+
## Quick start
|
|
30
41
|
|
|
31
|
-
|
|
32
|
-
frames, but it does contain everything needed to draw them again: Figma bakes outlined
|
|
33
|
-
strokes, combined booleans, per-glyph outlines and per-instance geometry into the file at save
|
|
34
|
-
time. `fig_render` uses that to produce a real picture offline — see
|
|
35
|
-
[Rendering](#rendering-fig_render) for exactly what is exact and what is approximated. It is
|
|
36
|
-
not a screenshot of Figma and never will be: read the report before trusting fine detail.
|
|
37
|
-
- **No writing.** Nothing is ever written back into a `.fig`. The only write paths in the whole
|
|
38
|
-
server are `fig_image { savePath }` and `fig_render { savePath }`, which write to a path you
|
|
39
|
-
name.
|
|
40
|
-
- **No Figma API and no network.** Nothing here talks to figma.com. Library assets published
|
|
41
|
-
from *other* files (styles, variables, components) cannot be resolved offline; they come back
|
|
42
|
-
as their opaque `assetRef` so you can see that they exist and where they point.
|
|
43
|
-
- **No vector-network decoding (v1).** Vector geometry lives in a separate binary blob format.
|
|
44
|
-
`fig_node` reports the blob indices and `fig_blob` hands you the raw bytes, but this server
|
|
45
|
-
does not interpret them.
|
|
46
|
-
- **Not a diffing or version-history tool.** A saved `.fig` is a full snapshot, not a delta.
|
|
42
|
+
You need [Node.js](https://nodejs.org) 22.15 or newer.
|
|
47
43
|
|
|
48
|
-
|
|
44
|
+
**1. Save the design as a `.fig` file.** In Figma, choose **File → Save local copy…** If it's a
|
|
45
|
+
Community file, click **Open in Figma** first.
|
|
49
46
|
|
|
50
|
-
|
|
51
|
-
- Runtime dependencies: `@modelcontextprotocol/sdk` and `zod`. The parser itself uses only
|
|
52
|
-
Node built-ins.
|
|
47
|
+
**2. Add figme to your agent.** In Claude Code:
|
|
53
48
|
|
|
54
|
-
|
|
49
|
+
```bash
|
|
50
|
+
claude mcp add figme -- npx -y figme-mcp
|
|
51
|
+
```
|
|
55
52
|
|
|
56
|
-
|
|
57
|
-
client downloads it on first start with `npx`.
|
|
53
|
+
For Cursor, VS Code, Windsurf and other clients, see [Set up your client](#set-up-your-client).
|
|
58
54
|
|
|
59
|
-
|
|
55
|
+
**3. Ask.** Give the full path to the file, and paste a Figma link if you have one:
|
|
60
56
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
there is no account, token or sign-in — but there is also nothing to read until you save
|
|
64
|
-
one. In Figma: `File -> Save local copy...`.
|
|
57
|
+
> Using figme, read /Users/me/Desktop/App.fig and build this frame as a React component:
|
|
58
|
+
> https://www.figma.com/design/AbC123/App?node-id=3017-121
|
|
65
59
|
|
|
66
|
-
|
|
60
|
+
The agent picks the tools from there. A few more things to try:
|
|
67
61
|
|
|
68
|
-
|
|
62
|
+
- *"List the pages and the most-used components in /Users/me/Desktop/App.fig."*
|
|
63
|
+
- *"Turn the colour variables in /Users/me/Desktop/App.fig into CSS custom properties."*
|
|
64
|
+
- *"Render the sign-in screen in /Users/me/Desktop/App.fig to /Users/me/Desktop/sign-in.png."*
|
|
69
65
|
|
|
70
|
-
|
|
71
|
-
{ "command": "npx", "args": ["-y", "figme-mcp"] }
|
|
72
|
-
```
|
|
66
|
+
## Set up your client
|
|
73
67
|
|
|
74
|
-
|
|
75
|
-
route it through `cmd`:
|
|
76
|
-
|
|
77
|
-
```json
|
|
78
|
-
{ "command": "cmd", "args": ["/c", "npx", "-y", "figme-mcp"] }
|
|
79
|
-
```
|
|
68
|
+
Every client runs the same command, `npx -y figme-mcp`. Only the place you put it changes.
|
|
80
69
|
|
|
81
|
-
|
|
70
|
+
<details>
|
|
71
|
+
<summary><b>Claude Code</b></summary>
|
|
82
72
|
|
|
83
73
|
```bash
|
|
84
74
|
claude mcp add figme -- npx -y figme-mcp # this project
|
|
85
75
|
claude mcp add -s user figme -- npx -y figme-mcp # every project
|
|
86
76
|
```
|
|
87
77
|
|
|
88
|
-
|
|
78
|
+
To share the server with everyone who works on a repository, commit a `.mcp.json` at its root:
|
|
89
79
|
|
|
90
80
|
```json
|
|
91
81
|
{
|
|
92
82
|
"mcpServers": {
|
|
93
|
-
"figme": {
|
|
94
|
-
"command": "npx",
|
|
95
|
-
"args": ["-y", "figme-mcp"]
|
|
96
|
-
}
|
|
83
|
+
"figme": { "command": "npx", "args": ["-y", "figme-mcp"] }
|
|
97
84
|
}
|
|
98
85
|
}
|
|
99
86
|
```
|
|
100
87
|
|
|
101
|
-
The Claude Code
|
|
102
|
-
|
|
103
|
-
They do not read the editor's own MCP settings.
|
|
88
|
+
The Claude Code extensions for VS Code and JetBrains use this same configuration. They don't read
|
|
89
|
+
the editor's own MCP settings.
|
|
104
90
|
|
|
105
|
-
|
|
91
|
+
</details>
|
|
106
92
|
|
|
107
|
-
|
|
93
|
+
<details>
|
|
94
|
+
<summary><b>Cursor</b></summary>
|
|
95
|
+
|
|
96
|
+
Add this to `~/.cursor/mcp.json` for every project, or to `.cursor/mcp.json` for one:
|
|
108
97
|
|
|
109
98
|
```json
|
|
110
99
|
{
|
|
111
100
|
"mcpServers": {
|
|
112
|
-
"figme": {
|
|
113
|
-
"command": "npx",
|
|
114
|
-
"args": ["-y", "figme-mcp"]
|
|
115
|
-
}
|
|
101
|
+
"figme": { "command": "npx", "args": ["-y", "figme-mcp"] }
|
|
116
102
|
}
|
|
117
103
|
}
|
|
118
104
|
```
|
|
119
105
|
|
|
120
|
-
|
|
106
|
+
</details>
|
|
121
107
|
|
|
122
|
-
|
|
108
|
+
<details>
|
|
109
|
+
<summary><b>VS Code (GitHub Copilot)</b></summary>
|
|
123
110
|
|
|
124
|
-
|
|
125
|
-
{
|
|
126
|
-
"servers": {
|
|
127
|
-
"figme": {
|
|
128
|
-
"type": "stdio",
|
|
129
|
-
"command": "npx",
|
|
130
|
-
"args": ["-y", "figme-mcp"]
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
The same entry works in your user `settings.json` under `"mcp"`. From a terminal:
|
|
111
|
+
From a terminal:
|
|
137
112
|
|
|
138
113
|
```bash
|
|
139
114
|
code --add-mcp '{"name":"figme","command":"npx","args":["-y","figme-mcp"]}'
|
|
140
115
|
```
|
|
141
116
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
### Windsurf
|
|
145
|
-
|
|
146
|
-
`~/.codeium/windsurf/mcp_config.json`:
|
|
117
|
+
Or add this to `.vscode/mcp.json`. VS Code uses the key `servers`, not `mcpServers`:
|
|
147
118
|
|
|
148
119
|
```json
|
|
149
120
|
{
|
|
150
|
-
"
|
|
151
|
-
"figme": {
|
|
152
|
-
"command": "npx",
|
|
153
|
-
"args": ["-y", "figme-mcp"]
|
|
154
|
-
}
|
|
121
|
+
"servers": {
|
|
122
|
+
"figme": { "type": "stdio", "command": "npx", "args": ["-y", "figme-mcp"] }
|
|
155
123
|
}
|
|
156
124
|
}
|
|
157
125
|
```
|
|
158
126
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
Spawn `npx -y figme-mcp` and talk MCP over stdio.
|
|
162
|
-
|
|
163
|
-
> Client UIs and config paths move between releases. The `command` and `args` pair above is the
|
|
164
|
-
> stable part; if a path here does not match what you see, check that client's own MCP
|
|
165
|
-
> documentation.
|
|
127
|
+
Then switch the Chat view to **Agent** mode.
|
|
166
128
|
|
|
167
|
-
|
|
129
|
+
</details>
|
|
168
130
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
path removes the guesswork:
|
|
131
|
+
<details>
|
|
132
|
+
<summary><b>Windsurf</b></summary>
|
|
172
133
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
**Watch memory.** `--max-files N` (default 4) caps how many parsed files stay cached. A 39 MB
|
|
176
|
-
`.fig` decodes to roughly 900 MB of live objects, so lower it on a small machine and raise it
|
|
177
|
-
only with memory to spare:
|
|
134
|
+
Add this to `~/.codeium/windsurf/mcp_config.json`:
|
|
178
135
|
|
|
179
136
|
```json
|
|
180
|
-
{ "command": "npx", "args": ["-y", "figme-mcp", "--max-files", "1"] }
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
## From a Figma link
|
|
184
|
-
|
|
185
|
-
The usual job: *implement this component from our design*, starting from a link someone pasted
|
|
186
|
-
into a ticket.
|
|
187
|
-
|
|
188
|
-
### 1. Save the file locally
|
|
189
|
-
|
|
190
|
-
This server reads a `.fig` on your disk and never contacts figma.com, so a link by itself is not
|
|
191
|
-
enough. Open it in Figma and use `File -> Save local copy...`. For a Community file, click
|
|
192
|
-
**Open in Figma** first — that duplicates it into your drafts, which is what makes the copy
|
|
193
|
-
possible.
|
|
194
|
-
|
|
195
|
-
### 2. Take the node id from the link
|
|
196
|
-
|
|
197
|
-
```
|
|
198
|
-
https://www.figma.com/design/<file key>/<slug>?node-id=3017-121&t=<share token>
|
|
199
|
-
~~~~~~~~~~ ~~~~~~~~
|
|
200
|
-
which file which node
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
Figma writes node ids with a **dash** in links; the `.fig` format uses a **colon**, so
|
|
204
|
-
`node-id=3017-121` is guid `3017:121`. You do not have to convert it yourself — every guid
|
|
205
|
-
argument accepts all of these:
|
|
206
|
-
|
|
207
|
-
| You pass | Server reads |
|
|
208
|
-
|---|---|
|
|
209
|
-
| `3017:121` | `3017:121` |
|
|
210
|
-
| `3017-121` | `3017:121` |
|
|
211
|
-
| `3017%3A121` | `3017:121` |
|
|
212
|
-
| `node-id=3017-121` | `3017:121` |
|
|
213
|
-
| the whole `https://www.figma.com/design/...?node-id=3017-121` | `3017:121` |
|
|
214
|
-
|
|
215
|
-
Anything else is passed through untouched, so a typo still fails loudly rather than being
|
|
216
|
-
guessed at.
|
|
217
|
-
|
|
218
|
-
The file key is a cloud identifier with no counterpart in the saved file, so nothing can work
|
|
219
|
-
out which local `.fig` a link refers to. Always give the path yourself.
|
|
220
|
-
|
|
221
|
-
### 3. Ask for the component
|
|
222
|
-
|
|
223
|
-
> Using figme, read `/abs/path/UX Case Study Template.fig` and implement node `3017:121` as a
|
|
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
137
|
{
|
|
290
|
-
"
|
|
291
|
-
|
|
292
|
-
|
|
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" } ]
|
|
138
|
+
"mcpServers": {
|
|
139
|
+
"figme": { "command": "npx", "args": ["-y", "figme-mcp"] }
|
|
140
|
+
}
|
|
335
141
|
}
|
|
336
142
|
```
|
|
337
143
|
|
|
338
|
-
|
|
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
|
-
---
|
|
144
|
+
</details>
|
|
479
145
|
|
|
480
|
-
|
|
146
|
+
<details>
|
|
147
|
+
<summary><b>Other clients</b></summary>
|
|
481
148
|
|
|
482
|
-
|
|
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.
|
|
149
|
+
Any client that can start a local (stdio) MCP server works. Give it:
|
|
487
150
|
|
|
488
|
-
|
|
489
|
-
|
|
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
|
|
151
|
+
```json
|
|
152
|
+
{ "command": "npx", "args": ["-y", "figme-mcp"] }
|
|
519
153
|
```
|
|
520
154
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
## How it stays inside a context window
|
|
155
|
+
Config file locations change between client releases. If a path above doesn't match what you
|
|
156
|
+
see, check your client's MCP documentation.
|
|
524
157
|
|
|
525
|
-
|
|
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**.
|
|
158
|
+
</details>
|
|
534
159
|
|
|
535
|
-
|
|
160
|
+
**On Windows**, some clients can't find `npx` by themselves. If the server doesn't start, run it
|
|
161
|
+
through `cmd`:
|
|
536
162
|
|
|
537
|
-
```
|
|
538
|
-
|
|
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
|
|
163
|
+
```json
|
|
164
|
+
{ "command": "cmd", "args": ["/c", "npx", "-y", "figme-mcp"] }
|
|
544
165
|
```
|
|
545
166
|
|
|
546
|
-
|
|
547
|
-
field id, so Figma's constant schema additions do not break the reader.
|
|
167
|
+
## Tips
|
|
548
168
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
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
|
-
```
|
|
169
|
+
- **Always give the full path to the file, even with a link.** A Figma link can't tell figme which
|
|
170
|
+
file on your disk it belongs to, and a relative path is resolved from wherever your client
|
|
171
|
+
started the server.
|
|
172
|
+
- **Don't let the agent open the Figma link.** The page needs a login, so the agent gets nothing
|
|
173
|
+
useful back, and it may then invent a design from the words in the URL. figme tells agents not
|
|
174
|
+
to; if yours tries anyway, stop it.
|
|
175
|
+
- **"Node not found"** usually means the saved file isn't the one the link points to. Compare the
|
|
176
|
+
document name that `fig_overview` reports with the name in the link, or ask the agent to find
|
|
177
|
+
the layer by name instead.
|
|
178
|
+
- **Big files need memory.** A 39 MB `.fig` takes about 900 MB of RAM once parsed, and figme keeps
|
|
179
|
+
up to 4 parsed files. On a smaller machine, keep just one:
|
|
578
180
|
|
|
579
|
-
|
|
181
|
+
```json
|
|
182
|
+
{ "command": "npx", "args": ["-y", "figme-mcp", "--max-files", "1"] }
|
|
183
|
+
```
|
|
580
184
|
|
|
581
|
-
##
|
|
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"`.
|
|
185
|
+
## Tools
|
|
615
186
|
|
|
616
|
-
|
|
187
|
+
Your agent picks these on its own; you don't need to name them.
|
|
617
188
|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
189
|
+
| Tool | What it gives the agent |
|
|
190
|
+
|---|---|
|
|
191
|
+
| `fig_overview` | The pages, node counts, and how many components, variables and images the file has |
|
|
192
|
+
| `fig_tree` | The layer tree under a node, a few levels at a time, instances opened |
|
|
193
|
+
| `fig_node` | One layer in detail: size, position, corner radii, auto-layout, children |
|
|
194
|
+
| `fig_find` | Layers whose name or text contains a string |
|
|
195
|
+
| `fig_text` | All the text, with fonts and mixed styles |
|
|
196
|
+
| `fig_style` | Fills, strokes, effects and typography, with auto-layout as CSS flexbox |
|
|
197
|
+
| `fig_components` | The components, their properties, and how often each is used |
|
|
198
|
+
| `fig_instance` | What an instance changes from its component |
|
|
199
|
+
| `fig_variables` | Design tokens: every collection, mode and value |
|
|
200
|
+
| `fig_image` | Embedded images, and the file's thumbnail |
|
|
201
|
+
| `fig_blob` | Raw vector data, for anything the other tools don't decode |
|
|
202
|
+
| `fig_render` | A PNG or SVG picture of any layer or page |
|
|
203
|
+
|
|
204
|
+
Parameters and example responses for each are in [docs/tools.md](docs/tools.md).
|
|
205
|
+
|
|
206
|
+
## Limitations
|
|
207
|
+
|
|
208
|
+
- **Read-only.** figme never changes your `.fig`. It writes a file only when you ask `fig_image`
|
|
209
|
+
or `fig_render` to save one.
|
|
210
|
+
- **A snapshot, not a live link.** A `.fig` holds the design as it was when you saved it. When the
|
|
211
|
+
design changes, save it again; figme picks up the new file.
|
|
212
|
+
- **Rendering is close, not pixel-perfect.** `fig_render` approximates a few effects, such as
|
|
213
|
+
background blur and angular gradients, and skips a few things, such as emoji. Every render
|
|
214
|
+
lists what it approximated or skipped. See [docs/rendering.md](docs/rendering.md).
|
|
215
|
+
- **Libraries from other files aren't included.** Styles, variables and components published from
|
|
216
|
+
another file show up as references, without their values.
|
|
217
|
+
- **Vector paths aren't decoded.** `fig_blob` returns their raw bytes.
|
|
218
|
+
|
|
219
|
+
## Contributing
|
|
220
|
+
|
|
221
|
+
Issues and pull requests are welcome. [CONTRIBUTING.md](CONTRIBUTING.md) explains how to build
|
|
222
|
+
from source and run the tests, and how the parser works.
|
|
623
223
|
|
|
624
224
|
## License
|
|
625
225
|
|
|
626
|
-
MIT
|
|
226
|
+
[MIT](LICENSE)
|