@biolab/talk-to-figma 0.3.3

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 ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Github User sonnylazuardi
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
13
+ all 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
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,263 @@
1
+ # Talk to Figma MCP
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.
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
+ ```
20
+
21
+ 2. Run setup, this will also install MCP in your Cursor's active project
22
+
23
+ ```bash
24
+ bun setup
25
+ ```
26
+
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
36
+
37
+ [Video Link](https://www.linkedin.com/posts/sonnylazuardi_just-wanted-to-share-my-latest-experiment-activity-7307821553654657024-yrh8)
38
+
39
+ ## Design Automation Example
40
+
41
+ **Bulk text content replacement**
42
+
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`:
54
+
55
+ ```json
56
+ {
57
+ "mcpServers": {
58
+ "TalkToFigma": {
59
+ "command": "bunx",
60
+ "args": ["cursor-talk-to-figma-mcp@latest"]
61
+ }
62
+ }
63
+ }
64
+ ```
65
+
66
+ ### WebSocket Server
67
+
68
+ Start the WebSocket server:
69
+
70
+ ```bash
71
+ bun socket
72
+ ```
73
+
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
84
+
85
+ ```bash
86
+ powershell -c "irm bun.sh/install.ps1|iex"
87
+ ```
88
+
89
+ 2. Uncomment the hostname `0.0.0.0` in `src/socket.ts`
90
+
91
+ ```typescript
92
+ // uncomment this to allow connections in windows wsl
93
+ hostname: "0.0.0.0",
94
+ ```
95
+
96
+ 3. Start the websocket
97
+
98
+ ```bash
99
+ bun socket
100
+ ```
101
+
102
+ ## Usage
103
+
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
109
+
110
+ ## Local Development Setup
111
+
112
+ To develop, update your mcp config to direct to your local directory.
113
+
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
+ ```
124
+
125
+ ## MCP Tools
126
+
127
+ The MCP server provides the following tools for interacting with Figma:
128
+
129
+ ### Document & Selection
130
+
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
138
+
139
+ ### Annotations
140
+
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)
145
+
146
+ ### Prototyping & Connections
147
+
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
151
+
152
+ ### Creating Elements
153
+
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
157
+
158
+ ### Modifying text content
159
+
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
163
+
164
+ ### Auto Layout & Spacing
165
+
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
171
+
172
+ ### Styling
173
+
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
177
+
178
+ ### Layout & Organization
179
+
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
185
+
186
+ ### Components & Styles
187
+
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.
260
+
261
+ ## License
262
+
263
+ MIT