zapcode-figma-mcp 1.1.3 → 1.3.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,9 +1,13 @@
1
+ # ZapCode Figma MCP Server
2
+
3
+ <p align="center"><img src="./assets/Zapcode.png" alt="ZapCode Logo" width="400"></p>
4
+
1
5
  # Zapcode Figma MCP Server
2
6
 
3
7
  [![npm version](https://img.shields.io/npm/v/zapcode-figma-mcp.svg)](https://www.npmjs.com/package/zapcode-figma-mcp)
4
8
 
5
9
 
6
- Connect your Figma designs directly to AI tools like Claude Desktop, Cursor, and Cline. Get real-time HTML, CSS, images, and assets from selected Figma frames through the Model Context Protocol.
10
+ Connect your Figma designs directly to AI tools like Claude Desktop, Claude Code, Cursor, and Cline. Get real-time HTML, CSS, images, and assets from selected Figma frames through the Model Context Protocol.
7
11
 
8
12
  ## Features
9
13
 
@@ -17,11 +21,13 @@ Connect your Figma designs directly to AI tools like Claude Desktop, Cursor, and
17
21
  ## Prerequisites
18
22
 
19
23
  1. **Node.js 16+** - [Download here](https://nodejs.org/)
20
- 2. **Figma Desktop App** - Required for plugin integration
24
+ 2. **Figma Desktop or Web** - Required for plugin
21
25
  3. **[Zapcode Figma Plugin](https://www.figma.com/community/plugin/1454956820198178710/zapcode)** - Install from Figma Community
22
26
 
23
27
  ## Installation
24
28
 
29
+ > **Note**: The `--figma-port` argument specifies which port to use for communication with the Figma plugin. Default is `32896`. You can customize this port if needed (e.g., to run multiple instances or if the default port is already in use).
30
+
25
31
  ### Claude Desktop
26
32
 
27
33
  Add to your `claude_desktop_config.json`:
@@ -34,7 +40,7 @@ Add to your `claude_desktop_config.json`:
34
40
  "mcpServers": {
35
41
  "zapcode-figma": {
36
42
  "command": "npx",
37
- "args": ["-y", "zapcode-figma-mcp"]
43
+ "args": ["-y", "zapcode-figma-mcp", "--figma-port", "61234"]
38
44
  }
39
45
  }
40
46
  }
@@ -42,6 +48,32 @@ Add to your `claude_desktop_config.json`:
42
48
 
43
49
  Restart Claude Desktop after making changes.
44
50
 
51
+
52
+
53
+ ### Claude Code
54
+
55
+ Add to your `claude_code_config.json`:
56
+
57
+ **macOS/Linux**: `~/.config/claude-code/claude_code_config.json`
58
+ **Windows**: `%APPDATA%\claude-code\claude_code_config.json`
59
+
60
+ ```json
61
+ {
62
+ "mcpServers": {
63
+ "zapcode-figma": {
64
+ "command": "npx",
65
+ "args": ["-y", "zapcode-figma-mcp", "--figma-port", "61234"]
66
+ }
67
+ }
68
+ }
69
+ ```
70
+
71
+ or run
72
+
73
+ ```sh
74
+ claude mcp add --transport stdio zapcode -- npx -y zapcode-figma-mcp --figma-port 61234
75
+ ```
76
+
45
77
  ### Cursor
46
78
 
47
79
  Add to your MCP settings configuration:
@@ -51,7 +83,7 @@ Add to your MCP settings configuration:
51
83
  "mcpServers": {
52
84
  "zapcode-figma": {
53
85
  "command": "npx",
54
- "args": ["-y", "zapcode-figma-mcp"]
86
+ "args": ["-y", "zapcode-figma-mcp", "--figma-port", "61234"]
55
87
  }
56
88
  }
57
89
  }
@@ -66,7 +98,7 @@ Add to Cline's MCP settings:
66
98
  "mcpServers": {
67
99
  "zapcode-figma": {
68
100
  "command": "npx",
69
- "args": ["-y", "zapcode-figma-mcp"]
101
+ "args": ["-y", "zapcode-figma-mcp", "--figma-port", "61234"]
70
102
  }
71
103
  }
72
104
  }
@@ -81,7 +113,7 @@ Add to your Windsurf MCP configuration:
81
113
  "mcpServers": {
82
114
  "zapcode-figma": {
83
115
  "command": "npx",
84
- "args": ["-y", "zapcode-figma-mcp"]
116
+ "args": ["-y", "zapcode-figma-mcp", "--figma-port", "61234"]
85
117
  }
86
118
  }
87
119
  }
@@ -96,7 +128,7 @@ Add to your Zed settings (MCP support currently in preview):
96
128
  "context_servers": {
97
129
  "zapcode-figma": {
98
130
  "command": "npx",
99
- "args": ["-y", "zapcode-figma-mcp"]
131
+ "args": ["-y", "zapcode-figma-mcp", "--figma-port", "61234"]
100
132
  }
101
133
  }
102
134
  }
@@ -111,7 +143,7 @@ Add to Continue's configuration:
111
143
  "mcpServers": {
112
144
  "zapcode-figma": {
113
145
  "command": "npx",
114
- "args": ["-y", "zapcode-figma-mcp"]
146
+ "args": ["-y", "zapcode-figma-mcp", "--figma-port", "61234"]
115
147
  }
116
148
  }
117
149
  }
@@ -127,7 +159,7 @@ Add to your GitHub Copilot MCP configuration:
127
159
  "zapcode-figma": {
128
160
  "type": "stdio",
129
161
  "command": "npx",
130
- "args": ["-y", "zapcode-figma-mcp"]
162
+ "args": ["-y", "zapcode-figma-mcp", "--figma-port", "61234"]
131
163
  }
132
164
  }
133
165
  }
@@ -186,6 +218,7 @@ assets/
186
218
  This server works with any MCP-compatible client, including:
187
219
 
188
220
  - [Claude Desktop](https://modelcontextprotocol.io/clients#claude-desktop) - Anthropic's desktop application
221
+ - [Claude Code](https://claude.com/claude-code) - Anthropic's official CLI for Claude
189
222
  - [Cursor](https://www.cursor.com/) - AI-first code editor
190
223
  - [Cline](https://github.com/cline/cline) - Autonomous coding agent for VS Code
191
224
  - [Windsurf](https://codeium.com/windsurf) - AI-powered IDE with MCP Plugin Store
package/build/index.js CHANGED
@@ -7,6 +7,12 @@ import * as fs from "fs";
7
7
  import * as path from "path";
8
8
  // --- Default Port for Figma Connection ---
9
9
  const DEFAULT_FIGMA_SOCKET_IO_PORT = 32896;
10
+ // --- Allowed Ports (must match Figma plugin manifest) ---
11
+ const ALLOWED_PORTS = [
12
+ 3000, 3001, 5000, 5173, 8000, 8080, 8888, 9000,
13
+ 32044, 32896, 32897, 32898, 32899,
14
+ 40000, 50000, 54321, 60000, 61234, 62000, 63000
15
+ ];
10
16
  // --- Global Variables for Figma Connection ---
11
17
  let figmaHttpServer = null;
12
18
  let io = null;
@@ -19,22 +25,34 @@ function parseArgs() {
19
25
  const figmaPortArgIndex = args.findIndex((arg) => arg === "--figma-port");
20
26
  if (figmaPortArgIndex !== -1 && args[figmaPortArgIndex + 1]) {
21
27
  const port = parseInt(args[figmaPortArgIndex + 1], 10);
22
- if (!isNaN(port))
28
+ if (!isNaN(port)) {
29
+ // Validate port is in allowed list
30
+ if (!ALLOWED_PORTS.includes(port)) {
31
+ console.error(`Zapcode: Warning - Port ${port} is not in the allowed ports list.`);
32
+ console.error(`Zapcode: Allowed ports: ${ALLOWED_PORTS.join(', ')}`);
33
+ console.error(`Zapcode: The Figma plugin may not be able to connect to this port.`);
34
+ }
23
35
  figmaPort = port;
36
+ }
24
37
  }
25
38
  return { figmaPort };
26
39
  }
27
40
  // --- Helper: Find Available Port ---
28
41
  async function findAvailablePort(startPort, maxAttempts = 4) {
29
- for (let i = 0; i < maxAttempts; i++) {
30
- const port = startPort + i;
42
+ // Find the starting port in the allowed ports list
43
+ const startIndex = ALLOWED_PORTS.indexOf(startPort);
44
+ const portsToTry = startIndex >= 0
45
+ ? ALLOWED_PORTS.slice(startIndex, startIndex + maxAttempts)
46
+ : ALLOWED_PORTS.slice(0, maxAttempts);
47
+ for (let i = 0; i < portsToTry.length; i++) {
48
+ const port = portsToTry[i];
31
49
  try {
32
50
  const testServer = createHttpServer();
33
51
  await new Promise((resolve, reject) => {
34
52
  testServer.once('error', (err) => {
35
53
  testServer.close();
36
54
  if (err.code === 'EADDRINUSE') {
37
- console.error(`Zapcode: Port ${port} is already in use, trying next port...`);
55
+ console.error(`Zapcode: Port ${port} is already in use, trying next allowed port...`);
38
56
  reject(err);
39
57
  }
40
58
  else {
@@ -49,8 +67,8 @@ async function findAvailablePort(startPort, maxAttempts = 4) {
49
67
  return port;
50
68
  }
51
69
  catch (err) {
52
- if (err.code !== 'EADDRINUSE' || i === maxAttempts - 1) {
53
- throw new Error(`No available ports in range ${startPort}-${startPort + maxAttempts - 1}`);
70
+ if (err.code !== 'EADDRINUSE' || i === portsToTry.length - 1) {
71
+ throw new Error(`No available ports found in allowed ports list. Tried: ${portsToTry.join(', ')}`);
54
72
  }
55
73
  // Continue to next port
56
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zapcode-figma-mcp",
3
- "version": "1.1.3",
3
+ "version": "1.3.0",
4
4
  "description": "An MCP server that exposes Figma context via a plugin and saves assets, from Zapcode.",
5
5
  "type": "module",
6
6
  "bin": {