@danainnovations/cortex-mcp 1.0.77 → 1.0.78
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/browser-S7WMSQYY.js +8 -0
- package/dist/{chunk-AUMRZ53L.js → chunk-YA4Q2GAN.js} +39 -1
- package/dist/chunk-YA4Q2GAN.js.map +1 -0
- package/dist/cli.js +15 -13
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +65 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/browser-WFTDXNKP.js +0 -8
- package/dist/chunk-AUMRZ53L.js.map +0 -1
- /package/dist/{browser-WFTDXNKP.js.map → browser-S7WMSQYY.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -78,7 +78,7 @@ declare function detectClients(): DetectedClient[];
|
|
|
78
78
|
* Uses command/args/env format (Claude Desktop does not support HTTP url/headers).
|
|
79
79
|
* Preserves existing non-Cortex entries.
|
|
80
80
|
*/
|
|
81
|
-
declare function configureClaudeDesktop(_serverUrl: string, apiKey: string, _mcps: string[]):
|
|
81
|
+
declare function configureClaudeDesktop(_serverUrl: string, apiKey: string, _mcps: string[]): string;
|
|
82
82
|
/**
|
|
83
83
|
* Configure Claude Code by running `claude mcp add` commands.
|
|
84
84
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1083,12 +1083,14 @@ async function startStdioServer(options) {
|
|
|
1083
1083
|
}
|
|
1084
1084
|
|
|
1085
1085
|
// src/config/storage.ts
|
|
1086
|
-
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as
|
|
1086
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
|
|
1087
1087
|
import { join as join3 } from "path";
|
|
1088
1088
|
|
|
1089
1089
|
// src/utils/platform.ts
|
|
1090
1090
|
import { homedir, platform } from "os";
|
|
1091
1091
|
import { join as join2 } from "path";
|
|
1092
|
+
import { readFileSync as readFileSync3, readdirSync as readdirSync2 } from "fs";
|
|
1093
|
+
import { execSync } from "child_process";
|
|
1092
1094
|
function getHomeDir() {
|
|
1093
1095
|
return homedir();
|
|
1094
1096
|
}
|
|
@@ -1098,9 +1100,44 @@ function getPlatform() {
|
|
|
1098
1100
|
if (p === "win32") return "windows";
|
|
1099
1101
|
return "linux";
|
|
1100
1102
|
}
|
|
1103
|
+
function isWSL() {
|
|
1104
|
+
if (getPlatform() !== "linux") return false;
|
|
1105
|
+
try {
|
|
1106
|
+
const version = readFileSync3("/proc/version", "utf-8");
|
|
1107
|
+
return /microsoft|wsl/i.test(version);
|
|
1108
|
+
} catch {
|
|
1109
|
+
return false;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
function getWindowsHomeFromWSL() {
|
|
1113
|
+
try {
|
|
1114
|
+
const raw = execSync("cmd.exe /c echo %USERNAME%", {
|
|
1115
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
1116
|
+
timeout: 5e3
|
|
1117
|
+
}).toString().trim().replace(/\r/g, "");
|
|
1118
|
+
if (raw && raw !== "%USERNAME%") {
|
|
1119
|
+
return `/mnt/c/Users/${raw}`;
|
|
1120
|
+
}
|
|
1121
|
+
} catch {
|
|
1122
|
+
}
|
|
1123
|
+
try {
|
|
1124
|
+
const dirs = readdirSync2("/mnt/c/Users").filter(
|
|
1125
|
+
(d) => d !== "Public" && d !== "Default" && d !== "Default User" && d !== "All Users" && !d.startsWith(".")
|
|
1126
|
+
);
|
|
1127
|
+
if (dirs.length === 1) return `/mnt/c/Users/${dirs[0]}`;
|
|
1128
|
+
} catch {
|
|
1129
|
+
}
|
|
1130
|
+
return null;
|
|
1131
|
+
}
|
|
1101
1132
|
function getClaudeDesktopConfigPath() {
|
|
1102
1133
|
const home = getHomeDir();
|
|
1103
1134
|
const p = getPlatform();
|
|
1135
|
+
if (p === "linux" && isWSL()) {
|
|
1136
|
+
const winHome = getWindowsHomeFromWSL();
|
|
1137
|
+
if (winHome) {
|
|
1138
|
+
return join2(winHome, "AppData", "Roaming", "Claude", "claude_desktop_config.json");
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1104
1141
|
switch (p) {
|
|
1105
1142
|
case "macos":
|
|
1106
1143
|
return join2(
|
|
@@ -1148,7 +1185,7 @@ function readConfig() {
|
|
|
1148
1185
|
const path = getConfigPath();
|
|
1149
1186
|
if (!existsSync2(path)) return null;
|
|
1150
1187
|
try {
|
|
1151
|
-
const raw =
|
|
1188
|
+
const raw = readFileSync4(path, "utf-8");
|
|
1152
1189
|
return JSON.parse(raw);
|
|
1153
1190
|
} catch {
|
|
1154
1191
|
return null;
|
|
@@ -1175,10 +1212,10 @@ function createConfig(apiKey, mcps) {
|
|
|
1175
1212
|
}
|
|
1176
1213
|
|
|
1177
1214
|
// src/config/clients.ts
|
|
1178
|
-
import { existsSync as existsSync3, readFileSync as
|
|
1215
|
+
import { existsSync as existsSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
1179
1216
|
import { dirname as dirname2 } from "path";
|
|
1180
1217
|
import { mkdirSync as mkdirSync3 } from "fs";
|
|
1181
|
-
import { execSync } from "child_process";
|
|
1218
|
+
import { execSync as execSync2 } from "child_process";
|
|
1182
1219
|
import { homedir as homedir2 } from "os";
|
|
1183
1220
|
import { join as join4 } from "path";
|
|
1184
1221
|
function detectClients() {
|
|
@@ -1193,7 +1230,7 @@ function detectClients() {
|
|
|
1193
1230
|
});
|
|
1194
1231
|
let claudeCodeDetected = false;
|
|
1195
1232
|
try {
|
|
1196
|
-
|
|
1233
|
+
execSync2("which claude", { stdio: "pipe" });
|
|
1197
1234
|
claudeCodeDetected = true;
|
|
1198
1235
|
} catch {
|
|
1199
1236
|
}
|
|
@@ -1230,7 +1267,7 @@ function detectClients() {
|
|
|
1230
1267
|
let codexDetected = existsSync3(join4(home, ".codex"));
|
|
1231
1268
|
if (!codexDetected) {
|
|
1232
1269
|
try {
|
|
1233
|
-
|
|
1270
|
+
execSync2("which codex", { stdio: "pipe" });
|
|
1234
1271
|
codexDetected = true;
|
|
1235
1272
|
} catch {
|
|
1236
1273
|
}
|
|
@@ -1273,20 +1310,20 @@ function configureClaudeDesktop(_serverUrl, apiKey, _mcps) {
|
|
|
1273
1310
|
if (!existsSync3(dir)) {
|
|
1274
1311
|
mkdirSync3(dir, { recursive: true });
|
|
1275
1312
|
}
|
|
1276
|
-
const
|
|
1277
|
-
const cortexEntry =
|
|
1313
|
+
const isWindowsTarget = getPlatform() === "windows" || isWSL();
|
|
1314
|
+
const cortexEntry = isWindowsTarget ? {
|
|
1278
1315
|
command: "cmd",
|
|
1279
1316
|
args: ["/c", "npx", "-y", "@danainnovations/cortex-mcp@latest", "serve"]
|
|
1280
1317
|
} : {
|
|
1281
1318
|
command: "npx",
|
|
1282
1319
|
args: ["-y", "@danainnovations/cortex-mcp@latest", "serve"]
|
|
1283
1320
|
};
|
|
1284
|
-
const maxAttempts =
|
|
1321
|
+
const maxAttempts = isWindowsTarget ? 3 : 1;
|
|
1285
1322
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
1286
1323
|
let config = {};
|
|
1287
1324
|
if (existsSync3(configPath)) {
|
|
1288
1325
|
try {
|
|
1289
|
-
config = JSON.parse(
|
|
1326
|
+
config = JSON.parse(readFileSync5(configPath, "utf-8"));
|
|
1290
1327
|
} catch {
|
|
1291
1328
|
}
|
|
1292
1329
|
}
|
|
@@ -1301,21 +1338,21 @@ function configureClaudeDesktop(_serverUrl, apiKey, _mcps) {
|
|
|
1301
1338
|
}
|
|
1302
1339
|
servers["cortex"] = cortexEntry;
|
|
1303
1340
|
writeFileSync3(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
1304
|
-
if (
|
|
1341
|
+
if (isWindowsTarget) {
|
|
1305
1342
|
const start = Date.now();
|
|
1306
1343
|
while (Date.now() - start < 500) {
|
|
1307
1344
|
}
|
|
1308
1345
|
try {
|
|
1309
|
-
const verify = JSON.parse(
|
|
1346
|
+
const verify = JSON.parse(readFileSync5(configPath, "utf-8"));
|
|
1310
1347
|
const verifyServers = verify.mcpServers;
|
|
1311
1348
|
if (verifyServers && "cortex" in verifyServers) {
|
|
1312
|
-
return;
|
|
1349
|
+
return configPath;
|
|
1313
1350
|
}
|
|
1314
1351
|
} catch {
|
|
1315
1352
|
}
|
|
1316
1353
|
continue;
|
|
1317
1354
|
}
|
|
1318
|
-
return;
|
|
1355
|
+
return configPath;
|
|
1319
1356
|
}
|
|
1320
1357
|
throw new Error(
|
|
1321
1358
|
"Claude Desktop is overwriting the config file. Please close Claude Desktop completely (quit from the system tray), then re-run setup."
|
|
@@ -1326,10 +1363,10 @@ function configureClaudeCode(serverUrl, apiKey, mcps) {
|
|
|
1326
1363
|
if (!mcps.includes(mcp.name)) continue;
|
|
1327
1364
|
const url = `${serverUrl}/mcp/${mcp.name}`;
|
|
1328
1365
|
try {
|
|
1329
|
-
|
|
1366
|
+
execSync2(`claude mcp remove ${mcp.serverName}`, { stdio: "pipe" });
|
|
1330
1367
|
} catch {
|
|
1331
1368
|
}
|
|
1332
|
-
|
|
1369
|
+
execSync2(
|
|
1333
1370
|
`claude mcp add --transport http ${mcp.serverName} ${url} -H "x-api-key: ${apiKey}"`,
|
|
1334
1371
|
{ stdio: "pipe" }
|
|
1335
1372
|
);
|
|
@@ -1344,7 +1381,7 @@ function configureCursor(serverUrl, apiKey, mcps) {
|
|
|
1344
1381
|
let config = {};
|
|
1345
1382
|
if (existsSync3(configPath)) {
|
|
1346
1383
|
try {
|
|
1347
|
-
config = JSON.parse(
|
|
1384
|
+
config = JSON.parse(readFileSync5(configPath, "utf-8"));
|
|
1348
1385
|
} catch {
|
|
1349
1386
|
}
|
|
1350
1387
|
}
|
|
@@ -1370,7 +1407,7 @@ function configureVSCode(serverUrl, apiKey, mcps) {
|
|
|
1370
1407
|
let config = {};
|
|
1371
1408
|
if (existsSync3(configPath)) {
|
|
1372
1409
|
try {
|
|
1373
|
-
config = JSON.parse(
|
|
1410
|
+
config = JSON.parse(readFileSync5(configPath, "utf-8"));
|
|
1374
1411
|
} catch {
|
|
1375
1412
|
}
|
|
1376
1413
|
}
|
|
@@ -1396,7 +1433,7 @@ function configureAntigravity(serverUrl, apiKey, mcps) {
|
|
|
1396
1433
|
let config = {};
|
|
1397
1434
|
if (existsSync3(configPath)) {
|
|
1398
1435
|
try {
|
|
1399
|
-
config = JSON.parse(
|
|
1436
|
+
config = JSON.parse(readFileSync5(configPath, "utf-8"));
|
|
1400
1437
|
} catch {
|
|
1401
1438
|
}
|
|
1402
1439
|
}
|
|
@@ -1422,7 +1459,7 @@ function configureCodex(serverUrl, apiKey, mcps) {
|
|
|
1422
1459
|
let existingContent = "";
|
|
1423
1460
|
if (existsSync3(configPath)) {
|
|
1424
1461
|
try {
|
|
1425
|
-
existingContent =
|
|
1462
|
+
existingContent = readFileSync5(configPath, "utf-8");
|
|
1426
1463
|
} catch {
|
|
1427
1464
|
}
|
|
1428
1465
|
}
|
|
@@ -1462,10 +1499,10 @@ function configurePerplexity(serverUrl, _apiKey, mcps) {
|
|
|
1462
1499
|
return lines.join("\n");
|
|
1463
1500
|
}
|
|
1464
1501
|
function generateStdioSnippet(_apiKey) {
|
|
1465
|
-
const
|
|
1502
|
+
const isWindowsTarget = getPlatform() === "windows" || isWSL();
|
|
1466
1503
|
const config = {
|
|
1467
1504
|
mcpServers: {
|
|
1468
|
-
cortex:
|
|
1505
|
+
cortex: isWindowsTarget ? {
|
|
1469
1506
|
command: "cmd",
|
|
1470
1507
|
args: ["/c", "npx", "-y", "@danainnovations/cortex-mcp@latest", "serve"]
|
|
1471
1508
|
} : {
|
|
@@ -1478,9 +1515,10 @@ function generateStdioSnippet(_apiKey) {
|
|
|
1478
1515
|
}
|
|
1479
1516
|
function configureClient(clientType, serverUrl, apiKey, mcps) {
|
|
1480
1517
|
switch (clientType) {
|
|
1481
|
-
case "claude-desktop":
|
|
1482
|
-
configureClaudeDesktop(serverUrl, apiKey, mcps);
|
|
1483
|
-
return
|
|
1518
|
+
case "claude-desktop": {
|
|
1519
|
+
const path = configureClaudeDesktop(serverUrl, apiKey, mcps);
|
|
1520
|
+
return `Claude Desktop configured (${path})`;
|
|
1521
|
+
}
|
|
1484
1522
|
case "claude-code":
|
|
1485
1523
|
configureClaudeCode(serverUrl, apiKey, mcps);
|
|
1486
1524
|
return "Claude Code configured";
|
|
@@ -1540,7 +1578,7 @@ async function validateApiKeyRemote(serverUrl, apiKey) {
|
|
|
1540
1578
|
}
|
|
1541
1579
|
|
|
1542
1580
|
// src/auth/credentials.ts
|
|
1543
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as
|
|
1581
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync6, unlinkSync as unlinkSync2, writeFileSync as writeFileSync4 } from "fs";
|
|
1544
1582
|
import { join as join5 } from "path";
|
|
1545
1583
|
function getCredentialsPath() {
|
|
1546
1584
|
return join5(getHomeDir(), CONFIG_DIR_NAME, CREDENTIALS_FILE_NAME);
|
|
@@ -1549,7 +1587,7 @@ function readCredentials() {
|
|
|
1549
1587
|
const path = getCredentialsPath();
|
|
1550
1588
|
if (!existsSync4(path)) return null;
|
|
1551
1589
|
try {
|
|
1552
|
-
const raw =
|
|
1590
|
+
const raw = readFileSync6(path, "utf-8");
|
|
1553
1591
|
return JSON.parse(raw);
|
|
1554
1592
|
} catch {
|
|
1555
1593
|
return null;
|