@biolab/talk-to-figma 0.3.3 → 0.4.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 +116 -199
- package/dist/cli.cjs +2780 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.js +2760 -0
- package/dist/cli.js.map +1 -0
- package/dist/relay.cjs +159 -0
- package/dist/relay.cjs.map +1 -0
- package/dist/relay.d.cts +4 -0
- package/dist/relay.d.ts +4 -0
- package/dist/relay.js +136 -0
- package/dist/relay.js.map +1 -0
- package/dist/talk_to_figma_mcp/server.cjs.map +1 -0
- package/dist/talk_to_figma_mcp/server.d.cts +1 -0
- package/dist/talk_to_figma_mcp/server.d.ts +1 -0
- package/dist/talk_to_figma_mcp/server.js.map +1 -0
- package/figma-plugin/code.js +4340 -0
- package/figma-plugin/figma-plugin.zip +0 -0
- package/figma-plugin/manifest.json +23 -0
- package/figma-plugin/setcharacters.js +215 -0
- package/figma-plugin/ui.html +834 -0
- package/package.json +5 -3
- package/dist/server.cjs.map +0 -1
- package/dist/server.js.map +0 -1
- /package/dist/{server.d.cts → cli.d.cts} +0 -0
- /package/dist/{server.d.ts → cli.d.ts} +0 -0
- /package/dist/{server.cjs → talk_to_figma_mcp/server.cjs} +0 -0
- /package/dist/{server.js → talk_to_figma_mcp/server.js} +0 -0
package/README.md
CHANGED
|
@@ -1,262 +1,179 @@
|
|
|
1
1
|
# Talk to Figma MCP
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
MCP server that lets AI agents (Cursor, Claude Code) read and modify Figma designs programmatically.
|
|
4
4
|
|
|
5
|
-
https://github.com/user-attachments/assets/129a14d2-ed73-470f-9a4c-2240b2a4885c
|
|
6
|
-
|
|
7
|
-
## Project Structure
|
|
8
|
-
|
|
9
|
-
- `src/talk_to_figma_mcp/` - TypeScript MCP server for Figma integration
|
|
10
|
-
- `src/cursor_mcp_plugin/` - Figma plugin for communicating with Cursor
|
|
11
|
-
- `src/socket.ts` - WebSocket server that facilitates communication between the MCP server and Figma plugin
|
|
12
|
-
|
|
13
|
-
## How to use
|
|
14
|
-
|
|
15
|
-
1. Install Bun if you haven't already:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
curl -fsSL https://bun.sh/install | bash
|
|
19
5
|
```
|
|
20
|
-
|
|
21
|
-
2. Run setup, this will also install MCP in your Cursor's active project
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
bun setup
|
|
6
|
+
AI Agent ←(stdio)→ MCP Server ←(WebSocket)→ WebSocket Relay ←(WebSocket)→ Figma Plugin
|
|
25
7
|
```
|
|
26
8
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
bun socket
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
4. **NEW** Install Figma plugin from [Figma community page](https://www.figma.com/community/plugin/1485687494525374295/cursor-talk-to-figma-mcp-plugin) or [install locally](#figma-plugin)
|
|
34
|
-
|
|
35
|
-
## Quick Video Tutorial
|
|
9
|
+
## Setup
|
|
36
10
|
|
|
37
|
-
|
|
11
|
+
### Prerequisites
|
|
38
12
|
|
|
39
|
-
|
|
13
|
+
- [Bun](https://bun.sh) runtime
|
|
14
|
+
- Figma desktop app
|
|
40
15
|
|
|
41
|
-
|
|
16
|
+
### 1. Add MCP server
|
|
42
17
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
**Instance Override Propagation**
|
|
46
|
-
Another contribution from [@dusskapark](https://github.com/dusskapark)
|
|
47
|
-
Propagate component instance overrides from a source instance to multiple target instances with a single command. This feature dramatically reduces repetitive design work when working with component instances that need similar customizations. Check out our [demo video](https://youtu.be/uvuT8LByroI).
|
|
48
|
-
|
|
49
|
-
## Manual Setup and Installation
|
|
50
|
-
|
|
51
|
-
### MCP Server: Integration with Cursor
|
|
52
|
-
|
|
53
|
-
Add the server to your Cursor MCP configuration in `~/.cursor/mcp.json`:
|
|
18
|
+
**Cursor** — add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
|
|
54
19
|
|
|
55
20
|
```json
|
|
56
21
|
{
|
|
57
22
|
"mcpServers": {
|
|
58
23
|
"TalkToFigma": {
|
|
59
24
|
"command": "bunx",
|
|
60
|
-
"args": ["
|
|
25
|
+
"args": ["@biolab/talk-to-figma@latest"]
|
|
61
26
|
}
|
|
62
27
|
}
|
|
63
28
|
}
|
|
64
29
|
```
|
|
65
30
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Start the WebSocket server:
|
|
31
|
+
**Claude Code** — add to `.mcp.json` in your project root, or via CLI:
|
|
69
32
|
|
|
70
33
|
```bash
|
|
71
|
-
|
|
34
|
+
claude mcp add TalkToFigma -- bunx @biolab/talk-to-figma@latest
|
|
72
35
|
```
|
|
73
36
|
|
|
74
|
-
###
|
|
75
|
-
|
|
76
|
-
1. In Figma, go to Plugins > Development > New Plugin
|
|
77
|
-
2. Choose "Link existing plugin"
|
|
78
|
-
3. Select the `src/cursor_mcp_plugin/manifest.json` file
|
|
79
|
-
4. The plugin should now be available in your Figma development plugins
|
|
80
|
-
|
|
81
|
-
## Windows + WSL Guide
|
|
82
|
-
|
|
83
|
-
1. Install bun via powershell
|
|
37
|
+
### 2. Start the WebSocket relay
|
|
84
38
|
|
|
85
39
|
```bash
|
|
86
|
-
|
|
40
|
+
bunx @biolab/talk-to-figma --relay
|
|
87
41
|
```
|
|
88
42
|
|
|
89
|
-
|
|
43
|
+
Runs on port 3055 by default (configurable via `PORT` env).
|
|
90
44
|
|
|
91
|
-
|
|
92
|
-
// uncomment this to allow connections in windows wsl
|
|
93
|
-
hostname: "0.0.0.0",
|
|
94
|
-
```
|
|
45
|
+
### 3. Install the Figma plugin
|
|
95
46
|
|
|
96
|
-
|
|
47
|
+
Download the plugin zip, unzip it, then in Figma: Plugins → Development → Link existing plugin → select `manifest.json`
|
|
97
48
|
|
|
98
|
-
```
|
|
99
|
-
|
|
49
|
+
```
|
|
50
|
+
https://cdn.jsdelivr.net/npm/@biolab/talk-to-figma@latest/figma-plugin/figma-plugin.zip
|
|
100
51
|
```
|
|
101
52
|
|
|
102
|
-
|
|
53
|
+
### 4. Connect
|
|
103
54
|
|
|
104
|
-
1.
|
|
105
|
-
2.
|
|
106
|
-
3.
|
|
107
|
-
4. Connect the plugin to the WebSocket server by joining a channel using `join_channel`
|
|
108
|
-
5. Use Cursor to communicate with Figma using the MCP tools
|
|
55
|
+
1. Open the plugin in Figma and join a channel
|
|
56
|
+
2. In your AI agent, call `join_channel` with the same channel name
|
|
57
|
+
3. Start using the MCP tools
|
|
109
58
|
|
|
110
|
-
##
|
|
59
|
+
## MCP Tools
|
|
111
60
|
|
|
112
|
-
|
|
61
|
+
### Document & Selection
|
|
113
62
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
```
|
|
63
|
+
- `get_document_info` - Get document info
|
|
64
|
+
- `get_selection` - Get current selection
|
|
65
|
+
- `read_my_design` - Get detailed selection info with all node details
|
|
66
|
+
- `get_node_info` - Get info about a specific node
|
|
67
|
+
- `get_nodes_info` - Get info about multiple nodes
|
|
68
|
+
- `set_focus` - Focus and scroll to a node
|
|
69
|
+
- `set_selections` - Select multiple nodes
|
|
124
70
|
|
|
125
|
-
|
|
71
|
+
### Creating Elements
|
|
126
72
|
|
|
127
|
-
|
|
73
|
+
- `create_rectangle` - Create a rectangle
|
|
74
|
+
- `create_frame` - Create a frame with auto-layout support
|
|
75
|
+
- `create_text` - Create a text node
|
|
76
|
+
|
|
77
|
+
### Modifying Elements
|
|
78
|
+
|
|
79
|
+
- `set_fill_color` - Set fill color (RGBA 0-1)
|
|
80
|
+
- `set_stroke_color` - Set stroke color and weight
|
|
81
|
+
- `set_corner_radius` - Set corner radius (per-corner support)
|
|
82
|
+
- `set_text_content` - Set text content
|
|
83
|
+
- `set_multiple_text_contents` - Batch update text nodes
|
|
84
|
+
- `move_node` - Move a node
|
|
85
|
+
- `resize_node` - Resize a node
|
|
86
|
+
- `clone_node` - Clone a node
|
|
87
|
+
- `delete_node` / `delete_multiple_nodes` - Delete nodes
|
|
88
|
+
|
|
89
|
+
### Auto Layout
|
|
90
|
+
|
|
91
|
+
- `set_layout_mode` - Set layout mode (NONE, HORIZONTAL, VERTICAL)
|
|
92
|
+
- `set_padding` - Set frame padding
|
|
93
|
+
- `set_axis_align` - Set axis alignment
|
|
94
|
+
- `set_layout_sizing` - Set sizing mode (FIXED, HUG, FILL)
|
|
95
|
+
- `set_item_spacing` - Set spacing between children
|
|
96
|
+
|
|
97
|
+
### Variables
|
|
98
|
+
|
|
99
|
+
- `get_local_variables` - Get all local variables with values per mode
|
|
100
|
+
- `get_local_variable_collections` - Get variable collections with modes
|
|
101
|
+
- `get_variable_by_id` - Get a specific variable
|
|
102
|
+
- `create_variable_collection` - Create a variable collection
|
|
103
|
+
- `create_variable` - Create a variable
|
|
104
|
+
- `set_variable_value` - Set variable value for a mode
|
|
105
|
+
- `set_variable_mode_name` - Rename a mode
|
|
106
|
+
- `set_variable_binding` - Bind a variable to a node property
|
|
128
107
|
|
|
129
|
-
###
|
|
108
|
+
### Components & Styles
|
|
130
109
|
|
|
131
|
-
- `
|
|
132
|
-
- `
|
|
133
|
-
- `
|
|
134
|
-
- `
|
|
135
|
-
- `
|
|
136
|
-
- `
|
|
137
|
-
- `
|
|
110
|
+
- `get_styles` - Get local styles
|
|
111
|
+
- `get_local_components` - Get local components
|
|
112
|
+
- `create_component_instance` - Instantiate a component
|
|
113
|
+
- `get_instance_overrides` / `set_instance_overrides` - Copy/apply instance overrides
|
|
114
|
+
- `get_team_library_components` - Get team library components
|
|
115
|
+
- `get_team_library_variables` - Get team library variables
|
|
116
|
+
- `import_variable_by_key` - Import a variable from team library
|
|
117
|
+
|
|
118
|
+
### Scanning
|
|
119
|
+
|
|
120
|
+
- `scan_text_nodes` - Scan text nodes (chunked for large designs)
|
|
121
|
+
- `scan_nodes_by_types` - Scan nodes by type
|
|
138
122
|
|
|
139
123
|
### Annotations
|
|
140
124
|
|
|
141
|
-
- `get_annotations` - Get
|
|
142
|
-
- `set_annotation` - Create
|
|
143
|
-
- `set_multiple_annotations` - Batch create/update multiple annotations efficiently
|
|
144
|
-
- `scan_nodes_by_types` - Scan for nodes with specific types (useful for finding annotation targets)
|
|
125
|
+
- `get_annotations` - Get annotations
|
|
126
|
+
- `set_annotation` / `set_multiple_annotations` - Create/update annotations
|
|
145
127
|
|
|
146
128
|
### Prototyping & Connections
|
|
147
129
|
|
|
148
|
-
- `get_reactions` - Get
|
|
149
|
-
- `set_default_connector` - Set
|
|
150
|
-
- `create_connections` - Create
|
|
130
|
+
- `get_reactions` - Get prototype reactions
|
|
131
|
+
- `set_default_connector` - Set default connector style
|
|
132
|
+
- `create_connections` - Create connector lines between nodes
|
|
151
133
|
|
|
152
|
-
###
|
|
134
|
+
### Export
|
|
153
135
|
|
|
154
|
-
- `
|
|
155
|
-
- `create_frame` - Create a new frame with position, size, and optional name
|
|
156
|
-
- `create_text` - Create a new text node with customizable font properties
|
|
136
|
+
- `export_node_as_image` - Export as PNG, JPG, SVG, or PDF
|
|
157
137
|
|
|
158
|
-
###
|
|
138
|
+
### Connection
|
|
159
139
|
|
|
160
|
-
- `
|
|
161
|
-
- `set_text_content` - Set the text content of a single text node
|
|
162
|
-
- `set_multiple_text_contents` - Batch update multiple text nodes efficiently
|
|
140
|
+
- `join_channel` - Join a channel to communicate with Figma
|
|
163
141
|
|
|
164
|
-
|
|
142
|
+
## Local Development
|
|
165
143
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
144
|
+
```bash
|
|
145
|
+
bun install # Install dependencies
|
|
146
|
+
bun run build # Build MCP server + relay (tsup → dist/)
|
|
147
|
+
bun run dev # Build in watch mode
|
|
148
|
+
bun socket # Start WebSocket relay (Bun-native, dev only)
|
|
149
|
+
```
|
|
171
150
|
|
|
172
|
-
|
|
151
|
+
For local dev, point your MCP config to the built CLI:
|
|
173
152
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"mcpServers": {
|
|
156
|
+
"TalkToFigma": {
|
|
157
|
+
"command": "node",
|
|
158
|
+
"args": ["/path-to-repo/dist/cli.js"]
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
```
|
|
177
163
|
|
|
178
|
-
|
|
164
|
+
Start the relay locally:
|
|
179
165
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
- `delete_multiple_nodes` - Delete multiple nodes at once efficiently
|
|
184
|
-
- `clone_node` - Create a copy of an existing node with optional position offset
|
|
166
|
+
```bash
|
|
167
|
+
node dist/cli.js --relay
|
|
168
|
+
```
|
|
185
169
|
|
|
186
|
-
|
|
170
|
+
## Project Structure
|
|
187
171
|
|
|
188
|
-
- `
|
|
189
|
-
- `
|
|
190
|
-
- `
|
|
191
|
-
- `
|
|
192
|
-
- `
|
|
193
|
-
|
|
194
|
-
### Export & Advanced
|
|
195
|
-
|
|
196
|
-
- `export_node_as_image` - Export a node as an image (PNG, JPG, SVG, or PDF) - limited support on image currently returning base64 as text
|
|
197
|
-
|
|
198
|
-
### Connection Management
|
|
199
|
-
|
|
200
|
-
- `join_channel` - Join a specific channel to communicate with Figma
|
|
201
|
-
|
|
202
|
-
### MCP Prompts
|
|
203
|
-
|
|
204
|
-
The MCP server includes several helper prompts to guide you through complex design tasks:
|
|
205
|
-
|
|
206
|
-
- `design_strategy` - Best practices for working with Figma designs
|
|
207
|
-
- `read_design_strategy` - Best practices for reading Figma designs
|
|
208
|
-
- `text_replacement_strategy` - Systematic approach for replacing text in Figma designs
|
|
209
|
-
- `annotation_conversion_strategy` - Strategy for converting manual annotations to Figma's native annotations
|
|
210
|
-
- `swap_overrides_instances` - Strategy for transferring overrides between component instances in Figma
|
|
211
|
-
- `reaction_to_connector_strategy` - Strategy for converting Figma prototype reactions to connector lines using the output of 'get_reactions', and guiding the use 'create_connections' in sequence
|
|
212
|
-
|
|
213
|
-
## Development
|
|
214
|
-
|
|
215
|
-
### Building the Figma Plugin
|
|
216
|
-
|
|
217
|
-
1. Navigate to the Figma plugin directory:
|
|
218
|
-
|
|
219
|
-
```
|
|
220
|
-
cd src/cursor_mcp_plugin
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
2. Edit code.js and ui.html
|
|
224
|
-
|
|
225
|
-
## Best Practices
|
|
226
|
-
|
|
227
|
-
When working with the Figma MCP:
|
|
228
|
-
|
|
229
|
-
1. Always join a channel before sending commands
|
|
230
|
-
2. Get document overview using `get_document_info` first
|
|
231
|
-
3. Check current selection with `get_selection` before modifications
|
|
232
|
-
4. Use appropriate creation tools based on needs:
|
|
233
|
-
- `create_frame` for containers
|
|
234
|
-
- `create_rectangle` for basic shapes
|
|
235
|
-
- `create_text` for text elements
|
|
236
|
-
5. Verify changes using `get_node_info`
|
|
237
|
-
6. Use component instances when possible for consistency
|
|
238
|
-
7. Handle errors appropriately as all commands can throw exceptions
|
|
239
|
-
8. For large designs:
|
|
240
|
-
- Use chunking parameters in `scan_text_nodes`
|
|
241
|
-
- Monitor progress through WebSocket updates
|
|
242
|
-
- Implement appropriate error handling
|
|
243
|
-
9. For text operations:
|
|
244
|
-
- Use batch operations when possible
|
|
245
|
-
- Consider structural relationships
|
|
246
|
-
- Verify changes with targeted exports
|
|
247
|
-
10. For converting legacy annotations:
|
|
248
|
-
- Scan text nodes to identify numbered markers and descriptions
|
|
249
|
-
- Use `scan_nodes_by_types` to find UI elements that annotations refer to
|
|
250
|
-
- Match markers with their target elements using path, name, or proximity
|
|
251
|
-
- Categorize annotations appropriately with `get_annotations`
|
|
252
|
-
- Create native annotations with `set_multiple_annotations` in batches
|
|
253
|
-
- Verify all annotations are properly linked to their targets
|
|
254
|
-
- Delete legacy annotation nodes after successful conversion
|
|
255
|
-
11. Visualize prototype noodles as FigJam connectors:
|
|
256
|
-
|
|
257
|
-
- Use `get_reactions` to extract prototype flows,
|
|
258
|
-
- set a default connector with `set_default_connector`,
|
|
259
|
-
- and generate connector lines with `create_connections` for clear visual flow mapping.
|
|
172
|
+
- `src/cli.ts` - CLI entry point (routes `--relay` flag)
|
|
173
|
+
- `src/talk_to_figma_mcp/server.ts` - MCP server
|
|
174
|
+
- `src/relay.ts` - WebSocket relay (Node-compatible, bundled in npm package)
|
|
175
|
+
- `src/socket.ts` - WebSocket relay (Bun-native, local dev only)
|
|
176
|
+
- `src/cursor_mcp_plugin/` - Figma plugin (`code.js`, `ui.html`, `manifest.json`)
|
|
260
177
|
|
|
261
178
|
## License
|
|
262
179
|
|