figma-console-mcp 0.1.0 → 1.1.2

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.
Files changed (71) hide show
  1. package/README.md +275 -24
  2. package/dist/browser/local.d.ts +15 -0
  3. package/dist/browser/local.d.ts.map +1 -1
  4. package/dist/browser/local.js +60 -0
  5. package/dist/browser/local.js.map +1 -1
  6. package/dist/cloudflare/core/code-to-spec.js +1126 -0
  7. package/dist/cloudflare/core/console-monitor.js +45 -0
  8. package/dist/cloudflare/core/design-system-manifest.js +260 -0
  9. package/dist/cloudflare/core/figma-desktop-connector.js +620 -4
  10. package/dist/cloudflare/core/figma-mcp-client.js +150 -0
  11. package/dist/cloudflare/core/figma-reconstruction-spec.js +402 -0
  12. package/dist/cloudflare/core/figma-tools.js +827 -240
  13. package/dist/core/code-to-spec.d.ts +103 -0
  14. package/dist/core/code-to-spec.d.ts.map +1 -0
  15. package/dist/core/code-to-spec.js +1127 -0
  16. package/dist/core/code-to-spec.js.map +1 -0
  17. package/dist/core/console-monitor.d.ts +1 -0
  18. package/dist/core/console-monitor.d.ts.map +1 -1
  19. package/dist/core/console-monitor.js +45 -0
  20. package/dist/core/console-monitor.js.map +1 -1
  21. package/dist/core/design-system-manifest.d.ts +272 -0
  22. package/dist/core/design-system-manifest.d.ts.map +1 -0
  23. package/dist/core/design-system-manifest.js +261 -0
  24. package/dist/core/design-system-manifest.js.map +1 -0
  25. package/dist/core/figma-desktop-connector.d.ts +175 -0
  26. package/dist/core/figma-desktop-connector.d.ts.map +1 -1
  27. package/dist/core/figma-desktop-connector.js +620 -4
  28. package/dist/core/figma-desktop-connector.js.map +1 -1
  29. package/dist/core/figma-mcp-client.d.ts +61 -0
  30. package/dist/core/figma-mcp-client.d.ts.map +1 -0
  31. package/dist/core/figma-mcp-client.js +151 -0
  32. package/dist/core/figma-mcp-client.js.map +1 -0
  33. package/dist/core/figma-reconstruction-spec.d.ts +166 -0
  34. package/dist/core/figma-reconstruction-spec.d.ts.map +1 -0
  35. package/dist/core/figma-reconstruction-spec.js +403 -0
  36. package/dist/core/figma-reconstruction-spec.js.map +1 -0
  37. package/dist/core/figma-tools.d.ts.map +1 -1
  38. package/dist/core/figma-tools.js +827 -240
  39. package/dist/core/figma-tools.js.map +1 -1
  40. package/dist/local.d.ts +12 -0
  41. package/dist/local.d.ts.map +1 -1
  42. package/dist/local.js +1817 -22
  43. package/dist/local.js.map +1 -1
  44. package/figma-desktop-bridge/code.js +1830 -8
  45. package/figma-desktop-bridge/manifest.json +1 -0
  46. package/figma-desktop-bridge/ui.html +482 -121
  47. package/package.json +1 -1
  48. package/dist/config.d.ts +0 -17
  49. package/dist/config.d.ts.map +0 -1
  50. package/dist/config.js +0 -141
  51. package/dist/config.js.map +0 -1
  52. package/dist/index.d.ts +0 -8
  53. package/dist/index.d.ts.map +0 -1
  54. package/dist/index.js +0 -72
  55. package/dist/index.js.map +0 -1
  56. package/dist/logger.d.ts +0 -22
  57. package/dist/logger.d.ts.map +0 -1
  58. package/dist/logger.js +0 -45
  59. package/dist/logger.js.map +0 -1
  60. package/dist/server.d.ts +0 -40
  61. package/dist/server.d.ts.map +0 -1
  62. package/dist/server.js +0 -99
  63. package/dist/server.js.map +0 -1
  64. package/dist/tools/index.d.ts +0 -15
  65. package/dist/tools/index.d.ts.map +0 -1
  66. package/dist/tools/index.js +0 -184
  67. package/dist/tools/index.js.map +0 -1
  68. package/dist/types/index.d.ts +0 -102
  69. package/dist/types/index.d.ts.map +0 -1
  70. package/dist/types/index.js +0 -6
  71. package/dist/types/index.js.map +0 -1
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![MCP](https://img.shields.io/badge/MCP-Compatible-blue)](https://modelcontextprotocol.io/)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
- > **Model Context Protocol server** that provides AI assistants with **real-time console access, visual debugging, and design system extraction** for Figma.
6
+ > **Model Context Protocol server** that provides AI assistants with **real-time console access, visual debugging, design system extraction, and design creation** for Figma.
7
7
 
8
8
  ## What is this?
9
9
 
@@ -12,13 +12,27 @@ Figma Console MCP connects AI assistants (like Claude) to Figma, enabling:
12
12
  - **🐛 Plugin debugging** - Capture console logs, errors, and stack traces
13
13
  - **📸 Visual debugging** - Take screenshots for context
14
14
  - **🎨 Design system extraction** - Pull variables, components, and styles
15
+ - **✏️ Design creation** - Create UI components, frames, and layouts directly in Figma
16
+ - **🔧 Variable management** - Create, update, rename, and delete design tokens
15
17
  - **⚡ Real-time monitoring** - Watch logs as plugins execute
16
- - **🔄 Two modes** - Remote (zero setup) or Local (plugin development)
18
+ - **🔄 Three ways to install** - Remote SSE (OAuth, zero-setup), NPX (npm package), or Local Git (source code)
17
19
 
18
20
  ---
19
21
 
20
22
  ## ⚡ Quick Start
21
23
 
24
+ ### Choose Your Installation Method
25
+
26
+ This MCP server offers **three installation methods** with different tradeoffs:
27
+
28
+ | Method | Setup | Auth | Best For |
29
+ |--------|-------|------|----------|
30
+ | **[Remote SSE](#for-most-users-remote-mode-zero-setup)** | ⭐ Paste URL (2 min) | OAuth (automatic) | Most users - design system extraction |
31
+ | **[NPX](#npx-alternative-package-distribution)** | npm package (10 min) | PAT (manual) | Local execution without source code |
32
+ | **[Local Git](#for-plugin-developers-local-mode)** | git clone (15 min) | PAT (manual) | Developers - modify source code |
33
+
34
+ **Key Insight:** Only Remote SSE offers true zero-setup via OAuth. Both NPX and Local Git require manual `FIGMA_ACCESS_TOKEN` setup.
35
+
22
36
  Choose the setup that fits your needs:
23
37
 
24
38
  ### For Most Users: Remote Mode (Zero Setup)
@@ -99,6 +113,48 @@ Consult your client's MCP documentation for the config file location, then add:
99
113
 
100
114
  ---
101
115
 
116
+ ### NPX: Alternative Package Distribution
117
+
118
+ **Use NPX if you:**
119
+ - ✅ Want local execution without cloning source code
120
+ - ✅ Need Desktop Bridge plugin features
121
+ - ✅ Prefer npm package distribution over git
122
+ - ⚠️ Are comfortable with manual `FIGMA_ACCESS_TOKEN` setup
123
+
124
+ **Setup time:** 10 minutes
125
+
126
+ **Note:** NPX has **identical authentication requirements** to Local Git mode. For true zero-setup, use [Remote Mode](#for-most-users-remote-mode-zero-setup) instead.
127
+
128
+ #### Configuration
129
+
130
+ Add to your MCP config (e.g., `.claude.json` or `claude_desktop_config.json`):
131
+
132
+ ```json
133
+ {
134
+ "mcpServers": {
135
+ "figma-console": {
136
+ "type": "stdio",
137
+ "command": "npx",
138
+ "args": ["-y", "figma-console-mcp@latest"],
139
+ "env": {
140
+ "FIGMA_ACCESS_TOKEN": "your_figma_access_token_here"
141
+ }
142
+ }
143
+ }
144
+ }
145
+ ```
146
+
147
+ #### Prerequisites
148
+
149
+ - Get **Figma Personal Access Token**: https://www.figma.com/developers/api#access-tokens
150
+ - Restart Figma Desktop with `--remote-debugging-port=9222`
151
+ - **macOS:** `open -a "Figma" --args --remote-debugging-port=9222`
152
+ - **Windows:** `cmd /c "%LOCALAPPDATA%\Figma\Figma.exe" --remote-debugging-port=9222`
153
+
154
+ **📖 [Complete NPX Setup Guide](docs/NPX-INSTALLATION.md)**
155
+
156
+ ---
157
+
102
158
  ### For Plugin Developers: Local Mode
103
159
 
104
160
  **Use Local Mode if you:**
@@ -111,27 +167,109 @@ Consult your client's MCP documentation for the config file location, then add:
111
167
 
112
168
  **Setup time:** 10-15 minutes
113
169
 
114
- **Prerequisites:**
115
- - Node.js 18+
170
+ #### Prerequisites
171
+ - Node.js 18+ installed
116
172
  - Figma Desktop installed
117
- - Terminal access
173
+ - Git installed
174
+ - Terminal/command line access
118
175
 
119
- **[📖 See Local Mode Setup Guide](docs/CLAUDE_DESKTOP_SETUP_UPDATED.md#local-mode-setup-advanced)**
176
+ #### Step 1: Install the MCP Server
120
177
 
121
- ---
178
+ ```bash
179
+ # Clone the repository
180
+ git clone https://github.com/southleft/figma-console-mcp.git
181
+ cd figma-console-mcp
182
+
183
+ # Install dependencies
184
+ npm install
185
+
186
+ # Build for local mode
187
+ npm run build:local
188
+ ```
189
+
190
+ #### Step 2: Get Figma Personal Access Token
191
+
192
+ 1. Visit https://www.figma.com/developers/api#access-tokens
193
+ 2. Click "Get personal access token"
194
+ 3. Enter description: "Figma Console MCP Local"
195
+ 4. Click "Generate token"
196
+ 5. **Copy the token** (you won't see it again!)
197
+
198
+ #### Step 3: Configure Claude Desktop
199
+
200
+ **macOS:** Edit `~/Library/Application Support/Claude/claude_desktop_config.json`
201
+ **Windows:** Edit `%APPDATA%\Claude\claude_desktop_config.json`
202
+
203
+ Add this configuration:
122
204
 
123
- ## 📊 Remote vs Local: Which Should I Use?
205
+ ```json
206
+ {
207
+ "mcpServers": {
208
+ "figma-console-local": {
209
+ "command": "node",
210
+ "args": ["/absolute/path/to/figma-console-mcp/dist/local.js"],
211
+ "env": {
212
+ "FIGMA_ACCESS_TOKEN": "figd_YOUR_TOKEN_HERE"
213
+ }
214
+ }
215
+ }
216
+ }
217
+ ```
124
218
 
125
- | Feature | Remote Mode | Local Mode |
126
- |---------|-------------|------------|
127
- | **Setup** | 2 minutes | 10-15 minutes |
128
- | **Prerequisites** | None | Node.js, Figma restart |
129
- | **Console logs** | ✅ | ✅ (lower latency) |
130
- | **API access** | | |
131
- | **OAuth auth** | ✅ (automatic) | ❌ (manual PAT) |
132
- | **Desktop Bridge plugin** | | |
133
- | **Variables (no Enterprise)** | ❌ | ✅ (via plugin) |
134
- | **Reliable component descriptions** | ⚠️ (API bugs) | ✅ (via plugin) |
219
+ **Important:**
220
+ - Replace `/absolute/path/to/figma-console-mcp` with the actual absolute path where you cloned the repo
221
+ - Replace `figd_YOUR_TOKEN_HERE` with your actual Figma token from Step 2
222
+ - Use forward slashes `/` even on Windows
223
+
224
+ #### Step 4: Launch Figma Desktop with Remote Debugging
225
+
226
+ **⚠️ CRITICAL:** Quit Figma completely first, then restart it with the debug flag:
227
+
228
+ **macOS:**
229
+ ```bash
230
+ open -a "Figma" --args --remote-debugging-port=9222
231
+ ```
232
+
233
+ **Windows (CMD or PowerShell):**
234
+ ```
235
+ cmd /c "%LOCALAPPDATA%\Figma\Figma.exe" --remote-debugging-port=9222
236
+ ```
237
+
238
+ #### Step 5: Restart Claude Desktop
239
+
240
+ Quit Claude Desktop completely and relaunch it. The MCP server will connect automatically.
241
+
242
+ #### Step 6: Verify Setup
243
+
244
+ 1. **Check debug port is working:**
245
+ - Open Chrome browser
246
+ - Visit: http://localhost:9222
247
+ - You should see inspectable Figma pages
248
+
249
+ 2. **Test in Claude Desktop:**
250
+ - Look for 🔌 icon showing "figma-console-local: connected"
251
+ - Ask Claude: "Check Figma status"
252
+ - Should show: "✅ Figma Desktop connected"
253
+
254
+ **📖 For more details:** See [Complete Setup Guide](docs/SETUP.md)
255
+
256
+ ---
257
+
258
+ ## 📊 Installation Method Comparison
259
+
260
+ | Feature | Remote SSE | NPX | Local Git |
261
+ |---------|------------|-----|-----------|
262
+ | **Setup** | 2 minutes | 10 minutes | 15 minutes |
263
+ | **Prerequisites** | None | PAT + Figma restart | PAT + Figma restart + git |
264
+ | **Authentication** | OAuth (automatic) | PAT (manual) | PAT (manual) |
265
+ | **Console logs** | ✅ | ✅ (zero latency) | ✅ (zero latency) |
266
+ | **API access** | ✅ | ✅ | ✅ |
267
+ | **Desktop Bridge plugin** | ❌ | ✅ | ✅ |
268
+ | **AI-Assisted Design Creation** | ❌ | ✅ (via plugin) | ✅ (via plugin) |
269
+ | **Variables (no Enterprise)** | ❌ | ✅ (via plugin) | ✅ (via plugin) |
270
+ | **Reliable descriptions** | ⚠️ (API bugs) | ✅ (via plugin) | ✅ (via plugin) |
271
+ | **Source code access** | ❌ | ❌ | ✅ |
272
+ | **Distribution** | URL | npm package | git clone |
135
273
 
136
274
  **📖 [Complete Feature Comparison](docs/MODE_COMPARISON.md)**
137
275
 
@@ -178,8 +316,6 @@ When you first use design system tools:
178
316
 
179
317
  ## 🛠️ Available Tools
180
318
 
181
- All 14 tools work in both Remote and Local modes:
182
-
183
319
  ### Navigation & Status
184
320
  - `figma_navigate` - Open Figma URLs
185
321
  - `figma_get_status` - Check connection status
@@ -195,13 +331,29 @@ All 14 tools work in both Remote and Local modes:
195
331
 
196
332
  ### Design System Extraction
197
333
  - `figma_get_variables` - Extract design tokens/variables
198
- - `figma_get_component` - Get component data
334
+ - `figma_get_component` - Get component data (metadata or reconstruction spec)
199
335
  - `figma_get_component_for_development` - Component + image
200
336
  - `figma_get_component_image` - Just the image
201
337
  - `figma_get_styles` - Color, text, effect styles
202
338
  - `figma_get_file_data` - Full file structure
203
339
  - `figma_get_file_for_plugin` - Optimized file data
204
340
 
341
+ ### ✏️ Design Creation (Local Mode + Desktop Bridge)
342
+ - `figma_execute` - **Power tool**: Run any Figma Plugin API code to create designs
343
+ - Create frames, shapes, text, components
344
+ - Apply auto-layout, styles, effects
345
+ - Build complete UI mockups programmatically
346
+
347
+ ### 🔧 Variable Management (Local Mode + Desktop Bridge)
348
+ - `figma_create_variable_collection` - Create new variable collections with modes
349
+ - `figma_create_variable` - Create COLOR, FLOAT, STRING, or BOOLEAN variables
350
+ - `figma_update_variable` - Update variable values in specific modes
351
+ - `figma_rename_variable` - Rename variables while preserving values
352
+ - `figma_delete_variable` - Delete variables
353
+ - `figma_delete_variable_collection` - Delete collections and all their variables
354
+ - `figma_add_mode` - Add modes to collections (e.g., "Dark", "Mobile")
355
+ - `figma_rename_mode` - Rename existing modes
356
+
205
357
  **📖 [Detailed Tool Documentation](docs/TOOLS.md)**
206
358
 
207
359
  ---
@@ -220,6 +372,23 @@ Get the last 20 console logs
220
372
  Get all design variables from https://figma.com/design/abc123
221
373
  Extract color styles and show me the CSS exports
222
374
  Get the Button component with a visual reference image
375
+ Get the Badge component in reconstruction format for programmatic creation
376
+ ```
377
+
378
+ ### Design Creation (Local Mode)
379
+ ```
380
+ Create a success notification card with a checkmark icon and message
381
+ Design a button component with hover and disabled states
382
+ Build a navigation bar with logo, menu items, and user avatar
383
+ Create a modal dialog with header, content area, and action buttons
384
+ ```
385
+
386
+ ### Variable Management (Local Mode)
387
+ ```
388
+ Create a new color collection called "Brand Colors" with Light and Dark modes
389
+ Add a primary color variable with value #3B82F6 for Light and #60A5FA for Dark
390
+ Rename the "Default" mode to "Light Theme"
391
+ Add a "High Contrast" mode to the existing collection
223
392
  ```
224
393
 
225
394
  ### Visual Debugging
@@ -232,13 +401,95 @@ Navigate to this file and capture what's on screen
232
401
 
233
402
  ---
234
403
 
404
+ ## 🎨 AI-Assisted Design Creation
405
+
406
+ > **⚠️ Local Mode Only:** This feature requires the Desktop Bridge plugin and only works with [Local Mode installation](#for-plugin-developers-local-mode). Remote Mode is read-only and cannot create or modify designs.
407
+
408
+ One of the most powerful capabilities of this MCP server is the ability to **design complete UI components and pages directly in Figma through natural language conversation** with any MCP-compatible AI assistant like Claude Desktop or Claude Code.
409
+
410
+ ### What's Possible
411
+
412
+ **Create original designs from scratch:**
413
+ ```
414
+ Design a login card with email and password fields, a "Forgot password?" link,
415
+ and a primary Sign In button. Use 32px padding, 16px border radius, and subtle shadow.
416
+ ```
417
+
418
+ **Leverage existing component libraries:**
419
+ ```
420
+ Build a dashboard header using the Avatar component for the user profile,
421
+ Button components for actions, and Badge components for notifications.
422
+ ```
423
+
424
+ **Generate complete page layouts:**
425
+ ```
426
+ Create a settings page with a sidebar navigation, a main content area with form fields,
427
+ and a sticky footer with Save and Cancel buttons.
428
+ ```
429
+
430
+ ### How It Works
431
+
432
+ 1. **You describe what you want** in plain English
433
+ 2. **The AI searches your component library** using `figma_search_components` to find relevant building blocks
434
+ 3. **Components are instantiated** with proper variants and properties via `figma_instantiate_component`
435
+ 4. **Custom elements are created** using the full Figma Plugin API via `figma_execute`
436
+ 5. **Visual validation** automatically captures screenshots and iterates until the design looks right
437
+
438
+ ### Who Benefits
439
+
440
+ | Role | Use Case |
441
+ |------|----------|
442
+ | **Designers** | Rapidly prototype ideas without manual frame-by-frame construction. Explore variations quickly by describing changes. |
443
+ | **Developers** | Generate UI mockups during planning discussions. Create visual specs without switching to design tools. |
444
+ | **Product Managers** | Sketch out feature concepts during ideation. Communicate visual requirements directly to stakeholders. |
445
+ | **Design System Teams** | Test component flexibility by generating compositions. Identify gaps in component coverage. |
446
+ | **Agencies** | Speed up initial concept delivery. Iterate on client feedback in real-time during calls. |
447
+
448
+ ### Example Workflows
449
+
450
+ **Brand New Design:**
451
+ > "Create a notification toast with an icon on the left, title and description text, and a dismiss button. Use our brand colors."
452
+
453
+ The AI creates custom frames, applies your design tokens, and builds the component from scratch.
454
+
455
+ **Component Composition:**
456
+ > "Build a user profile card using the Avatar component (large size), two Button components (Edit Profile and Settings), and a Badge for the user's status."
457
+
458
+ The AI searches your library, finds the exact components, and assembles them with proper spacing and alignment.
459
+
460
+ **Design Iteration:**
461
+ > "The spacing feels too tight. Increase the gap between sections to 24px and make the heading larger."
462
+
463
+ The AI modifies the existing design, takes a screenshot to verify, and continues iterating until you're satisfied.
464
+
465
+ ### Visual Validation
466
+
467
+ The AI automatically follows a validation workflow after creating designs:
468
+
469
+ 1. **Create** → Execute the design code
470
+ 2. **Screenshot** → Capture the result
471
+ 3. **Analyze** → Check alignment, spacing, and visual balance
472
+ 4. **Iterate** → Fix any issues detected
473
+ 5. **Verify** → Final screenshot to confirm
474
+
475
+ This ensures designs aren't just technically correct—they *look* right.
476
+
477
+ ---
478
+
235
479
  ## 🎨 Desktop Bridge Plugin (Local Mode Only)
236
480
 
237
- The **Figma Desktop Bridge** plugin enables:
481
+ The **Figma Desktop Bridge** plugin enables powerful capabilities:
482
+
483
+ ### Read Operations
238
484
  - ✅ Variables without Enterprise API
239
485
  - ✅ Reliable component descriptions (bypasses API bugs)
240
486
  - ✅ Multi-mode support (Light/Dark/Brand variants)
241
487
 
488
+ ### Write Operations
489
+ - ✅ **Design Creation** - Create frames, shapes, text, components via `figma_execute`
490
+ - ✅ **Variable Management** - Full CRUD operations on variables and collections
491
+ - ✅ **Mode Management** - Add and rename modes for multi-theme support
492
+
242
493
  **⚠️ Plugin Limitation:** Only works in Local Mode. Remote mode cannot access it.
243
494
 
244
495
  **Setup:**
@@ -246,7 +497,7 @@ The **Figma Desktop Bridge** plugin enables:
246
497
  2. Download plugin from [Releases](https://github.com/southleft/figma-console-mcp/releases/latest)
247
498
  3. Import plugin: Figma Desktop → Plugins → Development → Import plugin from manifest
248
499
  4. Run plugin in your Figma file
249
- 5. Ask Claude: "Show me the primary font for [your theme]"
500
+ 5. Ask Claude: "Create a button component" or "Show me the design variables"
250
501
 
251
502
  **📖 [Desktop Bridge Documentation](figma-desktop-bridge/README.md)**
252
503
 
@@ -254,7 +505,7 @@ The **Figma Desktop Bridge** plugin enables:
254
505
 
255
506
  ## 🚀 Advanced Topics
256
507
 
257
- - **[Local Mode Setup](docs/CLAUDE_DESKTOP_SETUP_UPDATED.md)** - Complete local installation guide
508
+ - **[Setup Guide](docs/SETUP.md)** - Complete setup guide for all MCP clients
258
509
  - **[Self-Hosting](docs/SELF_HOSTING.md)** - Deploy your own instance on Cloudflare
259
510
  - **[Architecture](docs/ARCHITECTURE.md)** - How it works under the hood
260
511
  - **[OAuth Setup](docs/OAUTH_SETUP.md)** - Configure OAuth for self-hosted deployments
@@ -58,6 +58,21 @@ export declare class LocalBrowserManager implements IBrowserManager {
58
58
  * Get current page URL
59
59
  */
60
60
  getCurrentUrl(): string | null;
61
+ /**
62
+ * Check if the browser connection is still alive
63
+ * Returns false if connection is stale (e.g., after computer sleep)
64
+ */
65
+ isConnectionAlive(): Promise<boolean>;
66
+ /**
67
+ * Reconnect to Figma Desktop if connection was lost
68
+ * Call this before any operation that requires a live connection
69
+ */
70
+ ensureConnection(): Promise<void>;
71
+ /**
72
+ * Force a complete reconnection to Figma Desktop
73
+ * Use this when frames become detached or stale even though the browser appears connected
74
+ */
75
+ forceReconnect(): Promise<void>;
61
76
  /**
62
77
  * Wait for navigation
63
78
  */
@@ -1 +1 @@
1
- {"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../src/browser/local.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAkB,EAA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WAAW,kBAAkB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,eAAe;IAC1D,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,MAAM,CAAqB;gBAEvB,MAAM,EAAE,kBAAkB;IAItC;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IA2C7B;;;OAGG;YACW,YAAY;IA4C1B;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAqC9B;;OAEG;IACG,eAAe,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBvD;;OAEG;IACG,MAAM,CAAC,UAAU,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB/C;;OAEG;IACG,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAQ1C;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB5B;;OAEG;IACH,aAAa,IAAI,MAAM,GAAG,IAAI;IAQ9B;;;OAGG;IACG,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;IAe3C;;;OAGG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBvC;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAqBrC;;OAEG;IACG,iBAAiB,CAAC,OAAO,SAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAUvD"}
@@ -95,6 +95,8 @@ export class LocalBrowserManager {
95
95
  * Prefers pages with active plugin workers for plugin debugging
96
96
  */
97
97
  async getPage() {
98
+ // Ensure connection is alive before proceeding
99
+ await this.ensureConnection();
98
100
  if (!this.browser) {
99
101
  await this.launch();
100
102
  }
@@ -126,6 +128,8 @@ export class LocalBrowserManager {
126
128
  * Navigate to Figma URL
127
129
  */
128
130
  async navigateToFigma(figmaUrl) {
131
+ // Ensure connection is alive before navigation
132
+ await this.ensureConnection();
129
133
  const page = await this.getPage();
130
134
  // Default to Figma homepage if no URL provided
131
135
  const url = figmaUrl || 'https://www.figma.com';
@@ -207,6 +211,62 @@ export class LocalBrowserManager {
207
211
  }
208
212
  return this.page.url();
209
213
  }
214
+ /**
215
+ * Check if the browser connection is still alive
216
+ * Returns false if connection is stale (e.g., after computer sleep)
217
+ */
218
+ async isConnectionAlive() {
219
+ try {
220
+ if (!this.browser || !this.page) {
221
+ return false;
222
+ }
223
+ // Try to get the page title - this will fail if connection is dead
224
+ await this.page.title();
225
+ return true;
226
+ }
227
+ catch (error) {
228
+ logger.warn({ error }, 'Browser connection appears to be dead');
229
+ return false;
230
+ }
231
+ }
232
+ /**
233
+ * Reconnect to Figma Desktop if connection was lost
234
+ * Call this before any operation that requires a live connection
235
+ */
236
+ async ensureConnection() {
237
+ const isAlive = await this.isConnectionAlive();
238
+ if (!isAlive) {
239
+ logger.info('Connection lost, attempting to reconnect to Figma Desktop');
240
+ // Clear stale references
241
+ this.browser = null;
242
+ this.page = null;
243
+ // Reconnect
244
+ await this.launch();
245
+ logger.info('Successfully reconnected to Figma Desktop');
246
+ }
247
+ }
248
+ /**
249
+ * Force a complete reconnection to Figma Desktop
250
+ * Use this when frames become detached or stale even though the browser appears connected
251
+ */
252
+ async forceReconnect() {
253
+ logger.info('Force reconnecting to Figma Desktop');
254
+ // Disconnect current connection if exists
255
+ if (this.browser) {
256
+ try {
257
+ this.browser.disconnect();
258
+ }
259
+ catch (e) {
260
+ // Ignore disconnect errors
261
+ }
262
+ }
263
+ // Clear all references
264
+ this.browser = null;
265
+ this.page = null;
266
+ // Reconnect
267
+ await this.launch();
268
+ logger.info('Force reconnect completed');
269
+ }
210
270
  /**
211
271
  * Wait for navigation
212
272
  */
@@ -1 +1 @@
1
- {"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