@danainnovations/cortex-mcp 1.0.77 → 1.0.79
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 +26 -15
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +75 -28
- 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
|
@@ -6,6 +6,8 @@ import { exec } from "child_process";
|
|
|
6
6
|
// src/utils/platform.ts
|
|
7
7
|
import { homedir, platform } from "os";
|
|
8
8
|
import { join } from "path";
|
|
9
|
+
import { readFileSync, readdirSync } from "fs";
|
|
10
|
+
import { execSync } from "child_process";
|
|
9
11
|
function getHomeDir() {
|
|
10
12
|
return homedir();
|
|
11
13
|
}
|
|
@@ -15,9 +17,44 @@ function getPlatform() {
|
|
|
15
17
|
if (p === "win32") return "windows";
|
|
16
18
|
return "linux";
|
|
17
19
|
}
|
|
20
|
+
function isWSL() {
|
|
21
|
+
if (getPlatform() !== "linux") return false;
|
|
22
|
+
try {
|
|
23
|
+
const version = readFileSync("/proc/version", "utf-8");
|
|
24
|
+
return /microsoft|wsl/i.test(version);
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function getWindowsHomeFromWSL() {
|
|
30
|
+
try {
|
|
31
|
+
const raw = execSync("cmd.exe /c echo %USERNAME%", {
|
|
32
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
33
|
+
timeout: 5e3
|
|
34
|
+
}).toString().trim().replace(/\r/g, "");
|
|
35
|
+
if (raw && raw !== "%USERNAME%") {
|
|
36
|
+
return `/mnt/c/Users/${raw}`;
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const dirs = readdirSync("/mnt/c/Users").filter(
|
|
42
|
+
(d) => d !== "Public" && d !== "Default" && d !== "Default User" && d !== "All Users" && !d.startsWith(".")
|
|
43
|
+
);
|
|
44
|
+
if (dirs.length === 1) return `/mnt/c/Users/${dirs[0]}`;
|
|
45
|
+
} catch {
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
18
49
|
function getClaudeDesktopConfigPath() {
|
|
19
50
|
const home = getHomeDir();
|
|
20
51
|
const p = getPlatform();
|
|
52
|
+
if (p === "linux" && isWSL()) {
|
|
53
|
+
const winHome = getWindowsHomeFromWSL();
|
|
54
|
+
if (winHome) {
|
|
55
|
+
return join(winHome, "AppData", "Roaming", "Claude", "claude_desktop_config.json");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
21
58
|
switch (p) {
|
|
22
59
|
case "macos":
|
|
23
60
|
return join(
|
|
@@ -66,6 +103,7 @@ function openBrowser(url) {
|
|
|
66
103
|
export {
|
|
67
104
|
getHomeDir,
|
|
68
105
|
getPlatform,
|
|
106
|
+
isWSL,
|
|
69
107
|
getClaudeDesktopConfigPath,
|
|
70
108
|
getCursorConfigPath,
|
|
71
109
|
getVSCodeMcpConfigPath,
|
|
@@ -73,4 +111,4 @@ export {
|
|
|
73
111
|
getCodexConfigPath,
|
|
74
112
|
openBrowser
|
|
75
113
|
};
|
|
76
|
-
//# sourceMappingURL=chunk-
|
|
114
|
+
//# sourceMappingURL=chunk-YA4Q2GAN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/browser.ts","../src/utils/platform.ts"],"sourcesContent":["import { exec } from \"node:child_process\";\nimport { getPlatform } from \"./platform.js\";\n\nexport function openBrowser(url: string): Promise<void> {\n return new Promise((resolve) => {\n const platform = getPlatform();\n const cmd =\n platform === \"macos\" ? `open \"${url}\"` :\n platform === \"windows\" ? `start \"\" \"${url}\"` :\n `xdg-open \"${url}\"`;\n exec(cmd, () => resolve());\n });\n}\n","import { homedir, platform } from \"node:os\";\nimport { join } from \"node:path\";\nimport { readFileSync, readdirSync } from \"node:fs\";\nimport { execSync } from \"node:child_process\";\n\n/** Get the user's home directory */\nexport function getHomeDir(): string {\n return homedir();\n}\n\n/** Get the current platform */\nexport function getPlatform(): \"macos\" | \"windows\" | \"linux\" {\n const p = platform();\n if (p === \"darwin\") return \"macos\";\n if (p === \"win32\") return \"windows\";\n return \"linux\";\n}\n\n/** Detect if running inside Windows Subsystem for Linux */\nexport function isWSL(): boolean {\n if (getPlatform() !== \"linux\") return false;\n try {\n const version = readFileSync(\"/proc/version\", \"utf-8\");\n return /microsoft|wsl/i.test(version);\n } catch {\n return false;\n }\n}\n\n/** Resolve the Windows user home directory from within WSL via /mnt/c */\nfunction getWindowsHomeFromWSL(): string | null {\n try {\n // Try cmd.exe to get the Windows USERNAME\n const raw = execSync(\"cmd.exe /c echo %USERNAME%\", {\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n timeout: 5000,\n }).toString().trim().replace(/\\r/g, \"\");\n if (raw && raw !== \"%USERNAME%\") {\n return `/mnt/c/Users/${raw}`;\n }\n } catch {\n // cmd.exe may not be available — fall through\n }\n\n try {\n // Fallback: scan /mnt/c/Users for a single non-system user directory\n const dirs = readdirSync(\"/mnt/c/Users\").filter(\n (d) =>\n d !== \"Public\" &&\n d !== \"Default\" &&\n d !== \"Default User\" &&\n d !== \"All Users\" &&\n !d.startsWith(\".\")\n );\n if (dirs.length === 1) return `/mnt/c/Users/${dirs[0]}`;\n } catch {\n // /mnt/c not mounted\n }\n\n return null;\n}\n\n/**\n * Get the Claude Desktop config file path for the current platform.\n */\nexport function getClaudeDesktopConfigPath(): string {\n const home = getHomeDir();\n const p = getPlatform();\n\n // WSL: Claude Desktop is a Windows app — write to the Windows AppData path\n if (p === \"linux\" && isWSL()) {\n const winHome = getWindowsHomeFromWSL();\n if (winHome) {\n return join(winHome, \"AppData\", \"Roaming\", \"Claude\", \"claude_desktop_config.json\");\n }\n }\n\n switch (p) {\n case \"macos\":\n return join(\n home,\n \"Library\",\n \"Application Support\",\n \"Claude\",\n \"claude_desktop_config.json\"\n );\n case \"windows\":\n return join(\n process.env.APPDATA || join(home, \"AppData\", \"Roaming\"),\n \"Claude\",\n \"claude_desktop_config.json\"\n );\n case \"linux\":\n return join(home, \".config\", \"Claude\", \"claude_desktop_config.json\");\n }\n}\n\n/**\n * Get the Cursor MCP config file path for the current platform.\n */\nexport function getCursorConfigPath(): string {\n const home = getHomeDir();\n return join(home, \".cursor\", \"mcp.json\");\n}\n\n/**\n * Get the VS Code MCP config file path for the current platform.\n */\nexport function getVSCodeMcpConfigPath(): string {\n const home = getHomeDir();\n return join(home, \".vscode\", \"mcp.json\");\n}\n\n/**\n * Get the Antigravity MCP config file path for the current platform.\n */\nexport function getAntigravityConfigPath(): string {\n const home = getHomeDir();\n return join(home, \".gemini\", \"antigravity\", \"mcp_config.json\");\n}\n\n/**\n * Get the Codex (OpenAI) config file path.\n * Shared by both Codex CLI and Codex IDE extension.\n */\nexport function getCodexConfigPath(): string {\n const home = getHomeDir();\n return join(home, \".codex\", \"config.toml\");\n}\n"],"mappings":";;;AAAA,SAAS,YAAY;;;ACArB,SAAS,SAAS,gBAAgB;AAClC,SAAS,YAAY;AACrB,SAAS,cAAc,mBAAmB;AAC1C,SAAS,gBAAgB;AAGlB,SAAS,aAAqB;AACnC,SAAO,QAAQ;AACjB;AAGO,SAAS,cAA6C;AAC3D,QAAM,IAAI,SAAS;AACnB,MAAI,MAAM,SAAU,QAAO;AAC3B,MAAI,MAAM,QAAS,QAAO;AAC1B,SAAO;AACT;AAGO,SAAS,QAAiB;AAC/B,MAAI,YAAY,MAAM,QAAS,QAAO;AACtC,MAAI;AACF,UAAM,UAAU,aAAa,iBAAiB,OAAO;AACrD,WAAO,iB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ACzC;AAKO,SAAS,yBAAiC;AAC/C,QAAM,OAAO,WAAW;AACxB,SAAO,KAAK,MAAM,WAAW,UAAU;AACzC;AAKO,SAAS,2BAAmC;AACjD,QAAM,OAAO,WAAW;AACxB,SAAO,KAAK,MAAM,WAAW,eAAe,iBAAiB;AAC/D;AAMO,SAAS,qBAA6B;AAC3C,QAAM,OAAO,WAAW;AACxB,SAAO,KAAK,MAAM,UAAU,aAAa;AAC3C;;;AD7HO,SAAS,YAAY,KAA4B;AACtD,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAMA,YAAW,YAAY;AAC7B,UAAM,MACJA,cAAa,UAAU,SAAS,GAAG,MACnCA,cAAa,YAAY,aAAa,GAAG,MACzC,aAAa,GAAG;AAClB,SAAK,KAAK,MAAM,QAAQ,CAAC;AAAA,EAC3B,CAAC;AACH;","names":["platform"]}
|
package/dist/cli.js
CHANGED
|
@@ -18,8 +18,9 @@ import {
|
|
|
18
18
|
getHomeDir,
|
|
19
19
|
getPlatform,
|
|
20
20
|
getVSCodeMcpConfigPath,
|
|
21
|
+
isWSL,
|
|
21
22
|
openBrowser
|
|
22
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-YA4Q2GAN.js";
|
|
23
24
|
|
|
24
25
|
// bin/cli.ts
|
|
25
26
|
import { Command } from "commander";
|
|
@@ -1217,7 +1218,7 @@ function getWizardHtml() {
|
|
|
1217
1218
|
resultEl.innerHTML = data.results.map(function(r) {
|
|
1218
1219
|
var html = '<div class="status ' + (r.success ? 'status-success' : 'status-error') + '">' +
|
|
1219
1220
|
'<span>' + (r.success ? '✓' : '✗') + '</span>' +
|
|
1220
|
-
'<span>' + escapeHtml(r.
|
|
1221
|
+
'<span>' + (r.success ? escapeHtml(r.message || 'Configured') : escapeHtml(r.client) + ': ' + (r.error || 'Failed')) + '</span>' +
|
|
1221
1222
|
'</div>';
|
|
1222
1223
|
// Show copyable snippet for stdio/OpenClaw and Perplexity instructions
|
|
1223
1224
|
if ((r.client === 'stdio' || r.client === 'perplexity') && r.success && r.message) {
|
|
@@ -1543,15 +1544,15 @@ function configureClaudeDesktop(_serverUrl, apiKey, _mcps) {
|
|
|
1543
1544
|
if (!existsSync(dir)) {
|
|
1544
1545
|
mkdirSync(dir, { recursive: true });
|
|
1545
1546
|
}
|
|
1546
|
-
const
|
|
1547
|
-
const cortexEntry =
|
|
1547
|
+
const isWindowsTarget = getPlatform() === "windows" || isWSL();
|
|
1548
|
+
const cortexEntry = isWindowsTarget ? {
|
|
1548
1549
|
command: "cmd",
|
|
1549
1550
|
args: ["/c", "npx", "-y", "@danainnovations/cortex-mcp@latest", "serve"]
|
|
1550
1551
|
} : {
|
|
1551
1552
|
command: "npx",
|
|
1552
1553
|
args: ["-y", "@danainnovations/cortex-mcp@latest", "serve"]
|
|
1553
1554
|
};
|
|
1554
|
-
const maxAttempts =
|
|
1555
|
+
const maxAttempts = isWindowsTarget ? 3 : 1;
|
|
1555
1556
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
1556
1557
|
let config = {};
|
|
1557
1558
|
if (existsSync(configPath)) {
|
|
@@ -1571,7 +1572,7 @@ function configureClaudeDesktop(_serverUrl, apiKey, _mcps) {
|
|
|
1571
1572
|
}
|
|
1572
1573
|
servers["cortex"] = cortexEntry;
|
|
1573
1574
|
writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
1574
|
-
if (
|
|
1575
|
+
if (isWindowsTarget) {
|
|
1575
1576
|
const start = Date.now();
|
|
1576
1577
|
while (Date.now() - start < 500) {
|
|
1577
1578
|
}
|
|
@@ -1579,16 +1580,25 @@ function configureClaudeDesktop(_serverUrl, apiKey, _mcps) {
|
|
|
1579
1580
|
const verify = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
1580
1581
|
const verifyServers = verify.mcpServers;
|
|
1581
1582
|
if (verifyServers && "cortex" in verifyServers) {
|
|
1582
|
-
return;
|
|
1583
|
+
return configPath;
|
|
1583
1584
|
}
|
|
1584
1585
|
} catch {
|
|
1585
1586
|
}
|
|
1586
1587
|
continue;
|
|
1587
1588
|
}
|
|
1588
|
-
|
|
1589
|
+
try {
|
|
1590
|
+
const verify = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
1591
|
+
if (!verify.mcpServers || !("cortex" in verify.mcpServers)) {
|
|
1592
|
+
throw new Error(`Wrote to ${configPath} but mcpServers.cortex not found after write`);
|
|
1593
|
+
}
|
|
1594
|
+
} catch (e) {
|
|
1595
|
+
if (e instanceof Error && e.message.includes("mcpServers.cortex not found")) throw e;
|
|
1596
|
+
throw new Error(`Failed to verify config at ${configPath}: ${e}`);
|
|
1597
|
+
}
|
|
1598
|
+
return configPath;
|
|
1589
1599
|
}
|
|
1590
1600
|
throw new Error(
|
|
1591
|
-
|
|
1601
|
+
`Failed to write config to ${configPath}. Claude Desktop may be overwriting the file. Please close Claude Desktop completely (quit from the system tray), then re-run setup.`
|
|
1592
1602
|
);
|
|
1593
1603
|
}
|
|
1594
1604
|
function configureClaudeCode(serverUrl, apiKey, mcps) {
|
|
@@ -1732,10 +1742,10 @@ function configurePerplexity(serverUrl, _apiKey, mcps) {
|
|
|
1732
1742
|
return lines.join("\n");
|
|
1733
1743
|
}
|
|
1734
1744
|
function generateStdioSnippet(_apiKey) {
|
|
1735
|
-
const
|
|
1745
|
+
const isWindowsTarget = getPlatform() === "windows" || isWSL();
|
|
1736
1746
|
const config = {
|
|
1737
1747
|
mcpServers: {
|
|
1738
|
-
cortex:
|
|
1748
|
+
cortex: isWindowsTarget ? {
|
|
1739
1749
|
command: "cmd",
|
|
1740
1750
|
args: ["/c", "npx", "-y", "@danainnovations/cortex-mcp@latest", "serve"]
|
|
1741
1751
|
} : {
|
|
@@ -1821,9 +1831,10 @@ function resetCodex() {
|
|
|
1821
1831
|
}
|
|
1822
1832
|
function configureClient(clientType, serverUrl, apiKey, mcps) {
|
|
1823
1833
|
switch (clientType) {
|
|
1824
|
-
case "claude-desktop":
|
|
1825
|
-
configureClaudeDesktop(serverUrl, apiKey, mcps);
|
|
1826
|
-
return
|
|
1834
|
+
case "claude-desktop": {
|
|
1835
|
+
const path = configureClaudeDesktop(serverUrl, apiKey, mcps);
|
|
1836
|
+
return `Claude Desktop configured (${path})`;
|
|
1837
|
+
}
|
|
1827
1838
|
case "claude-code":
|
|
1828
1839
|
configureClaudeCode(serverUrl, apiKey, mcps);
|
|
1829
1840
|
return "Claude Code configured";
|
|
@@ -4079,7 +4090,7 @@ program.command("disconnect <provider>").description("Remove your personal OAuth
|
|
|
4079
4090
|
});
|
|
4080
4091
|
program.command("connect-mobile").description("Connect Cortex to Claude on mobile \u2014 opens setup page in browser").action(async () => {
|
|
4081
4092
|
const { DEFAULT_SERVER_URL: DEFAULT_SERVER_URL3 } = await import("./constants-QSLA3TAZ.js");
|
|
4082
|
-
const { openBrowser: openBrowser2 } = await import("./browser-
|
|
4093
|
+
const { openBrowser: openBrowser2 } = await import("./browser-S7WMSQYY.js");
|
|
4083
4094
|
const url = `${DEFAULT_SERVER_URL3}/connect`;
|
|
4084
4095
|
console.log("\nOpening Cortex connect page...");
|
|
4085
4096
|
console.log(` ${url}
|