@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 CHANGED
@@ -1,262 +1,179 @@
1
1
  # Talk to Figma MCP
2
2
 
3
- This project implements a Model Context Protocol (MCP) integration between AI agent (Cursor, Claude Code) and Figma, allowing AI agent to communicate with Figma for reading designs and modifying them programmatically.
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
- 3. Start the Websocket server
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
- [Video Link](https://www.linkedin.com/posts/sonnylazuardi_just-wanted-to-share-my-latest-experiment-activity-7307821553654657024-yrh8)
11
+ ### Prerequisites
38
12
 
39
- ## Design Automation Example
13
+ - [Bun](https://bun.sh) runtime
14
+ - Figma desktop app
40
15
 
41
- **Bulk text content replacement**
16
+ ### 1. Add MCP server
42
17
 
43
- Thanks to [@dusskapark](https://github.com/dusskapark) for contributing the bulk text replacement feature. Here is the [demo video](https://www.youtube.com/watch?v=j05gGT3xfCs).
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": ["cursor-talk-to-figma-mcp@latest"]
25
+ "args": ["@biolab/talk-to-figma@latest"]
61
26
  }
62
27
  }
63
28
  }
64
29
  ```
65
30
 
66
- ### WebSocket Server
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
- bun socket
34
+ claude mcp add TalkToFigma -- bunx @biolab/talk-to-figma@latest
72
35
  ```
73
36
 
74
- ### Figma Plugin
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
- powershell -c "irm bun.sh/install.ps1|iex"
40
+ bunx @biolab/talk-to-figma --relay
87
41
  ```
88
42
 
89
- 2. Uncomment the hostname `0.0.0.0` in `src/socket.ts`
43
+ Runs on port 3055 by default (configurable via `PORT` env).
90
44
 
91
- ```typescript
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
- 3. Start the websocket
47
+ Download the plugin zip, unzip it, then in Figma: Plugins → Development → Link existing plugin → select `manifest.json`
97
48
 
98
- ```bash
99
- bun socket
49
+ ```
50
+ https://cdn.jsdelivr.net/npm/@biolab/talk-to-figma@latest/figma-plugin/figma-plugin.zip
100
51
  ```
101
52
 
102
- ## Usage
53
+ ### 4. Connect
103
54
 
104
- 1. Start the WebSocket server
105
- 2. Install the MCP server in Cursor
106
- 3. Open Figma and run the Cursor MCP Plugin
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
- ## Local Development Setup
59
+ ## MCP Tools
111
60
 
112
- To develop, update your mcp config to direct to your local directory.
61
+ ### Document & Selection
113
62
 
114
- ```json
115
- {
116
- "mcpServers": {
117
- "TalkToFigma": {
118
- "command": "bun",
119
- "args": ["/path-to-repo/src/talk_to_figma_mcp/server.ts"]
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
- ## MCP Tools
71
+ ### Creating Elements
126
72
 
127
- The MCP server provides the following tools for interacting with Figma:
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
- ### Document & Selection
108
+ ### Components & Styles
130
109
 
131
- - `get_document_info` - Get information about the current Figma document
132
- - `get_selection` - Get information about the current selection
133
- - `read_my_design` - Get detailed node information about the current selection without parameters
134
- - `get_node_info` - Get detailed information about a specific node
135
- - `get_nodes_info` - Get detailed information about multiple nodes by providing an array of node IDs
136
- - `set_focus` - Set focus on a specific node by selecting it and scrolling viewport to it
137
- - `set_selections` - Set selection to multiple nodes and scroll viewport to show them
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 all annotations in the current document or specific node
142
- - `set_annotation` - Create or update an annotation with markdown support
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 all prototype reactions from nodes with visual highlight animation
149
- - `set_default_connector` - Set a copied FigJam connector as the default connector style for creating connections (must be set before creating connections)
150
- - `create_connections` - Create FigJam connector lines between nodes, based on prototype flows or custom mapping
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
- ### Creating Elements
134
+ ### Export
153
135
 
154
- - `create_rectangle` - Create a new rectangle with position, size, and optional name
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
- ### Modifying text content
138
+ ### Connection
159
139
 
160
- - `scan_text_nodes` - Scan text nodes with intelligent chunking for large designs
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
- ### Auto Layout & Spacing
142
+ ## Local Development
165
143
 
166
- - `set_layout_mode` - Set the layout mode and wrap behavior of a frame (NONE, HORIZONTAL, VERTICAL)
167
- - `set_padding` - Set padding values for an auto-layout frame (top, right, bottom, left)
168
- - `set_axis_align` - Set primary and counter axis alignment for auto-layout frames
169
- - `set_layout_sizing` - Set horizontal and vertical sizing modes for auto-layout frames (FIXED, HUG, FILL)
170
- - `set_item_spacing` - Set distance between children in an auto-layout frame
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
- ### Styling
151
+ For local dev, point your MCP config to the built CLI:
173
152
 
174
- - `set_fill_color` - Set the fill color of a node (RGBA)
175
- - `set_stroke_color` - Set the stroke color and weight of a node
176
- - `set_corner_radius` - Set the corner radius of a node with optional per-corner control
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
- ### Layout & Organization
164
+ Start the relay locally:
179
165
 
180
- - `move_node` - Move a node to a new position
181
- - `resize_node` - Resize a node with new dimensions
182
- - `delete_node` - Delete a node
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
- ### Components & Styles
170
+ ## Project Structure
187
171
 
188
- - `get_styles` - Get information about local styles
189
- - `get_local_components` - Get information about local components
190
- - `create_component_instance` - Create an instance of a component
191
- - `get_instance_overrides` - Extract override properties from a selected component instance
192
- - `set_instance_overrides` - Apply extracted overrides to target instances
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