@matthesketh/utopia-cli 0.7.1 → 0.7.3
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/dist/index.js +25 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -134,7 +134,9 @@ async function mcpServe() {
|
|
|
134
134
|
const content = await server.ssrLoadModule("@matthesketh/utopia-content");
|
|
135
135
|
const names = content.listCollections();
|
|
136
136
|
if (names.length === 0) {
|
|
137
|
-
process.stderr.write(
|
|
137
|
+
process.stderr.write(
|
|
138
|
+
"No collections defined. Add defineCollection() calls to your config.\n"
|
|
139
|
+
);
|
|
138
140
|
process.exit(1);
|
|
139
141
|
}
|
|
140
142
|
const contentMcp = await server.ssrLoadModule("@matthesketh/utopia-content/mcp");
|
|
@@ -216,15 +218,32 @@ async function mcpServe() {
|
|
|
216
218
|
}
|
|
217
219
|
}
|
|
218
220
|
}
|
|
221
|
+
function findClaude() {
|
|
222
|
+
const candidates = [
|
|
223
|
+
"claude",
|
|
224
|
+
resolve(process.env.HOME ?? "~", ".local/bin/claude"),
|
|
225
|
+
resolve(process.env.HOME ?? "~", ".npm-global/bin/claude"),
|
|
226
|
+
"/usr/local/bin/claude"
|
|
227
|
+
];
|
|
228
|
+
for (const bin of candidates) {
|
|
229
|
+
try {
|
|
230
|
+
execSync(`${bin} --version`, { stdio: "ignore" });
|
|
231
|
+
return bin;
|
|
232
|
+
} catch {
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
219
237
|
function mcpInstall() {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
238
|
+
const claude = findClaude();
|
|
239
|
+
if (!claude) {
|
|
240
|
+
console.error(
|
|
241
|
+
"Claude Code CLI not found. Install it first: npm i -g @anthropic-ai/claude-code"
|
|
242
|
+
);
|
|
224
243
|
process.exit(1);
|
|
225
244
|
}
|
|
226
245
|
try {
|
|
227
|
-
execSync(
|
|
246
|
+
execSync(`${claude} mcp add utopia-content -s project -- npx utopia mcp serve`, {
|
|
228
247
|
stdio: "inherit",
|
|
229
248
|
cwd: process.cwd()
|
|
230
249
|
});
|