figma-rust-mcp 2.8.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.
- package/LICENSE +21 -0
- package/README.md +189 -0
- package/bin/figma-mcp.js +445 -0
- package/package.json +60 -0
- package/plugin/code.js +5257 -0
- package/plugin/icon16.png +0 -0
- package/plugin/icon32.png +0 -0
- package/plugin/manifest.json +24 -0
- package/plugin/ui.html +998 -0
- package/scripts/build-plugin.js +34 -0
- package/scripts/test-rust-mcp.sh +40 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Build script — concatenate src/plugin/*.js into plugin/code.js
|
|
2
|
+
// No module system used: files are plain JS sharing a single scope when concatenated.
|
|
3
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
4
|
+
|
|
5
|
+
const { version } = JSON.parse(readFileSync("package.json", "utf8"));
|
|
6
|
+
|
|
7
|
+
const files = [
|
|
8
|
+
"plugin-src/utils.js",
|
|
9
|
+
"plugin-src/svg-path-helpers.js",
|
|
10
|
+
"plugin-src/paint-and-effects.js",
|
|
11
|
+
"plugin-src/read-helpers.js",
|
|
12
|
+
"plugin-src/handlers-write.js",
|
|
13
|
+
"plugin-src/handlers-library.js",
|
|
14
|
+
"plugin-src/handlers-read.js",
|
|
15
|
+
"plugin-src/handlers-read-detail.js",
|
|
16
|
+
"plugin-src/handlers-tokens.js",
|
|
17
|
+
"plugin-src/handlers-write-ops.js",
|
|
18
|
+
"plugin-src/main.js",
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const banner = `// figma-mcp — Figma Plugin main thread v1.2.1
|
|
22
|
+
// Handles both WRITE (draw UI) and READ (extract design) operations.
|
|
23
|
+
// AUTO-GENERATED by scripts/build-plugin.js — edit plugin-src/*.js instead
|
|
24
|
+
// Generated: ${new Date().toISOString()}
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
const parts = files.map(f => {
|
|
28
|
+
const content = readFileSync(f, "utf8");
|
|
29
|
+
return `\n// ── ${f} ──\n${content}`;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const output = (banner + parts.join("\n")).replace(/\{\{PLUGIN_VERSION\}\}/g, version);
|
|
33
|
+
writeFileSync("plugin/code.js", output);
|
|
34
|
+
console.log(`✓ plugin/code.js written (${output.length} chars, ${output.split("\n").length} lines)`);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
BIN_PATH="target/release/figma-mcp"
|
|
5
|
+
if [ ! -f "$BIN_PATH" ]; then
|
|
6
|
+
BIN_PATH="target/debug/figma-mcp"
|
|
7
|
+
fi
|
|
8
|
+
|
|
9
|
+
echo "Testing binary: $BIN_PATH"
|
|
10
|
+
|
|
11
|
+
# Test 1: CLI Version
|
|
12
|
+
echo "--- Test 1: Version check ---"
|
|
13
|
+
$BIN_PATH --version
|
|
14
|
+
|
|
15
|
+
# Test 2: MCP Protocol JSON-RPC
|
|
16
|
+
echo "--- Test 2: MCP Stdio JSON-RPC ---"
|
|
17
|
+
INPUT=$(cat << 'JSON'
|
|
18
|
+
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test-client","version":"1.0.0"}}}
|
|
19
|
+
{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}
|
|
20
|
+
{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"figma_docs","arguments":{"section":"icons"}}}
|
|
21
|
+
{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"figma_status","arguments":{}}}
|
|
22
|
+
JSON
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
OUTPUT=$(echo "$INPUT" | $BIN_PATH --port 38499 2>/dev/null)
|
|
26
|
+
echo "$OUTPUT" | head -n 4
|
|
27
|
+
|
|
28
|
+
# Verify tool registration in JSON-RPC output
|
|
29
|
+
echo "--- Test 3: Verify Tool Registrations ---"
|
|
30
|
+
echo "$OUTPUT" | grep -q "figma_get_selection" && echo "✓ figma_get_selection registered"
|
|
31
|
+
echo "$OUTPUT" | grep -q "figma_inspect_node" && echo "✓ figma_inspect_node registered"
|
|
32
|
+
echo "$OUTPUT" | grep -q "figma_export_asset" && echo "✓ figma_export_asset registered"
|
|
33
|
+
echo "$OUTPUT" | grep -q "figma_read" && echo "✓ figma_read registered"
|
|
34
|
+
echo "$OUTPUT" | grep -q "figma_write" && echo "✓ figma_write registered"
|
|
35
|
+
|
|
36
|
+
# Test 4: Node/NPX wrapper test
|
|
37
|
+
echo "--- Test 4: NPX Wrapper ---"
|
|
38
|
+
node bin/figma-mcp.js --version
|
|
39
|
+
|
|
40
|
+
echo "--- All Tests completed successfully! ---"
|