@danainnovations/cortex-mcp 1.0.76 → 1.0.77
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/cli.js +40 -18
- package/dist/cli.js.map +1 -1
- package/dist/index.js +40 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1273,31 +1273,53 @@ function configureClaudeDesktop(_serverUrl, apiKey, _mcps) {
|
|
|
1273
1273
|
if (!existsSync3(dir)) {
|
|
1274
1274
|
mkdirSync3(dir, { recursive: true });
|
|
1275
1275
|
}
|
|
1276
|
-
let config = {};
|
|
1277
|
-
if (existsSync3(configPath)) {
|
|
1278
|
-
try {
|
|
1279
|
-
config = JSON.parse(readFileSync4(configPath, "utf-8"));
|
|
1280
|
-
} catch {
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
if (!config.mcpServers || typeof config.mcpServers !== "object") {
|
|
1284
|
-
config.mcpServers = {};
|
|
1285
|
-
}
|
|
1286
|
-
const servers = config.mcpServers;
|
|
1287
|
-
for (const key of Object.keys(servers)) {
|
|
1288
|
-
if (key.startsWith("cortex-") || key === "cortex") {
|
|
1289
|
-
delete servers[key];
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
1276
|
const isWindows = getPlatform() === "windows";
|
|
1293
|
-
|
|
1277
|
+
const cortexEntry = isWindows ? {
|
|
1294
1278
|
command: "cmd",
|
|
1295
1279
|
args: ["/c", "npx", "-y", "@danainnovations/cortex-mcp@latest", "serve"]
|
|
1296
1280
|
} : {
|
|
1297
1281
|
command: "npx",
|
|
1298
1282
|
args: ["-y", "@danainnovations/cortex-mcp@latest", "serve"]
|
|
1299
1283
|
};
|
|
1300
|
-
|
|
1284
|
+
const maxAttempts = isWindows ? 3 : 1;
|
|
1285
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
1286
|
+
let config = {};
|
|
1287
|
+
if (existsSync3(configPath)) {
|
|
1288
|
+
try {
|
|
1289
|
+
config = JSON.parse(readFileSync4(configPath, "utf-8"));
|
|
1290
|
+
} catch {
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
if (!config.mcpServers || typeof config.mcpServers !== "object") {
|
|
1294
|
+
config.mcpServers = {};
|
|
1295
|
+
}
|
|
1296
|
+
const servers = config.mcpServers;
|
|
1297
|
+
for (const key of Object.keys(servers)) {
|
|
1298
|
+
if (key.startsWith("cortex-") || key === "cortex") {
|
|
1299
|
+
delete servers[key];
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
servers["cortex"] = cortexEntry;
|
|
1303
|
+
writeFileSync3(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
1304
|
+
if (isWindows) {
|
|
1305
|
+
const start = Date.now();
|
|
1306
|
+
while (Date.now() - start < 500) {
|
|
1307
|
+
}
|
|
1308
|
+
try {
|
|
1309
|
+
const verify = JSON.parse(readFileSync4(configPath, "utf-8"));
|
|
1310
|
+
const verifyServers = verify.mcpServers;
|
|
1311
|
+
if (verifyServers && "cortex" in verifyServers) {
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
} catch {
|
|
1315
|
+
}
|
|
1316
|
+
continue;
|
|
1317
|
+
}
|
|
1318
|
+
return;
|
|
1319
|
+
}
|
|
1320
|
+
throw new Error(
|
|
1321
|
+
"Claude Desktop is overwriting the config file. Please close Claude Desktop completely (quit from the system tray), then re-run setup."
|
|
1322
|
+
);
|
|
1301
1323
|
}
|
|
1302
1324
|
function configureClaudeCode(serverUrl, apiKey, mcps) {
|
|
1303
1325
|
for (const mcp of AVAILABLE_MCPS) {
|