figma-rust-mcp 3.2.12 → 3.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +400 -403
- package/bin/agent-config.js +90 -0
- package/bin/{figma-mcp.js → figma-rust-mcp.js} +668 -591
- package/package.json +64 -62
- package/plugin/code.js +52 -52
- package/plugin/manifest.json +25 -25
- package/plugin/ui.html +211 -211
- package/scripts/build-plugin.js +52 -52
- package/scripts/test-bridge-sessions.mjs +155 -155
- package/scripts/test-plugin-tokens.mjs +447 -388
- package/scripts/test-rust-mcp.sh +38 -38
package/README.md
CHANGED
|
@@ -1,299 +1,296 @@
|
|
|
1
|
-
# figma-
|
|
2
|
-
|
|
3
|
-
High-performance, bidirectional Model Context Protocol (MCP) server written in **Rust** connecting AI coding assistants directly to **Figma Desktop**.
|
|
4
|
-
|
|
5
|
-
Enables AI agents (Google Antigravity, Claude Code, Cursor, Windsurf, VS Code, Zed) to **compile Figma designs into production code**, **extract design tokens**, **draw UI directly on canvas**, and **inspect hierarchy, styles, and assets** — with zero external API keys needed.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## ⚡ Highlights
|
|
10
|
-
|
|
11
|
-
- **Lossless Rust Tree Compression**: Compact/minimal tree responses share identical style bundles when the complete JSON becomes smaller. Node IDs, hierarchy, text, geometry and state differences remain intact. Full detail bypasses Rust compression; no heuristic merging of screens or repeated items.
|
|
12
|
-
- **Pure Rust Native Performance**: Starts in `< 1ms`, uses `~3MB RAM`, zero GC pauses.
|
|
13
|
-
- **In-Memory Deep Indexing (`figma_index`)**: Queries layers, components, styles, and tokens in `< 1ms` without slow canvas roundtrips.
|
|
14
|
-
- **Binary IPC & Chunk Streaming**: Powered by **MessagePack** (`rmp-serde`) and progressive subtree chunking for instant transfers of massive design files.
|
|
15
|
-
- **Incremental Diff Updates**: Sub-millisecond live document sync (`upsert_node`) keeps the server index fresh as you edit in Figma.
|
|
16
|
-
- **Instant Design-to-Code (`figma_to_code`)**: Compiles Figma frames into clean, semantic components (**React + Tailwind**, **React Native**, **Vue 3 + Tailwind**, **HTML**, **SwiftUI**).
|
|
17
|
-
- **Design Token Exporter (`figma_get_tokens`)**: Exports variables and styles to **Tailwind config**, **CSS custom properties** (`:root` & dark mode), **TypeScript consts**, or **W3C DTCG Token Studio JSON**.
|
|
18
|
-
- **Batch Asset Extractor (`figma_export_assets` / `figma_export_asset`)**: Extracts SVG icons and raster images directly to project folders (`outputPath`) with auto-generated TypeScript barrel exports (`index.ts`) — zero chat token bloating.
|
|
19
|
-
- **Sandboxed JS Drawing Engine (`figma_write`)**: Powered by **Boa** (pure Rust ECMAScript engine) with built-in asset resolvers and 7 icon packs (*Ionicons, Lucide, Tabler, Bootstrap, Fluent, Phosphor*).
|
|
20
|
-
- **Multi-Tab / Multi-Session Support**: Seamlessly connects to multiple open Figma files simultaneously.
|
|
21
|
-
- **100% Localhost Privacy**: All communication stays strictly on `127.0.0.1:38451`.
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## 🏛️ Architecture & Zero-Touch Connection
|
|
26
|
-
|
|
27
|
-
```text
|
|
28
|
-
┌────────────────────────────────────────────────────────────────────────┐
|
|
29
|
-
│ Terminal / Background Service │
|
|
30
|
-
│ figma-mcp (Pure Rust Engine) │
|
|
31
|
-
│ • MCP Streamable HTTP (/mcp) & legacy SSE (/sse, /message) │
|
|
32
|
-
│ • Dynamic Runtime Server (/plugin/code.js, /plugin/ui.html) │
|
|
33
|
-
│ • In-Memory Fast Index (<1ms Lookups & Incremental Diffs) │
|
|
34
|
-
│ • Design-to-Code Compiler (React/Tailwind, Vue, RN, SwiftUI) │
|
|
35
|
-
│ • Design Token Transformer (CSS, Tailwind, TypeScript, W3C DTCG) │
|
|
36
|
-
│ • Sandboxed JS Runtime (Boa ECMAScript Engine) │
|
|
37
|
-
│ • Binary MessagePack & Progressive Subtree Chunk Receiver │
|
|
38
|
-
└───────────────▲────────────────────────────────────────▲───────────────┘
|
|
39
|
-
│ (ws://127.0.0.1:38451/ws) │ (http://127.0.0.1:38451/mcp)
|
|
40
|
-
│ (Dynamic Code Streaming & Hot-Reload) │ (JSON-RPC 2.0 / Streamable HTTP)
|
|
41
|
-
┌─────────┴─────────┐ ┌─────────┴─────────┐
|
|
42
|
-
│ Figma Desktop │ │ AI Assistant(s) │
|
|
43
|
-
│ (Thin Loader) │ │ Google Antigravity│
|
|
44
|
-
│ │ │ Cursor / Windsurf │
|
|
45
|
-
│ • Zero-Touch Sync │ │ Claude Code / Zed │
|
|
46
|
-
│ • Live Hot-Reload │ └───────────────────┘
|
|
47
|
-
│ • SVG/PNG Render │
|
|
48
|
-
└───────────────────┘
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### 🔌 How the Zero-Touch Connection Works:
|
|
52
|
-
1. **Permanent Thin Loader**: You only import the Figma plugin **once** (`~/.figma-mcp/plugin/manifest.json`).
|
|
53
|
-
2. **Dynamic Runtime Streaming**: Upon launch, the Thin Loader contacts `http://127.0.0.1:38451/plugin/code.js` to fetch and execute the latest runtime in memory.
|
|
54
|
-
3. **Live WebSocket Hot-Reload**: The plugin connects to `ws://127.0.0.1:38451/ws`. When you upgrade `figma-rust-mcp` or restart the daemon, the plugin automatically detects the new server version and hot-reloads seamlessly — **no need to re-import or restart the plugin in Figma**.
|
|
55
|
-
4. **Auto-Reconnect & Offline Buffer**: If Figma is opened before the Rust service starts, the plugin displays a waiting screen and connects automatically the instant the service is up.
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
## 🚀 Quick Start
|
|
60
|
-
|
|
61
|
-
### 1. One-
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
npx -y figma-rust-mcp@latest --
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
npx -y figma-rust-mcp@latest --upgrade
|
|
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
|
-
|
|
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
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
with
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
-
|
|
291
|
-
- `"
|
|
292
|
-
- `"
|
|
293
|
-
- `"
|
|
294
|
-
- `"search_components"`: Find component sets and variants.
|
|
295
|
-
- `"search_styles"`: Find paint, text, and effect styles.
|
|
296
|
-
- `"search_variables"`: Find design token variables by name or collection.
|
|
1
|
+
# figma-rust-mcp
|
|
2
|
+
|
|
3
|
+
High-performance, bidirectional Model Context Protocol (MCP) server written in **Rust** connecting AI coding assistants directly to **Figma Desktop**.
|
|
4
|
+
|
|
5
|
+
Enables AI agents (Google Antigravity, Claude Code, Cursor, Windsurf, VS Code, Zed) to **compile Figma designs into production code**, **extract design tokens**, **draw UI directly on canvas**, and **inspect hierarchy, styles, and assets** — with zero external API keys needed.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## ⚡ Highlights
|
|
10
|
+
|
|
11
|
+
- **Lossless Rust Tree Compression**: Compact/minimal tree responses share identical style bundles when the complete JSON becomes smaller. Node IDs, hierarchy, text, geometry and state differences remain intact. Full detail bypasses Rust compression; no heuristic merging of screens or repeated items.
|
|
12
|
+
- **Pure Rust Native Performance**: Starts in `< 1ms`, uses `~3MB RAM`, zero GC pauses.
|
|
13
|
+
- **In-Memory Deep Indexing (`figma_index`)**: Queries layers, components, styles, and tokens in `< 1ms` without slow canvas roundtrips.
|
|
14
|
+
- **Binary IPC & Chunk Streaming**: Powered by **MessagePack** (`rmp-serde`) and progressive subtree chunking for instant transfers of massive design files.
|
|
15
|
+
- **Incremental Diff Updates**: Sub-millisecond live document sync (`upsert_node`) keeps the server index fresh as you edit in Figma.
|
|
16
|
+
- **Instant Design-to-Code (`figma_to_code`)**: Compiles Figma frames into clean, semantic components (**React + Tailwind**, **React Native**, **Vue 3 + Tailwind**, **HTML**, **SwiftUI**).
|
|
17
|
+
- **Design Token Exporter (`figma_get_tokens`)**: Exports variables and styles to **Tailwind config**, **CSS custom properties** (`:root` & dark mode), **TypeScript consts**, or **W3C DTCG Token Studio JSON**.
|
|
18
|
+
- **Batch Asset Extractor (`figma_export_assets` / `figma_export_asset`)**: Extracts SVG icons and raster images directly to project folders (`outputPath`) with auto-generated TypeScript barrel exports (`index.ts`) — zero chat token bloating.
|
|
19
|
+
- **Sandboxed JS Drawing Engine (`figma_write`)**: Powered by **Boa** (pure Rust ECMAScript engine) with built-in asset resolvers and 7 icon packs (*Ionicons, Lucide, Tabler, Bootstrap, Fluent, Phosphor*).
|
|
20
|
+
- **Multi-Tab / Multi-Session Support**: Seamlessly connects to multiple open Figma files simultaneously.
|
|
21
|
+
- **100% Localhost Privacy**: All communication stays strictly on `127.0.0.1:38451`.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 🏛️ Architecture & Zero-Touch Connection
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
┌────────────────────────────────────────────────────────────────────────┐
|
|
29
|
+
│ Terminal / Background Service │
|
|
30
|
+
│ figma-rust-mcp (Pure Rust Engine) │
|
|
31
|
+
│ • MCP Streamable HTTP (/mcp) & legacy SSE (/sse, /message) │
|
|
32
|
+
│ • Dynamic Runtime Server (/plugin/code.js, /plugin/ui.html) │
|
|
33
|
+
│ • In-Memory Fast Index (<1ms Lookups & Incremental Diffs) │
|
|
34
|
+
│ • Design-to-Code Compiler (React/Tailwind, Vue, RN, SwiftUI) │
|
|
35
|
+
│ • Design Token Transformer (CSS, Tailwind, TypeScript, W3C DTCG) │
|
|
36
|
+
│ • Sandboxed JS Runtime (Boa ECMAScript Engine) │
|
|
37
|
+
│ • Binary MessagePack & Progressive Subtree Chunk Receiver │
|
|
38
|
+
└───────────────▲────────────────────────────────────────▲───────────────┘
|
|
39
|
+
│ (ws://127.0.0.1:38451/ws) │ (http://127.0.0.1:38451/mcp)
|
|
40
|
+
│ (Dynamic Code Streaming & Hot-Reload) │ (JSON-RPC 2.0 / Streamable HTTP)
|
|
41
|
+
┌─────────┴─────────┐ ┌─────────┴─────────┐
|
|
42
|
+
│ Figma Desktop │ │ AI Assistant(s) │
|
|
43
|
+
│ (Thin Loader) │ │ Google Antigravity│
|
|
44
|
+
│ │ │ Cursor / Windsurf │
|
|
45
|
+
│ • Zero-Touch Sync │ │ Claude Code / Zed │
|
|
46
|
+
│ • Live Hot-Reload │ └───────────────────┘
|
|
47
|
+
│ • SVG/PNG Render │
|
|
48
|
+
└───────────────────┘
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 🔌 How the Zero-Touch Connection Works:
|
|
52
|
+
1. **Permanent Thin Loader**: You only import the Figma plugin **once** (`~/.figma-rust-mcp/plugin/manifest.json`).
|
|
53
|
+
2. **Dynamic Runtime Streaming**: Upon launch, the Thin Loader contacts `http://127.0.0.1:38451/plugin/code.js` to fetch and execute the latest runtime in memory.
|
|
54
|
+
3. **Live WebSocket Hot-Reload**: The plugin connects to `ws://127.0.0.1:38451/ws`. When you upgrade `figma-rust-mcp` or restart the daemon, the plugin automatically detects the new server version and hot-reloads seamlessly — **no need to re-import or restart the plugin in Figma**.
|
|
55
|
+
4. **Auto-Reconnect & Offline Buffer**: If Figma is opened before the Rust service starts, the plugin displays a waiting screen and connects automatically the instant the service is up.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 🚀 Quick Start
|
|
60
|
+
|
|
61
|
+
### 1. One-command setup with NPX (No Rust toolchain needed)
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npx -y figma-rust-mcp@latest --init
|
|
65
|
+
```
|
|
66
|
+
The setup detects installed Codex, Claude Code, Antigravity, Cursor, Windsurf,
|
|
67
|
+
VS Code/Copilot, and Zed clients. Choose an action from the menu:
|
|
68
|
+
|
|
69
|
+
```text
|
|
70
|
+
1) Quick setup — plugin + background service + detected agents
|
|
71
|
+
2) Install/update Figma plugin only
|
|
72
|
+
3) Start server in this terminal
|
|
73
|
+
4) Configure detected agents
|
|
74
|
+
5) Check background service
|
|
75
|
+
6) Upgrade package and refresh setup
|
|
76
|
+
7) Remove background service
|
|
77
|
+
0) Exit
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Choose **1** for the recommended setup. It downloads the platform binary,
|
|
81
|
+
installs the permanent plugin loader, starts the background service at login,
|
|
82
|
+
then lets you select detected agents (`a` for all, or comma-separated numbers)
|
|
83
|
+
and writes each client's MCP config while preserving existing servers. Restart
|
|
84
|
+
or reload those clients afterward. Then import the manifest into Figma once:
|
|
85
|
+
open **Plugins → Development → Import plugin from manifest...**, select
|
|
86
|
+
`~/.figma-rust-mcp/plugin/manifest.json`, and run **Figma Rust MCP Bridge**. Future
|
|
87
|
+
updates are streamed to the plugin automatically.
|
|
88
|
+
|
|
89
|
+
The runner automatically downloads the precompiled native binary for macOS
|
|
90
|
+
(Apple Silicon or Intel), Linux, or Windows. Use `--configure` as an alias for
|
|
91
|
+
`--init`.
|
|
92
|
+
|
|
93
|
+
For scripts and direct use, the individual options remain available:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npx -y figma-rust-mcp@latest --setup-plugin # install/update plugin
|
|
97
|
+
npx -y figma-rust-mcp@latest --install-service # plugin + background service
|
|
98
|
+
npx -y figma-rust-mcp@latest --service-status
|
|
99
|
+
npx -y figma-rust-mcp@latest --upgrade
|
|
100
|
+
npx -y figma-rust-mcp@latest --alias
|
|
101
|
+
npx -y figma-rust-mcp@latest --uninstall-service
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Run `npx -y figma-rust-mcp@latest` to launch the interactive server directly.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
### Windows background mode
|
|
109
|
+
|
|
110
|
+
Double-clicking `figma-rust-mcp.exe` starts the server in a detached process and closes
|
|
111
|
+
its launcher console. From PowerShell or Command Prompt, use:
|
|
112
|
+
|
|
113
|
+
```powershell
|
|
114
|
+
.\figma-rust-mcp.exe --background
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The server keeps running after the terminal closes. Logs are appended to
|
|
118
|
+
`%LOCALAPPDATA%\figma-rust-mcp\logs\server.log`. Use `--server` for the foreground
|
|
119
|
+
terminal dashboard, or `--stdio` for an MCP client subprocess.
|
|
120
|
+
|
|
121
|
+
`--install-service` through the npm runner configures background startup at login.
|
|
122
|
+
Re-run the installation command to update an existing Windows task. Removing the
|
|
123
|
+
task disables future login startup; stop an already detached server through Task
|
|
124
|
+
Manager (`figma-rust-mcp.exe`). The launcher console may appear briefly when opening
|
|
125
|
+
the executable; the server itself does not retain a console window.
|
|
126
|
+
|
|
127
|
+
### 2. Build from Source (Optional)
|
|
128
|
+
|
|
129
|
+
If you prefer building directly with the [Rust toolchain](https://rustup.rs/) (`cargo >= 1.80`):
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
git clone https://github.com/BuiHung1612/figma-mcp.git
|
|
133
|
+
cd figma-rust-mcp
|
|
134
|
+
cargo build --release
|
|
135
|
+
./target/release/figma-rust-mcp
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
### 3. Configure Your MCP Client
|
|
141
|
+
|
|
142
|
+
The `--init` quick setup can add the local server to detected clients. To
|
|
143
|
+
configure one manually, use the matching section below.
|
|
144
|
+
|
|
145
|
+
#### Codex and clients using Streamable HTTP (Recommended)
|
|
146
|
+
|
|
147
|
+
Use the `/mcp` endpoint. It accepts `POST` JSON-RPC requests directly:
|
|
148
|
+
|
|
149
|
+
```toml
|
|
150
|
+
[mcp_servers.figma-rust-mcp]
|
|
151
|
+
url = "http://127.0.0.1:38451/mcp"
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
For Codex CLI, the equivalent command is:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
codex mcp add figma-rust-mcp --url http://127.0.0.1:38451/mcp
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### Google Antigravity (SSE Transport)
|
|
161
|
+
Add to your `~/.gemini/config/mcp_config.json` or project `.agents/mcp_config.json`:
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"mcpServers": {
|
|
165
|
+
"figma-rust-mcp": {
|
|
166
|
+
"serverUrl": "http://127.0.0.1:38451/sse"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
#### Claude Code / Cursor / Windsurf / VS Code / Zed
|
|
173
|
+
|
|
174
|
+
These clients can use the Streamable HTTP `/mcp` endpoint:
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"mcpServers": {
|
|
178
|
+
"figma-rust-mcp": {
|
|
179
|
+
"url": "http://127.0.0.1:38451/mcp"
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
For Zed, place the server entry under `context_servers` in `settings.json`.
|
|
186
|
+
Alternatively, configure a stdio subprocess via NPX:
|
|
187
|
+
```json
|
|
188
|
+
{
|
|
189
|
+
"mcpServers": {
|
|
190
|
+
"figma-rust-mcp": {
|
|
191
|
+
"command": "npx",
|
|
192
|
+
"args": ["-y", "figma-rust-mcp", "--stdio"]
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### 6. Diagnose a stale Figma runtime
|
|
199
|
+
|
|
200
|
+
Check the runtime bundle currently served to Figma Desktop:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
curl http://127.0.0.1:38451/plugin/version
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
The response includes `version` and `runtimeHash`. If the hash changes after an
|
|
207
|
+
upgrade, the dynamic plugin runtime is refreshed automatically. Restart the
|
|
208
|
+
Figma plugin only if the reported hash does not change.
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## 🛠️ MCP Tools Reference
|
|
213
|
+
|
|
214
|
+
`figma-rust-mcp` provides **15 first-class MCP tools**:
|
|
215
|
+
|
|
216
|
+
### 1. `figma_status`
|
|
217
|
+
Checks live bridge connection status, connected Figma tabs/files, in-memory index health, queue length, and latency statistics.
|
|
218
|
+
|
|
219
|
+
### 2. `figma_inspect_node`
|
|
220
|
+
Inspects a specific node by ID or name, returning CSS styles, flex layout rules, tokens, typography, and fills in a clean format (served in `< 1ms` via in-memory index or direct bridge).
|
|
221
|
+
|
|
222
|
+
### 3. `figma_to_code`
|
|
223
|
+
Compiles any Figma node (Frame, Component, Section, or selection) directly into clean, production-ready component code.
|
|
224
|
+
- **`framework`**: `"react-tailwind"` (default), `"react-native"`, `"vue-tailwind"`, `"html"`, `"swiftui"`.
|
|
225
|
+
- **`outputPath`**: Directly saves the generated component to your codebase (e.g. `src/components/UserProfileCard.tsx`).
|
|
226
|
+
- **`componentName`**: Custom component name override.
|
|
227
|
+
|
|
228
|
+
### 4. `figma_get_tokens`
|
|
229
|
+
Exports Figma Variables (Design Tokens), Color Styles, Typography Styles, and Elevation/Shadow Styles directly into frontend code.
|
|
230
|
+
- **`format`**: `"tailwind"` (`tailwind.config.js` theme.extend), `"css"` (`:root` CSS custom properties with light/dark theme modes), `"typescript"` (`tokens.ts`), `"w3c"` (W3C DTCG Token Studio JSON), or `"json"`.
|
|
231
|
+
- **`outputPath`**: Writes directly to disk (e.g. `src/styles/tokens.css` or `tailwind.config.js`).
|
|
232
|
+
- **`collection`** / **`mode`** / **`prefix`**: Optional filters and naming prefixes.
|
|
233
|
+
|
|
234
|
+
Token exports use schema v2 and preserve full paint/effect stacks, alpha, gradient
|
|
235
|
+
transforms, collection modes and raw alias values. CSS, Tailwind, TypeScript and
|
|
236
|
+
JSON share one normalized model. The `w3c` output uses DTCG 2025.10 color,
|
|
237
|
+
dimension, gradient-stop and shadow values, with Figma-specific geometry and
|
|
238
|
+
unsupported values retained in `$extensions`.
|
|
239
|
+
|
|
240
|
+
Linear gradients on a node are projected using its actual dimensions. A diagonal
|
|
241
|
+
gradient style has no target aspect ratio: use `get_css` on its consuming node.
|
|
242
|
+
Radial/angular/diamond paints, unsupported blend modes and progressive blurs
|
|
243
|
+
retain their raw data and report diagnostics recommending SVG instead of emitting
|
|
244
|
+
approximate CSS. Unknown modes, unresolved aliases and sanitized name collisions
|
|
245
|
+
fail explicitly. CSS exports include non-default modes under `data-theme`
|
|
246
|
+
selectors; opacity/font-weight variables stay unitless.
|
|
247
|
+
|
|
248
|
+
The plugin UI badge is stamped from the build version and updated from the
|
|
249
|
+
connected server handshake. Package/Cargo/tag mismatches fail the build pipeline.
|
|
250
|
+
Run `npm run build:plugin` after changing plugin source, and `npm run test:tokens`
|
|
251
|
+
for the token/contract/version regression suite. Existing background servers need
|
|
252
|
+
a restart with the new binary to load the updated runtime.
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
### 5. `figma_get_selection`
|
|
256
|
+
Inspection of currently selected layers/frames, with shared-style compression when it reduces response size.
|
|
257
|
+
- **`detail`**: `"compact"` (default), `"minimal"`, `"full"`.
|
|
258
|
+
|
|
259
|
+
Compact/minimal `get_selection` and `get_design` responses may contain a root
|
|
260
|
+
`_compression` object with `version: 1` and a `styles` dictionary. For each node
|
|
261
|
+
with `styleRef`, merge `_compression.styles[node.styleRef]` into that node and
|
|
262
|
+
remove `styleRef`; remove root `_compression` to reconstruct the plugin payload
|
|
263
|
+
exactly. Style references are dictionary lookups, not inherited CSS. Payloads
|
|
264
|
+
with reserved-field collisions or no net byte savings stay inline. `detail: "full"` bypasses this Rust transformation and queries the plugin rather than a
|
|
265
|
+
compact selection cache. Plugin detail, visibility, precision, depth and node
|
|
266
|
+
budgets still determine the source payload; compression cannot restore fields
|
|
267
|
+
omitted there. Code generation continues to consume inline styles.
|
|
268
|
+
|
|
269
|
+
No token-reduction or AI-latency percentage is claimed without a tokenizer and
|
|
270
|
+
end-to-end benchmark on real designs.
|
|
271
|
+
- **`depth`**: Tree depth limit or `"full"`.
|
|
272
|
+
|
|
273
|
+
### 6. `figma_export_asset`
|
|
274
|
+
Exports any Figma node/layer directly into PNG, JPG, or SVG.
|
|
275
|
+
- **`outputPath`**: When specified (e.g. `src/assets/logo.png`), saves directly to disk and returns minimal JSON metadata instead of bloating context with large base64 strings.
|
|
276
|
+
- **`format`**: `"png"` (default), `"jpg"`, `"svg"`.
|
|
277
|
+
- **`scale`**: Scaling factor (default `2` for high-res).
|
|
278
|
+
|
|
279
|
+
### 7. `figma_export_assets`
|
|
280
|
+
Batch extracts all SVG icons and PNG images from a Figma frame/page directly into project directories.
|
|
281
|
+
- **`iconDir`**: Directory path for SVG icons (e.g. `src/assets/icons`).
|
|
282
|
+
- **`imageDir`**: Directory path for raster images (e.g. `public/images`).
|
|
283
|
+
- **`createBarrel`**: Automatically creates an `index.ts` barrel export file in `iconDir`.
|
|
284
|
+
|
|
285
|
+
### 8. `figma_index`
|
|
286
|
+
Instant `< 1ms` in-memory queries against pre-indexed Figma file structures.
|
|
287
|
+
- **`operation`**:
|
|
288
|
+
- `"status"`: View index health and node counts.
|
|
289
|
+
- `"search_nodes"`: Search nodes by text name, query, and type (`FRAME`, `TEXT`, `COMPONENT`, `INSTANCE`).
|
|
290
|
+
- `"get_node"`: Instant node lookup by ID.
|
|
291
|
+
- `"search_components"`: Find component sets and variants.
|
|
292
|
+
- `"search_styles"`: Find paint, text, and effect styles.
|
|
293
|
+
- `"search_variables"`: Find design token variables by name or collection.
|
|
297
294
|
- `"refresh"`: Trigger full background re-indexing of the canvas.
|
|
298
295
|
- `"subtree"`: Read/cache one `nodeId`, default depth 2 and 1000 nodes. Increase `depth` or `maxNodes` only for the section you need; check `meta` for truncation.
|
|
299
296
|
- `"typography"`: Rust-generated text/font table for one `nodeId`, with mixed-style runs preserved. Default limit 200 rows. Null font fields mean unknown/mixed, not a guessed default.
|
|
@@ -301,110 +298,110 @@ Instant `< 1ms` in-memory queries against pre-indexed Figma file structures.
|
|
|
301
298
|
`status` includes per-tab dispatch cache hits/misses, bridge calls and total bridge wait time, plus process-wide tool call counts and total/average milliseconds. Node changes invalidate related subtrees; style changes, unknown events and global writes invalidate the whole cache. Detailed subtree data is loaded on demand. The initial index remains shallow.
|
|
302
299
|
|
|
303
300
|
For typography verification, call `figma_verify_ui` with a text `nodeId` and browser `computedStyles` (`font-size` in px, numeric `font-weight`, `font-family`). Mixed text accepts `computedStyles.segments`, an ordered array of CSS objects matching the Figma runs. Size checks preserve fractional pixels.
|
|
304
|
-
|
|
305
|
-
### 9. `figma_read`
|
|
306
|
-
Universal reader for advanced queries:
|
|
307
|
-
- **Design-to-code**: `get_design_context`, `get_css`, `get_component_map`, `get_unmapped_components`.
|
|
308
|
-
- **Inspection & Hierarchy**: `get_selection`, `get_design`, `get_page_nodes`, `get_node_detail`, `scan_design`, `search_nodes`.
|
|
309
|
-
- **Design Systems**: `get_styles`, `get_variables`, `get_local_components`, `get_tokens`.
|
|
310
|
-
- **Visuals & Canvas**: `screenshot`, `export_svg`, `export_image`, `get_viewport`.
|
|
311
|
-
|
|
312
|
-
### 10. `figma_write`
|
|
313
|
-
Executes JavaScript draw commands inside the sandboxed VM to build or modify designs on the Figma canvas.
|
|
314
|
-
- Supports Auto-layout (`layoutMode`, `itemSpacing`, `padding`), typography, fills, strokes, corner radius, drop shadows, and component creation.
|
|
315
|
-
- Supports icon loading: `figma.loadIcon("ionicons", "heart", { size: 24, fill: "#ff4757" })`.
|
|
316
|
-
- Supports image insertion: `figma.loadImage(url, { width: 300, height: 200 })`.
|
|
317
|
-
- Supports Design Tokens: `createVariableCollection`, `createVariable`, `addVariableMode`, `applyVariable`.
|
|
318
|
-
- Supports Prototyping & Reactions: `setReactions`, `getReactions`, `setScrollBehavior`.
|
|
319
|
-
|
|
320
|
-
### 11. `figma_rules`
|
|
321
|
-
Audits the current Figma document and generates a complete design system rule sheet (color tokens, typography styles, variables, component catalog) in `< 1ms` from cache.
|
|
322
|
-
|
|
323
|
-
### 12. `figma_docs`
|
|
324
|
-
Fetches built-in documentation, design rules, layout guidelines, and code examples for `figma_write`.
|
|
325
|
-
- **`section`**: `"rules"` | `"layout"` | `"api"` | `"tokens"` | `"icons"`
|
|
326
|
-
|
|
327
|
-
### 13. `figma_verify_ui`
|
|
328
|
-
Validates and compares actual rendered HTML/React UI styles and layout against Figma design specifications.
|
|
329
|
-
- Checks dimensions, padding, flex gap, colors, border-radius, and typography.
|
|
330
|
-
- Returns an exact match percentage (`match_percentage`), discrepancy breakdown, and actionable CSS/Tailwind fixes.
|
|
331
|
-
- **`nodeId`** / **`nodeName`**: Target Figma node spec.
|
|
332
|
-
- **`computedStyles`**: Key-value pairs of computed CSS properties from browser/component inspection.
|
|
333
|
-
- **`url`** / **`selector`**: Contextual target URL or CSS selector inspected.
|
|
334
|
-
|
|
335
|
-
### 14. `figma_match_components`
|
|
336
|
-
Scans your local codebase directories (`src/components`, `components/ui`) to discover existing React/Vue components and matches them directly against Figma design layers, preventing duplicate component creation and ensuring reuse of existing design systems.
|
|
337
|
-
- **`projectDir`**: Base directory of your project (default: current directory `"."`).
|
|
338
|
-
- **`nodeId`**: Optional Figma node ID to check specific match against local components.
|
|
339
|
-
|
|
340
|
-
### 15. `figma_prepare_design`
|
|
341
|
-
**All-In-One Multimodal Grounding Pack for AI**: The ultimate single-call tool for code generation that eliminates missing UI elements and icon guesswork.
|
|
342
|
-
- Simultaneously extracts **100% of visible text elements** (greeting, badges, timestamps, labels).
|
|
343
|
-
- Automatically **exports all SVG vector icons** into your local project directory (`iconDir`) and provides exact TypeScript import statements.
|
|
344
|
-
- Captures high-res **visual canvas screenshots** saved locally for immediate multimodal LLM inspection.
|
|
345
|
-
- Discovers existing components in your codebase for direct reuse.
|
|
346
|
-
- Generates an actionable **Implementation Checklist** ensuring complete design fidelity in 1 single shot.
|
|
347
|
-
- **`nodeId`**: Target Figma screen/frame ID.
|
|
348
|
-
- **`iconDir`**: Target directory for SVG icons (e.g. `src/assets/icons` or `assets/images`).
|
|
349
|
-
- **`projectDir`**: Base directory for component discovery.
|
|
350
|
-
|
|
351
|
-
---
|
|
352
|
-
|
|
353
|
-
### Multiple tabs and frame tasks
|
|
354
|
-
|
|
355
|
-
Each plugin runtime has its own `sessionId`; tabs of the same file share a
|
|
356
|
-
`documentId`. Use `figma_status` to discover tabs. With multiple connected tabs,
|
|
357
|
-
pass an exact `sessionId`; the server rejects ambiguous routing.
|
|
358
|
-
|
|
359
|
-
For multiple agents editing one file, call `figma_task` with `action: "start"`,
|
|
360
|
-
`sessionId` and `frameId`, then pass the returned `taskId` on subsequent tools.
|
|
361
|
-
Each task reserves a separate FRAME directly under a PAGE or SECTION, without
|
|
362
|
-
shared component definitions. Writes stay inside that frame; global styles,
|
|
363
|
-
variables, page and selection changes are blocked. A frame cannot be reserved
|
|
364
|
-
twice, including across tabs of the same document. Release it with `figma_task`
|
|
365
|
-
using `action: "end"` and `taskId`; restart tasks after a plugin reload.
|
|
366
|
-
|
|
367
|
-
Tools on one tab run sequentially, including every awaited operation in a
|
|
368
|
-
`figma_write` call. Different tabs run independently. `npm run test:sessions`
|
|
369
|
-
(Node >=22) checks real WebSocket/HTTP transport with a simulated plugin canvas;
|
|
370
|
-
it does not replace validation in Figma Desktop.
|
|
371
|
-
|
|
372
|
-
### Startup indexing
|
|
373
|
-
|
|
374
|
-
Opening the bridge indexes top-level nodes on the active page and local tokens.
|
|
375
|
-
It does not preload every page or scan the document-wide component catalogue.
|
|
376
|
-
`figma_index` status exposes `components_indexed: false` until a full reindex;
|
|
377
|
-
this means deferred, not an empty catalogue. Live component queries populate
|
|
378
|
-
the Rust cache for subsequent reads while the index remains valid. Component reads/searches and rules
|
|
379
|
-
that require the complete catalogue fall back to a live query.
|
|
380
|
-
|
|
381
|
-
The plugin listens to active-page `nodechange` and global `stylechange` events,
|
|
382
|
-
and rebuilds the lightweight index when the active page changes. It does not
|
|
383
|
-
subscribe to document-wide node changes by preloading the whole file. Explicit
|
|
384
|
-
reindexing still includes all local components; discovery loads pages one at a
|
|
385
|
-
time and yields after at most 100 nodes or an 8ms traversal slice. Figma's native
|
|
386
|
-
page load itself cannot be interrupted by the plugin. Concurrent identical
|
|
387
|
-
index requests share one scan, and results from a previously active page are
|
|
388
|
-
not published as the current index.
|
|
389
|
-
|
|
390
|
-
## 💻 Development & Testing
|
|
391
|
-
|
|
392
|
-
```bash
|
|
393
|
-
# Run server in debug mode
|
|
394
|
-
cargo run
|
|
395
|
-
|
|
396
|
-
# Build optimized release binary
|
|
397
|
-
cargo build --release
|
|
398
|
-
|
|
399
|
-
# Run automated MCP test suite
|
|
400
|
-
./scripts/test-rust-mcp.sh
|
|
401
|
-
|
|
402
|
-
# Rebuild Figma plugin bundle (if plugin-src/ is modified)
|
|
403
|
-
node scripts/build-plugin.js
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
---
|
|
407
|
-
|
|
408
|
-
## 📄 License
|
|
409
|
-
|
|
410
|
-
MIT © [BuiHung1612](https://github.com/BuiHung1612) — Free to use, modify, and distribute. See [LICENSE](LICENSE) for details.
|
|
301
|
+
|
|
302
|
+
### 9. `figma_read`
|
|
303
|
+
Universal reader for advanced queries:
|
|
304
|
+
- **Design-to-code**: `get_design_context`, `get_css`, `get_component_map`, `get_unmapped_components`.
|
|
305
|
+
- **Inspection & Hierarchy**: `get_selection`, `get_design`, `get_page_nodes`, `get_node_detail`, `scan_design`, `search_nodes`.
|
|
306
|
+
- **Design Systems**: `get_styles`, `get_variables`, `get_local_components`, `get_tokens`.
|
|
307
|
+
- **Visuals & Canvas**: `screenshot`, `export_svg`, `export_image`, `get_viewport`.
|
|
308
|
+
|
|
309
|
+
### 10. `figma_write`
|
|
310
|
+
Executes JavaScript draw commands inside the sandboxed VM to build or modify designs on the Figma canvas.
|
|
311
|
+
- Supports Auto-layout (`layoutMode`, `itemSpacing`, `padding`), typography, fills, strokes, corner radius, drop shadows, and component creation.
|
|
312
|
+
- Supports icon loading: `figma.loadIcon("ionicons", "heart", { size: 24, fill: "#ff4757" })`.
|
|
313
|
+
- Supports image insertion: `figma.loadImage(url, { width: 300, height: 200 })`.
|
|
314
|
+
- Supports Design Tokens: `createVariableCollection`, `createVariable`, `addVariableMode`, `applyVariable`.
|
|
315
|
+
- Supports Prototyping & Reactions: `setReactions`, `getReactions`, `setScrollBehavior`.
|
|
316
|
+
|
|
317
|
+
### 11. `figma_rules`
|
|
318
|
+
Audits the current Figma document and generates a complete design system rule sheet (color tokens, typography styles, variables, component catalog) in `< 1ms` from cache.
|
|
319
|
+
|
|
320
|
+
### 12. `figma_docs`
|
|
321
|
+
Fetches built-in documentation, design rules, layout guidelines, and code examples for `figma_write`.
|
|
322
|
+
- **`section`**: `"rules"` | `"layout"` | `"api"` | `"tokens"` | `"icons"`
|
|
323
|
+
|
|
324
|
+
### 13. `figma_verify_ui`
|
|
325
|
+
Validates and compares actual rendered HTML/React UI styles and layout against Figma design specifications.
|
|
326
|
+
- Checks dimensions, padding, flex gap, colors, border-radius, and typography.
|
|
327
|
+
- Returns an exact match percentage (`match_percentage`), discrepancy breakdown, and actionable CSS/Tailwind fixes.
|
|
328
|
+
- **`nodeId`** / **`nodeName`**: Target Figma node spec.
|
|
329
|
+
- **`computedStyles`**: Key-value pairs of computed CSS properties from browser/component inspection.
|
|
330
|
+
- **`url`** / **`selector`**: Contextual target URL or CSS selector inspected.
|
|
331
|
+
|
|
332
|
+
### 14. `figma_match_components`
|
|
333
|
+
Scans your local codebase directories (`src/components`, `components/ui`) to discover existing React/Vue components and matches them directly against Figma design layers, preventing duplicate component creation and ensuring reuse of existing design systems.
|
|
334
|
+
- **`projectDir`**: Base directory of your project (default: current directory `"."`).
|
|
335
|
+
- **`nodeId`**: Optional Figma node ID to check specific match against local components.
|
|
336
|
+
|
|
337
|
+
### 15. `figma_prepare_design`
|
|
338
|
+
**All-In-One Multimodal Grounding Pack for AI**: The ultimate single-call tool for code generation that eliminates missing UI elements and icon guesswork.
|
|
339
|
+
- Simultaneously extracts **100% of visible text elements** (greeting, badges, timestamps, labels).
|
|
340
|
+
- Automatically **exports all SVG vector icons** into your local project directory (`iconDir`) and provides exact TypeScript import statements.
|
|
341
|
+
- Captures high-res **visual canvas screenshots** saved locally for immediate multimodal LLM inspection.
|
|
342
|
+
- Discovers existing components in your codebase for direct reuse.
|
|
343
|
+
- Generates an actionable **Implementation Checklist** ensuring complete design fidelity in 1 single shot.
|
|
344
|
+
- **`nodeId`**: Target Figma screen/frame ID.
|
|
345
|
+
- **`iconDir`**: Target directory for SVG icons (e.g. `src/assets/icons` or `assets/images`).
|
|
346
|
+
- **`projectDir`**: Base directory for component discovery.
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
### Multiple tabs and frame tasks
|
|
351
|
+
|
|
352
|
+
Each plugin runtime has its own `sessionId`; tabs of the same file share a
|
|
353
|
+
`documentId`. Use `figma_status` to discover tabs. With multiple connected tabs,
|
|
354
|
+
pass an exact `sessionId`; the server rejects ambiguous routing.
|
|
355
|
+
|
|
356
|
+
For multiple agents editing one file, call `figma_task` with `action: "start"`,
|
|
357
|
+
`sessionId` and `frameId`, then pass the returned `taskId` on subsequent tools.
|
|
358
|
+
Each task reserves a separate FRAME directly under a PAGE or SECTION, without
|
|
359
|
+
shared component definitions. Writes stay inside that frame; global styles,
|
|
360
|
+
variables, page and selection changes are blocked. A frame cannot be reserved
|
|
361
|
+
twice, including across tabs of the same document. Release it with `figma_task`
|
|
362
|
+
using `action: "end"` and `taskId`; restart tasks after a plugin reload.
|
|
363
|
+
|
|
364
|
+
Tools on one tab run sequentially, including every awaited operation in a
|
|
365
|
+
`figma_write` call. Different tabs run independently. `npm run test:sessions`
|
|
366
|
+
(Node >=22) checks real WebSocket/HTTP transport with a simulated plugin canvas;
|
|
367
|
+
it does not replace validation in Figma Desktop.
|
|
368
|
+
|
|
369
|
+
### Startup indexing
|
|
370
|
+
|
|
371
|
+
Opening the bridge indexes top-level nodes on the active page and local tokens.
|
|
372
|
+
It does not preload every page or scan the document-wide component catalogue.
|
|
373
|
+
`figma_index` status exposes `components_indexed: false` until a full reindex;
|
|
374
|
+
this means deferred, not an empty catalogue. Live component queries populate
|
|
375
|
+
the Rust cache for subsequent reads while the index remains valid. Component reads/searches and rules
|
|
376
|
+
that require the complete catalogue fall back to a live query.
|
|
377
|
+
|
|
378
|
+
The plugin listens to active-page `nodechange` and global `stylechange` events,
|
|
379
|
+
and rebuilds the lightweight index when the active page changes. It does not
|
|
380
|
+
subscribe to document-wide node changes by preloading the whole file. Explicit
|
|
381
|
+
reindexing still includes all local components; discovery loads pages one at a
|
|
382
|
+
time and yields after at most 100 nodes or an 8ms traversal slice. Figma's native
|
|
383
|
+
page load itself cannot be interrupted by the plugin. Concurrent identical
|
|
384
|
+
index requests share one scan, and results from a previously active page are
|
|
385
|
+
not published as the current index.
|
|
386
|
+
|
|
387
|
+
## 💻 Development & Testing
|
|
388
|
+
|
|
389
|
+
```bash
|
|
390
|
+
# Run server in debug mode
|
|
391
|
+
cargo run
|
|
392
|
+
|
|
393
|
+
# Build optimized release binary
|
|
394
|
+
cargo build --release
|
|
395
|
+
|
|
396
|
+
# Run automated MCP test suite
|
|
397
|
+
./scripts/test-rust-mcp.sh
|
|
398
|
+
|
|
399
|
+
# Rebuild Figma plugin bundle (if plugin-src/ is modified)
|
|
400
|
+
node scripts/build-plugin.js
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
---
|
|
404
|
+
|
|
405
|
+
## 📄 License
|
|
406
|
+
|
|
407
|
+
MIT © [BuiHung1612](https://github.com/BuiHung1612) — Free to use, modify, and distribute. See [LICENSE](LICENSE) for details.
|