zapcode-figma-mcp 1.1.2 → 1.2.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 +24 -1
- package/build/index.js +24 -6
- package/package.json +3 -2
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
|
[](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
|
|
|
@@ -42,6 +46,24 @@ Add to your `claude_desktop_config.json`:
|
|
|
42
46
|
|
|
43
47
|
Restart Claude Desktop after making changes.
|
|
44
48
|
|
|
49
|
+
### Claude Code
|
|
50
|
+
|
|
51
|
+
Add to your `claude_code_config.json`:
|
|
52
|
+
|
|
53
|
+
**macOS/Linux**: `~/.config/claude-code/claude_code_config.json`
|
|
54
|
+
**Windows**: `%APPDATA%\claude-code\claude_code_config.json`
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"mcpServers": {
|
|
59
|
+
"zapcode-figma": {
|
|
60
|
+
"command": "npx",
|
|
61
|
+
"args": ["-y", "zapcode-figma-mcp"]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
45
67
|
### Cursor
|
|
46
68
|
|
|
47
69
|
Add to your MCP settings configuration:
|
|
@@ -186,6 +208,7 @@ assets/
|
|
|
186
208
|
This server works with any MCP-compatible client, including:
|
|
187
209
|
|
|
188
210
|
- [Claude Desktop](https://modelcontextprotocol.io/clients#claude-desktop) - Anthropic's desktop application
|
|
211
|
+
- [Claude Code](https://claude.com/claude-code) - Anthropic's official CLI for Claude
|
|
189
212
|
- [Cursor](https://www.cursor.com/) - AI-first code editor
|
|
190
213
|
- [Cline](https://github.com/cline/cline) - Autonomous coding agent for VS Code
|
|
191
214
|
- [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
|
-
|
|
30
|
-
|
|
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 ===
|
|
53
|
-
throw new Error(`No available ports in
|
|
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.
|
|
3
|
+
"version": "1.2.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": {
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"author": "Zapcode",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"files": [
|
|
24
|
-
"build/"
|
|
24
|
+
"build/",
|
|
25
|
+
"README.md"
|
|
25
26
|
],
|
|
26
27
|
"dependencies": {
|
|
27
28
|
"@modelcontextprotocol/sdk": "^1.9.0",
|