@createlex/figma-swiftui-mcp 1.0.4 → 1.0.5
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/bin/figma-swiftui-mcp.js +35 -0
- package/companion/setup.cjs +194 -0
- package/package.json +2 -1
package/bin/figma-swiftui-mcp.js
CHANGED
|
@@ -13,16 +13,19 @@ function printHelp() {
|
|
|
13
13
|
Usage:
|
|
14
14
|
npx ${PACKAGE_NAME} login
|
|
15
15
|
npx ${PACKAGE_NAME} start [--project /path/to/Xcode/source]
|
|
16
|
+
npx ${PACKAGE_NAME} setup [--force] [--dry-run]
|
|
16
17
|
|
|
17
18
|
Commands:
|
|
18
19
|
login Open the CreateLex browser login flow and save ~/.createlex/auth.json
|
|
19
20
|
start Start the local figma-swiftui MCP runtime and localhost bridge
|
|
21
|
+
setup Auto-configure MCP in Cursor, Claude, VS Code, Windsurf, and more
|
|
20
22
|
help Show this help message
|
|
21
23
|
version Show the package version
|
|
22
24
|
|
|
23
25
|
Examples:
|
|
24
26
|
npx ${PACKAGE_NAME} login
|
|
25
27
|
npx ${PACKAGE_NAME} start --project /Users/you/MyApp/MyApp
|
|
28
|
+
npx ${PACKAGE_NAME} setup
|
|
26
29
|
npm install -g ${PACKAGE_NAME}
|
|
27
30
|
${CLI_NAME} start --project /Users/you/MyApp/MyApp
|
|
28
31
|
`);
|
|
@@ -56,6 +59,24 @@ Description:
|
|
|
56
59
|
return;
|
|
57
60
|
}
|
|
58
61
|
|
|
62
|
+
if (command === 'setup') {
|
|
63
|
+
console.log(`${CLI_NAME} setup
|
|
64
|
+
|
|
65
|
+
Usage:
|
|
66
|
+
npx ${PACKAGE_NAME} setup [--force] [--dry-run]
|
|
67
|
+
|
|
68
|
+
Options:
|
|
69
|
+
--force Overwrite existing figma-swiftui config entries
|
|
70
|
+
--dry-run Show what would be configured without writing
|
|
71
|
+
|
|
72
|
+
Description:
|
|
73
|
+
Detects installed IDEs (Cursor, Claude Desktop, Claude Code, VS Code,
|
|
74
|
+
Windsurf, Antigravity) and adds the figma-swiftui MCP server entry
|
|
75
|
+
to each config file automatically.
|
|
76
|
+
`);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
59
80
|
printHelp();
|
|
60
81
|
}
|
|
61
82
|
|
|
@@ -104,6 +125,20 @@ switch (command) {
|
|
|
104
125
|
}
|
|
105
126
|
runNode(resolveEntry('start'), args);
|
|
106
127
|
break;
|
|
128
|
+
case 'setup':
|
|
129
|
+
if (wantsHelp) {
|
|
130
|
+
printCommandHelp('setup');
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
{
|
|
134
|
+
const { runSetup } = require(path.join(__dirname, '..', 'companion', 'setup.cjs'));
|
|
135
|
+
const flags = {
|
|
136
|
+
force: args.includes('--force'),
|
|
137
|
+
dryRun: args.includes('--dry-run'),
|
|
138
|
+
};
|
|
139
|
+
runSetup(flags);
|
|
140
|
+
}
|
|
141
|
+
break;
|
|
107
142
|
case 'help':
|
|
108
143
|
case '--help':
|
|
109
144
|
case '-h':
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* figma-swiftui-mcp setup
|
|
3
|
+
*
|
|
4
|
+
* Auto-detect installed IDEs / CLI tools and add the figma-swiftui MCP
|
|
5
|
+
* server entry to each config file.
|
|
6
|
+
*
|
|
7
|
+
* Supported targets:
|
|
8
|
+
* - Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json)
|
|
9
|
+
* - Claude Code (~/.claude.json → mcpServers)
|
|
10
|
+
* - Cursor (~/.cursor/mcp.json)
|
|
11
|
+
* - Windsurf (~/.codeium/windsurf/mcp_config.json)
|
|
12
|
+
* - VS Code (~/.vscode/mcp.json — user-level)
|
|
13
|
+
* - Antigravity (~/.gemini/antigravity/mcp_config.json)
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
const fs = require('node:fs');
|
|
19
|
+
const path = require('node:path');
|
|
20
|
+
const os = require('node:os');
|
|
21
|
+
|
|
22
|
+
const MCP_KEY = 'figma-swiftui';
|
|
23
|
+
|
|
24
|
+
// ── Resolve the absolute path to this binary ──────────────────────────
|
|
25
|
+
function resolveBinaryPath() {
|
|
26
|
+
// If installed globally via npm, process.argv[1] points at the bin script
|
|
27
|
+
const binScript = process.argv[1];
|
|
28
|
+
if (binScript) {
|
|
29
|
+
const resolved = fs.realpathSync(binScript);
|
|
30
|
+
const dir = path.dirname(resolved);
|
|
31
|
+
const candidate = path.join(dir, 'figma-swiftui-mcp');
|
|
32
|
+
if (fs.existsSync(candidate)) {
|
|
33
|
+
return candidate;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Fallback: search PATH
|
|
38
|
+
const whichCmd = require('node:child_process')
|
|
39
|
+
.execSync('which figma-swiftui-mcp 2>/dev/null || true')
|
|
40
|
+
.toString()
|
|
41
|
+
.trim();
|
|
42
|
+
if (whichCmd) return whichCmd;
|
|
43
|
+
|
|
44
|
+
// Last resort: use npx invocation
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ── IDE config definitions ────────────────────────────────────────────
|
|
49
|
+
function getTargets(binaryPath) {
|
|
50
|
+
const home = os.homedir();
|
|
51
|
+
|
|
52
|
+
// The entry we want in every config
|
|
53
|
+
const stdioEntry = binaryPath
|
|
54
|
+
? { command: binaryPath, args: ['start'] }
|
|
55
|
+
: { command: 'npx', args: ['-y', '@createlex/figma-swiftui-mcp', 'start'] };
|
|
56
|
+
|
|
57
|
+
const stdioEntryWithType = { type: 'stdio', ...stdioEntry };
|
|
58
|
+
|
|
59
|
+
return [
|
|
60
|
+
{
|
|
61
|
+
name: 'Claude Desktop',
|
|
62
|
+
path: path.join(home, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json'),
|
|
63
|
+
key: 'mcpServers',
|
|
64
|
+
entry: stdioEntry,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'Claude Code',
|
|
68
|
+
path: path.join(home, '.claude.json'),
|
|
69
|
+
key: 'mcpServers',
|
|
70
|
+
entry: stdioEntryWithType,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'Cursor',
|
|
74
|
+
path: path.join(home, '.cursor', 'mcp.json'),
|
|
75
|
+
key: 'mcpServers',
|
|
76
|
+
entry: stdioEntry,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'Windsurf',
|
|
80
|
+
path: path.join(home, '.codeium', 'windsurf', 'mcp_config.json'),
|
|
81
|
+
key: 'mcpServers',
|
|
82
|
+
entry: stdioEntry,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'VS Code (user)',
|
|
86
|
+
path: path.join(home, '.vscode', 'mcp.json'),
|
|
87
|
+
key: 'servers',
|
|
88
|
+
entry: stdioEntry,
|
|
89
|
+
wrapKey: null, // VS Code uses { servers: { ... } } at top level
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'Antigravity (Gemini)',
|
|
93
|
+
path: path.join(home, '.gemini', 'antigravity', 'mcp_config.json'),
|
|
94
|
+
key: 'mcpServers',
|
|
95
|
+
entry: { ...stdioEntry, env: {}, disabled: false },
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// ── Read / write helpers ──────────────────────────────────────────────
|
|
101
|
+
function readJsonSafe(filePath) {
|
|
102
|
+
try {
|
|
103
|
+
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
104
|
+
return JSON.parse(raw);
|
|
105
|
+
} catch {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function writeJsonSafe(filePath, data) {
|
|
111
|
+
const dir = path.dirname(filePath);
|
|
112
|
+
if (!fs.existsSync(dir)) {
|
|
113
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
114
|
+
}
|
|
115
|
+
fs.writeFileSync(filePath, JSON.stringify(data, null, 2) + '\n', 'utf-8');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// ── Main ──────────────────────────────────────────────────────────────
|
|
119
|
+
function runSetup(flags = {}) {
|
|
120
|
+
const force = flags.force || false;
|
|
121
|
+
const dryRun = flags.dryRun || false;
|
|
122
|
+
|
|
123
|
+
const binaryPath = resolveBinaryPath();
|
|
124
|
+
|
|
125
|
+
console.log();
|
|
126
|
+
console.log(' 🔧 figma-swiftui-mcp setup');
|
|
127
|
+
console.log(' ─────────────────────────────────────');
|
|
128
|
+
if (binaryPath) {
|
|
129
|
+
console.log(` Binary: ${binaryPath}`);
|
|
130
|
+
} else {
|
|
131
|
+
console.log(' Binary: not found — will use npx fallback');
|
|
132
|
+
}
|
|
133
|
+
console.log();
|
|
134
|
+
|
|
135
|
+
const targets = getTargets(binaryPath);
|
|
136
|
+
let configured = 0;
|
|
137
|
+
let skipped = 0;
|
|
138
|
+
let notInstalled = 0;
|
|
139
|
+
|
|
140
|
+
for (const target of targets) {
|
|
141
|
+
const exists = fs.existsSync(target.path);
|
|
142
|
+
|
|
143
|
+
if (!exists) {
|
|
144
|
+
console.log(` ⚪ ${target.name} — not installed (${path.basename(target.path)} not found)`);
|
|
145
|
+
notInstalled++;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const config = readJsonSafe(target.path);
|
|
150
|
+
if (!config) {
|
|
151
|
+
console.log(` ⚠️ ${target.name} — could not parse config`);
|
|
152
|
+
skipped++;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Ensure the server container key exists
|
|
157
|
+
if (!config[target.key]) {
|
|
158
|
+
config[target.key] = {};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const servers = config[target.key];
|
|
162
|
+
|
|
163
|
+
// Check if already configured
|
|
164
|
+
if (servers[MCP_KEY] && !force) {
|
|
165
|
+
console.log(` ✅ ${target.name} — already configured`);
|
|
166
|
+
skipped++;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Add the entry
|
|
171
|
+
servers[MCP_KEY] = target.entry;
|
|
172
|
+
|
|
173
|
+
if (dryRun) {
|
|
174
|
+
console.log(` 🟡 ${target.name} — would configure (dry run)`);
|
|
175
|
+
} else {
|
|
176
|
+
writeJsonSafe(target.path, config);
|
|
177
|
+
console.log(` ✅ ${target.name} — configured!`);
|
|
178
|
+
}
|
|
179
|
+
configured++;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
console.log();
|
|
183
|
+
console.log(` ─────────────────────────────────────`);
|
|
184
|
+
console.log(` ${configured} configured · ${skipped} skipped · ${notInstalled} not installed`);
|
|
185
|
+
|
|
186
|
+
if (configured > 0 && !dryRun) {
|
|
187
|
+
console.log();
|
|
188
|
+
console.log(' 💡 Restart your IDE(s) for the new MCP config to take effect.');
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
console.log();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
module.exports = { runSetup };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@createlex/figma-swiftui-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "CreateLex MCP runtime for Figma-to-SwiftUI generation and Xcode export",
|
|
5
5
|
"bin": {
|
|
6
6
|
"figma-swiftui-mcp": "bin/figma-swiftui-mcp.js"
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"companion/mcp-server.mjs",
|
|
14
14
|
"companion/package.json",
|
|
15
15
|
"companion/server.js",
|
|
16
|
+
"companion/setup.cjs",
|
|
16
17
|
"companion/xcode-writer.cjs",
|
|
17
18
|
"README.md"
|
|
18
19
|
],
|