figma-mcp-console 0.1.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.
Files changed (3) hide show
  1. package/README.md +18 -0
  2. package/bin.js +85 -0
  3. package/package.json +27 -0
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # figma-mcp-console
2
+
3
+ Figma MCP server for AI coding assistants — real-time read/write access to Figma Desktop via a local plugin. No API token, no rate limits.
4
+
5
+ This package is a thin launcher: on first run it downloads the prebuilt server binary for your platform from GitHub Releases and starts it.
6
+
7
+ ```json
8
+ {
9
+ "mcpServers": {
10
+ "figma-console": {
11
+ "command": "npx",
12
+ "args": ["-y", "figma-mcp-console@latest"]
13
+ }
14
+ }
15
+ }
16
+ ```
17
+
18
+ Full setup guide (including the required Figma Desktop plugin): see the [project README](https://github.com/hoangann2000/figma-mcp-console).
package/bin.js ADDED
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+ // Thin npx wrapper: downloads the figma-mcp Go binary for this platform from
3
+ // GitHub Releases (once, cached in the home directory) and executes it.
4
+ //
5
+ // IMPORTANT: stdout is the MCP JSON-RPC transport — every message from this
6
+ // wrapper must go to stderr.
7
+
8
+ "use strict";
9
+
10
+ const { spawnSync } = require("child_process");
11
+ const fs = require("fs");
12
+ const https = require("https");
13
+ const os = require("os");
14
+ const path = require("path");
15
+
16
+ const pkg = require("./package.json");
17
+ const REPO = "hoangann2000/figma-mcp-console"; // must match the GitHub repo
18
+
19
+ const GOOS = { darwin: "darwin", linux: "linux", win32: "windows" }[process.platform];
20
+ const GOARCH = { x64: "amd64", arm64: "arm64" }[process.arch];
21
+
22
+ function fail(msg) {
23
+ process.stderr.write(`figma-mcp-console: ${msg}\n`);
24
+ process.exit(1);
25
+ }
26
+
27
+ if (!GOOS || !GOARCH) fail(`unsupported platform: ${process.platform}/${process.arch}`);
28
+ if (GOOS === "windows" && GOARCH === "arm64") fail("windows/arm64 builds are not published");
29
+
30
+ const exe = GOOS === "windows" ? ".exe" : "";
31
+ const asset = `figma-mcp_${GOOS}_${GOARCH}${exe}`;
32
+ const url = `https://github.com/${REPO}/releases/download/v${pkg.version}/${asset}`;
33
+ const cacheDir = path.join(os.homedir(), ".figma-mcp-console", pkg.version);
34
+ const binPath = path.join(cacheDir, `figma-mcp${exe}`);
35
+
36
+ function download(from, dest, redirects, done) {
37
+ if (redirects > 5) return done(new Error("too many redirects"));
38
+ https
39
+ .get(from, { headers: { "User-Agent": "figma-mcp-console-npx" } }, (res) => {
40
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
41
+ res.resume();
42
+ return download(res.headers.location, dest, redirects + 1, done);
43
+ }
44
+ if (res.statusCode !== 200) {
45
+ res.resume();
46
+ return done(new Error(`GET ${from} returned ${res.statusCode}`));
47
+ }
48
+ const file = fs.createWriteStream(dest, { mode: 0o755 });
49
+ res.pipe(file);
50
+ file.on("finish", () => file.close(done));
51
+ file.on("error", done);
52
+ })
53
+ .on("error", done);
54
+ }
55
+
56
+ function run() {
57
+ const result = spawnSync(binPath, process.argv.slice(2), { stdio: "inherit" });
58
+ if (result.error) fail(`failed to start server: ${result.error.message}`);
59
+ process.exit(result.status === null ? 1 : result.status);
60
+ }
61
+
62
+ if (fs.existsSync(binPath)) {
63
+ run();
64
+ } else {
65
+ process.stderr.write(`figma-mcp-console: downloading ${asset} v${pkg.version}...\n`);
66
+ fs.mkdirSync(cacheDir, { recursive: true });
67
+ // Download to a temp name, then rename, so a concurrently started client
68
+ // never executes a half-written binary.
69
+ const tmp = `${binPath}.${process.pid}.tmp`;
70
+ download(url, tmp, 0, (err) => {
71
+ if (err) {
72
+ try { fs.unlinkSync(tmp); } catch (_) {}
73
+ fail(`download failed: ${err.message}\n from: ${url}\n Check your network, or build from source (see the repo README).`);
74
+ }
75
+ try {
76
+ fs.renameSync(tmp, binPath);
77
+ } catch (e) {
78
+ // Another process may have won the race; that's fine if the file exists.
79
+ try { fs.unlinkSync(tmp); } catch (_) {}
80
+ if (!fs.existsSync(binPath)) fail(`could not install binary: ${e.message}`);
81
+ }
82
+ process.stderr.write("figma-mcp-console: ready\n");
83
+ run();
84
+ });
85
+ }
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "figma-mcp-console",
3
+ "version": "0.1.0",
4
+ "description": "Figma MCP server for AI coding assistants — real-time read/write via a Figma Desktop plugin. No API token, no rate limits.",
5
+ "bin": {
6
+ "figma-mcp-console": "bin.js"
7
+ },
8
+ "files": [
9
+ "bin.js"
10
+ ],
11
+ "engines": {
12
+ "node": ">=18"
13
+ },
14
+ "keywords": [
15
+ "figma",
16
+ "mcp",
17
+ "model-context-protocol",
18
+ "claude",
19
+ "cursor",
20
+ "design"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/hoangann2000/figma-mcp-console.git"
25
+ },
26
+ "license": "MIT"
27
+ }