mcp-figma-toolkit 1.0.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/LICENSE +21 -0
- package/README.md +444 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +530 -0
- package/dist/server.js.map +1 -0
- package/package.json +57 -0
- package/plugin/manifest.json +12 -0
- package/plugin/plugin.js +1311 -0
- package/plugin/ui.html +30 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Figma MCP Write Bridge Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
# MCP Figma Toolkit
|
|
2
|
+
|
|
3
|
+
An MCP server that lets AI agents design in Figma. Create shapes, text, components, styles, variables, and more.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/mcp-figma-toolkit)
|
|
6
|
+
|
|
7
|
+
## How It Works
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
Your AI Assistant ←→ MCP Server ←→ Figma Plugin ←→ Figma Document
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The MCP server communicates with a Figma plugin via WebSocket. Your AI client (Claude Code, VS Code, Cursor) connects to the MCP server and can then create and manipulate designs in Figma.
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# 1. Install globally
|
|
19
|
+
npm install -g mcp-figma-toolkit
|
|
20
|
+
|
|
21
|
+
# 2. Find where the plugin was installed
|
|
22
|
+
npm root -g
|
|
23
|
+
# Note the path, e.g., /Users/you/.nvm/versions/node/v20/lib/node_modules
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then:
|
|
27
|
+
1. Open Figma → **Plugins** → **Development** → **Import plugin from manifest**
|
|
28
|
+
2. Navigate to `<path-from-above>/mcp-figma-toolkit/plugin/manifest.json`
|
|
29
|
+
3. Add the MCP server to your AI client config (see [Configuration](#configuration))
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
### Prerequisites
|
|
34
|
+
|
|
35
|
+
- [Node.js 18+](https://nodejs.org)
|
|
36
|
+
- [Figma Desktop App](https://figma.com/downloads)
|
|
37
|
+
- An MCP-compatible AI client (Claude Code, VS Code with Copilot, Cursor)
|
|
38
|
+
|
|
39
|
+
### Step 1: Install the Package
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install -g mcp-figma-toolkit
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Step 2: Import the Figma Plugin
|
|
46
|
+
|
|
47
|
+
The plugin files are bundled with the npm package. You need to import them into Figma once.
|
|
48
|
+
|
|
49
|
+
**Find the plugin location:**
|
|
50
|
+
|
|
51
|
+
macOS / Linux:
|
|
52
|
+
```bash
|
|
53
|
+
echo "$(npm root -g)/mcp-figma-toolkit/plugin"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Windows (PowerShell):
|
|
57
|
+
```powershell
|
|
58
|
+
echo "$(npm root -g)\mcp-figma-toolkit\plugin"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Import into Figma:**
|
|
62
|
+
|
|
63
|
+
1. Open Figma Desktop
|
|
64
|
+
2. Click the Figma menu (top-left) → **Plugins** → **Development** → **Import plugin from manifest...**
|
|
65
|
+
3. Navigate to the plugin folder from above
|
|
66
|
+
4. Select `manifest.json` and click **Open**
|
|
67
|
+
|
|
68
|
+
The plugin "MCP Figma Toolkit" should now appear under **Plugins → Development**.
|
|
69
|
+
|
|
70
|
+
### Alternative: Clone from Source
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
git clone https://github.com/dmytro-zemliak/mcp-figma-toolkit.git
|
|
74
|
+
cd mcp-figma-toolkit
|
|
75
|
+
npm install
|
|
76
|
+
npm run build
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Then import the plugin from the `plugin/` folder.
|
|
80
|
+
|
|
81
|
+
## Configuration
|
|
82
|
+
|
|
83
|
+
Add the MCP server to your AI client's configuration file.
|
|
84
|
+
|
|
85
|
+
### Claude Code
|
|
86
|
+
|
|
87
|
+
Edit `~/.claude.json` (macOS/Linux) or `%USERPROFILE%\.claude.json` (Windows):
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"mcpServers": {
|
|
92
|
+
"figma": {
|
|
93
|
+
"command": "mcp-figma-toolkit"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### VS Code / Cursor
|
|
100
|
+
|
|
101
|
+
Create `.vscode/mcp.json` in your project:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"mcpServers": {
|
|
106
|
+
"figma": {
|
|
107
|
+
"command": "mcp-figma-toolkit"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Using npx (No Global Install)
|
|
114
|
+
|
|
115
|
+
If you prefer not to install globally:
|
|
116
|
+
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"mcpServers": {
|
|
120
|
+
"figma": {
|
|
121
|
+
"command": "npx",
|
|
122
|
+
"args": ["mcp-figma-toolkit"]
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Usage
|
|
129
|
+
|
|
130
|
+
### Starting a Design Session
|
|
131
|
+
|
|
132
|
+
1. **Open Figma** and create or open a document
|
|
133
|
+
|
|
134
|
+
2. **Run the plugin**: **Plugins** → **Development** → **MCP Figma Toolkit**
|
|
135
|
+
|
|
136
|
+
The plugin window is hidden but establishes the connection.
|
|
137
|
+
|
|
138
|
+
3. **Start your AI client** (Claude Code, VS Code, etc.)
|
|
139
|
+
|
|
140
|
+
The MCP server starts automatically when your AI client launches.
|
|
141
|
+
|
|
142
|
+
4. **Design with AI!** Ask your assistant to create designs:
|
|
143
|
+
|
|
144
|
+
> "Create a blue button with rounded corners and white text saying 'Get Started'"
|
|
145
|
+
|
|
146
|
+
> "Design a card component with an image, title, and description"
|
|
147
|
+
|
|
148
|
+
> "Set up a color system with primary, secondary, and neutral colors"
|
|
149
|
+
|
|
150
|
+
> "Create a mobile login screen with email and password fields"
|
|
151
|
+
|
|
152
|
+
### Session Workflow
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
┌─────────────────────────────────────────────────────────┐
|
|
156
|
+
│ 1. Open Figma document │
|
|
157
|
+
│ 2. Run plugin (Plugins → Development → MCP Figma...) │
|
|
158
|
+
│ 3. Use your AI client to design │
|
|
159
|
+
│ 4. Plugin stays connected until you close Figma │
|
|
160
|
+
└─────────────────────────────────────────────────────────┘
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**Note:** You need to run the Figma plugin each time you open a new Figma document.
|
|
164
|
+
|
|
165
|
+
## Features
|
|
166
|
+
|
|
167
|
+
### Creation
|
|
168
|
+
- Frames, rectangles, ellipses, lines, polygons, stars
|
|
169
|
+
- Text with custom fonts and styling
|
|
170
|
+
- Images from URL or base64
|
|
171
|
+
- Vector icons from SVG
|
|
172
|
+
|
|
173
|
+
### Styling
|
|
174
|
+
- Solid and gradient fills/strokes
|
|
175
|
+
- Corner radius, opacity, blend modes
|
|
176
|
+
- Drop shadows, inner shadows, blurs
|
|
177
|
+
- Layout grids
|
|
178
|
+
|
|
179
|
+
### Layout
|
|
180
|
+
- Auto Layout (direction, spacing, padding, alignment)
|
|
181
|
+
- Constraints
|
|
182
|
+
|
|
183
|
+
### Variables (Design Tokens)
|
|
184
|
+
- Variable collections with modes (Light/Dark)
|
|
185
|
+
- COLOR, FLOAT, STRING, BOOLEAN types
|
|
186
|
+
- Bind variables to node properties
|
|
187
|
+
|
|
188
|
+
### Styles
|
|
189
|
+
- Reusable text styles
|
|
190
|
+
- Reusable effect styles
|
|
191
|
+
|
|
192
|
+
### Components
|
|
193
|
+
- Create components from nodes
|
|
194
|
+
- Component sets (variants)
|
|
195
|
+
- Component properties (text, boolean, instance swap)
|
|
196
|
+
- Instances
|
|
197
|
+
|
|
198
|
+
### Other
|
|
199
|
+
- Boolean operations (union, subtract, intersect, exclude)
|
|
200
|
+
- Export as PNG, JPG, SVG
|
|
201
|
+
- Plugin data storage
|
|
202
|
+
|
|
203
|
+
## Available Tools
|
|
204
|
+
|
|
205
|
+
<details>
|
|
206
|
+
<summary><strong>Creation Tools</strong></summary>
|
|
207
|
+
|
|
208
|
+
| Tool | Description |
|
|
209
|
+
|------|-------------|
|
|
210
|
+
| `create_frame` | Create a frame with optional parent |
|
|
211
|
+
| `create_rectangle` | Create a rectangle |
|
|
212
|
+
| `create_ellipse` | Create an ellipse/circle |
|
|
213
|
+
| `create_line` | Create a line |
|
|
214
|
+
| `create_polygon` | Create a polygon |
|
|
215
|
+
| `create_star` | Create a star |
|
|
216
|
+
| `add_text` | Add text with font styling |
|
|
217
|
+
| `place_image_url` | Place image from URL |
|
|
218
|
+
| `place_image_base64` | Place image from base64 |
|
|
219
|
+
| `create_vector` | Create vector from SVG |
|
|
220
|
+
|
|
221
|
+
</details>
|
|
222
|
+
|
|
223
|
+
<details>
|
|
224
|
+
<summary><strong>Node Management</strong></summary>
|
|
225
|
+
|
|
226
|
+
| Tool | Description |
|
|
227
|
+
|------|-------------|
|
|
228
|
+
| `find_nodes` | Find nodes by name/type |
|
|
229
|
+
| `select_nodes` | Select nodes |
|
|
230
|
+
| `get_selection` | Get current selection |
|
|
231
|
+
| `rename_node` | Rename a node |
|
|
232
|
+
| `delete_node` | Delete a node |
|
|
233
|
+
| `duplicate_node` | Duplicate a node |
|
|
234
|
+
| `resize_node` | Resize a node |
|
|
235
|
+
| `rotate_node` | Rotate a node |
|
|
236
|
+
| `set_position` | Set position |
|
|
237
|
+
| `group_nodes` | Group nodes |
|
|
238
|
+
| `ungroup` | Ungroup |
|
|
239
|
+
| `create_page` | Create a page |
|
|
240
|
+
| `set_current_page` | Switch page |
|
|
241
|
+
|
|
242
|
+
</details>
|
|
243
|
+
|
|
244
|
+
<details>
|
|
245
|
+
<summary><strong>Styling</strong></summary>
|
|
246
|
+
|
|
247
|
+
| Tool | Description |
|
|
248
|
+
|------|-------------|
|
|
249
|
+
| `set_fill` | Set solid fill |
|
|
250
|
+
| `set_gradient_fill` | Set gradient fill |
|
|
251
|
+
| `set_stroke` | Set stroke |
|
|
252
|
+
| `set_gradient_stroke` | Set gradient stroke |
|
|
253
|
+
| `set_corner_radius` | Set corner radius |
|
|
254
|
+
| `set_opacity` | Set opacity |
|
|
255
|
+
| `set_blend_mode` | Set blend mode |
|
|
256
|
+
| `add_effect` | Add shadow/blur |
|
|
257
|
+
| `clear_effects` | Remove effects |
|
|
258
|
+
|
|
259
|
+
</details>
|
|
260
|
+
|
|
261
|
+
<details>
|
|
262
|
+
<summary><strong>Layout</strong></summary>
|
|
263
|
+
|
|
264
|
+
| Tool | Description |
|
|
265
|
+
|------|-------------|
|
|
266
|
+
| `set_auto_layout` | Configure Auto Layout |
|
|
267
|
+
| `set_constraints` | Set constraints |
|
|
268
|
+
| `layout_grid_add` | Add layout grid |
|
|
269
|
+
| `layout_grid_clear` | Clear grids |
|
|
270
|
+
|
|
271
|
+
</details>
|
|
272
|
+
|
|
273
|
+
<details>
|
|
274
|
+
<summary><strong>Text</strong></summary>
|
|
275
|
+
|
|
276
|
+
| Tool | Description |
|
|
277
|
+
|------|-------------|
|
|
278
|
+
| `set_text_content` | Edit text |
|
|
279
|
+
| `set_text_style` | Set font/size/spacing |
|
|
280
|
+
| `set_text_color` | Set text color |
|
|
281
|
+
| `set_text_gradient` | Set text gradient |
|
|
282
|
+
|
|
283
|
+
</details>
|
|
284
|
+
|
|
285
|
+
<details>
|
|
286
|
+
<summary><strong>Variables</strong></summary>
|
|
287
|
+
|
|
288
|
+
| Tool | Description |
|
|
289
|
+
|------|-------------|
|
|
290
|
+
| `create_variable_collection` | Create collection |
|
|
291
|
+
| `create_variable` | Create variable |
|
|
292
|
+
| `get_local_variable_collections` | List collections |
|
|
293
|
+
| `get_local_variables` | List variables |
|
|
294
|
+
| `set_variable_value` | Update value |
|
|
295
|
+
| `bind_variable` | Bind to property |
|
|
296
|
+
| `unbind_variable` | Remove binding |
|
|
297
|
+
| `delete_variable` | Delete variable |
|
|
298
|
+
| `delete_variable_collection` | Delete collection |
|
|
299
|
+
|
|
300
|
+
</details>
|
|
301
|
+
|
|
302
|
+
<details>
|
|
303
|
+
<summary><strong>Styles</strong></summary>
|
|
304
|
+
|
|
305
|
+
| Tool | Description |
|
|
306
|
+
|------|-------------|
|
|
307
|
+
| `create_text_style` | Create text style |
|
|
308
|
+
| `create_effect_style` | Create effect style |
|
|
309
|
+
| `get_local_text_styles` | List text styles |
|
|
310
|
+
| `get_local_effect_styles` | List effect styles |
|
|
311
|
+
| `apply_text_style` | Apply text style |
|
|
312
|
+
| `apply_effect_style` | Apply effect style |
|
|
313
|
+
| `update_text_style` | Update text style |
|
|
314
|
+
| `update_effect_style` | Update effect style |
|
|
315
|
+
| `delete_style` | Delete style |
|
|
316
|
+
|
|
317
|
+
</details>
|
|
318
|
+
|
|
319
|
+
<details>
|
|
320
|
+
<summary><strong>Components</strong></summary>
|
|
321
|
+
|
|
322
|
+
| Tool | Description |
|
|
323
|
+
|------|-------------|
|
|
324
|
+
| `create_component` | Create empty component |
|
|
325
|
+
| `create_component_from_node` | Convert to component |
|
|
326
|
+
| `create_component_set` | Create variant set |
|
|
327
|
+
| `create_instance` | Create instance |
|
|
328
|
+
| `detach_instance` | Detach instance |
|
|
329
|
+
| `add_component_property` | Add property |
|
|
330
|
+
| `set_instance_property` | Set property |
|
|
331
|
+
| `get_component_properties` | Get properties |
|
|
332
|
+
|
|
333
|
+
</details>
|
|
334
|
+
|
|
335
|
+
<details>
|
|
336
|
+
<summary><strong>Advanced</strong></summary>
|
|
337
|
+
|
|
338
|
+
| Tool | Description |
|
|
339
|
+
|------|-------------|
|
|
340
|
+
| `boolean_op` | Boolean operations |
|
|
341
|
+
| `export_node` | Export as image |
|
|
342
|
+
| `set_plugin_data` | Store data |
|
|
343
|
+
| `get_plugin_data` | Retrieve data |
|
|
344
|
+
| `set_properties` | Batch set properties |
|
|
345
|
+
|
|
346
|
+
</details>
|
|
347
|
+
|
|
348
|
+
## SVG Icons
|
|
349
|
+
|
|
350
|
+
The `create_vector` tool supports two modes:
|
|
351
|
+
|
|
352
|
+
### Full SVG (Recommended)
|
|
353
|
+
|
|
354
|
+
Use `svgString` for any SVG, including those with arcs, circles, and complex shapes:
|
|
355
|
+
|
|
356
|
+
```json
|
|
357
|
+
{
|
|
358
|
+
"svgString": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">...</svg>",
|
|
359
|
+
"width": 24,
|
|
360
|
+
"height": 24,
|
|
361
|
+
"name": "icon"
|
|
362
|
+
}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### Path Data Only
|
|
366
|
+
|
|
367
|
+
Use `pathData` for simple paths (no arcs):
|
|
368
|
+
|
|
369
|
+
```json
|
|
370
|
+
{
|
|
371
|
+
"pathData": "M20 6L9 17l-5-5",
|
|
372
|
+
"width": 24,
|
|
373
|
+
"height": 24,
|
|
374
|
+
"strokeHex": "#000000",
|
|
375
|
+
"strokeWeight": 2
|
|
376
|
+
}
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
**Icon Library Compatibility:**
|
|
380
|
+
|
|
381
|
+
| Library | Recommended Mode |
|
|
382
|
+
|---------|------------------|
|
|
383
|
+
| Heroicons | `pathData` or `svgString` |
|
|
384
|
+
| Lucide | `svgString` (uses arcs) |
|
|
385
|
+
| Feather | `svgString` (uses circles) |
|
|
386
|
+
|
|
387
|
+
## Troubleshooting
|
|
388
|
+
|
|
389
|
+
| Problem | Solution |
|
|
390
|
+
|---------|----------|
|
|
391
|
+
| "Figma plugin not connected" | Run the plugin in Figma: **Plugins → Development → MCP Figma Toolkit** |
|
|
392
|
+
| `mcp-figma-toolkit: command not found` | Run `npm install -g mcp-figma-toolkit` |
|
|
393
|
+
| Port 3055 in use | Kill existing process: `lsof -ti:3055 \| xargs kill -9` (macOS) |
|
|
394
|
+
| Plugin not in Figma menu | Re-import `manifest.json` via **Plugins → Development → Import plugin from manifest** |
|
|
395
|
+
| Font errors | Ensure the font is installed on your system and available in Figma |
|
|
396
|
+
|
|
397
|
+
## Development
|
|
398
|
+
|
|
399
|
+
### Project Structure
|
|
400
|
+
|
|
401
|
+
```
|
|
402
|
+
mcp-figma-toolkit/
|
|
403
|
+
├── server.ts # MCP server (TypeScript source)
|
|
404
|
+
├── dist/ # Compiled JavaScript
|
|
405
|
+
├── plugin/
|
|
406
|
+
│ ├── plugin.js # Figma plugin
|
|
407
|
+
│ ├── ui.html # WebSocket bridge
|
|
408
|
+
│ └── manifest.json # Plugin manifest
|
|
409
|
+
├── package.json
|
|
410
|
+
└── tsconfig.json
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### Building
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
npm install
|
|
417
|
+
npm run build # Compile TypeScript
|
|
418
|
+
npm run dev # Run with tsx (development)
|
|
419
|
+
npm start # Run compiled version
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### Adding Tools
|
|
423
|
+
|
|
424
|
+
1. Add action handler in `plugin/plugin.js`
|
|
425
|
+
2. Add case in `handleAction()` switch
|
|
426
|
+
3. Register tool in `server.ts` with Zod schema
|
|
427
|
+
4. Rebuild: `npm run build`
|
|
428
|
+
|
|
429
|
+
## Limitations
|
|
430
|
+
|
|
431
|
+
- One Figma document connection at a time
|
|
432
|
+
- 20-second timeout per operation
|
|
433
|
+
- Multiple variable modes (Light/Dark) require Figma paid plan
|
|
434
|
+
- SVG `pathData` doesn't support arc commands (use `svgString` instead)
|
|
435
|
+
|
|
436
|
+
## License
|
|
437
|
+
|
|
438
|
+
MIT
|
|
439
|
+
|
|
440
|
+
## Acknowledgments
|
|
441
|
+
|
|
442
|
+
- Originally forked from [firasmj/Figma-MCP-Write-Bridge](https://github.com/firasmj/Figma-MCP-Write-Bridge)
|
|
443
|
+
- Built with [Model Context Protocol SDK](https://github.com/modelcontextprotocol)
|
|
444
|
+
- Uses [Figma Plugin API](https://www.figma.com/plugin-docs/)
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../server.ts"],"names":[],"mappings":""}
|