@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.
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ openBrowser
4
+ } from "./chunk-YA4Q2GAN.js";
5
+ export {
6
+ openBrowser
7
+ };
8
+ //# sourceMappingURL=browser-S7WMSQYY.js.map
@@ -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-AUMRZ53L.js.map
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,iBAAiB,KAAK,OAAO;AAAA,EACtC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGA,SAAS,wBAAuC;AAC9C,MAAI;AAEF,UAAM,MAAM,SAAS,8BAA8B;AAAA,MACjD,OAAO,CAAC,QAAQ,QAAQ,MAAM;AAAA,MAC9B,SAAS;AAAA,IACX,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,OAAO,EAAE;AACtC,QAAI,OAAO,QAAQ,cAAc;AAC/B,aAAO,gBAAgB,GAAG;AAAA,IAC5B;AAAA,EACF,QAAQ;AAAA,EAER;AAEA,MAAI;AAEF,UAAM,OAAO,YAAY,cAAc,EAAE;AAAA,MACvC,CAAC,MACC,MAAM,YACN,MAAM,aACN,MAAM,kBACN,MAAM,eACN,CAAC,EAAE,WAAW,GAAG;AAAA,IACrB;AACA,QAAI,KAAK,WAAW,EAAG,QAAO,gBAAgB,KAAK,CAAC,CAAC;AAAA,EACvD,QAAQ;AAAA,EAER;AAEA,SAAO;AACT;AAKO,SAAS,6BAAqC;AACnD,QAAM,OAAO,WAAW;AACxB,QAAM,IAAI,YAAY;AAGtB,MAAI,MAAM,WAAW,MAAM,GAAG;AAC5B,UAAM,UAAU,sBAAsB;AACtC,QAAI,SAAS;AACX,aAAO,KAAK,SAAS,WAAW,WAAW,UAAU,4BAA4B;AAAA,IACnF;AAAA,EACF;AAEA,UAAQ,GAAG;AAAA,IACT,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,QAAQ,IAAI,WAAW,KAAK,MAAM,WAAW,SAAS;AAAA,QACtD;AAAA,QACA;AAAA,MACF;AAAA,IACF,KAAK;AACH,aAAO,KAAK,MAAM,WAAW,UAAU,4BAA4B;AAAA,EACvE;AACF;AAKO,SAAS,sBAA8B;AAC5C,QAAM,OAAO,WAAW;AACxB,SAAO,KAAK,MAAM,WAAW,UAAU;AACzC;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-AUMRZ53L.js";
23
+ } from "./chunk-YA4Q2GAN.js";
23
24
 
24
25
  // bin/cli.ts
25
26
  import { Command } from "commander";
@@ -1543,15 +1544,15 @@ function configureClaudeDesktop(_serverUrl, apiKey, _mcps) {
1543
1544
  if (!existsSync(dir)) {
1544
1545
  mkdirSync(dir, { recursive: true });
1545
1546
  }
1546
- const isWindows = getPlatform() === "windows";
1547
- const cortexEntry = isWindows ? {
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 = isWindows ? 3 : 1;
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 (isWindows) {
1575
+ if (isWindowsTarget) {
1575
1576
  const start = Date.now();
1576
1577
  while (Date.now() - start < 500) {
1577
1578
  }
@@ -1579,13 +1580,13 @@ 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
- return;
1589
+ return configPath;
1589
1590
  }
1590
1591
  throw new Error(
1591
1592
  "Claude Desktop is overwriting the config file. Please close Claude Desktop completely (quit from the system tray), then re-run setup."
@@ -1732,10 +1733,10 @@ function configurePerplexity(serverUrl, _apiKey, mcps) {
1732
1733
  return lines.join("\n");
1733
1734
  }
1734
1735
  function generateStdioSnippet(_apiKey) {
1735
- const isWindows = getPlatform() === "windows";
1736
+ const isWindowsTarget = getPlatform() === "windows" || isWSL();
1736
1737
  const config = {
1737
1738
  mcpServers: {
1738
- cortex: isWindows ? {
1739
+ cortex: isWindowsTarget ? {
1739
1740
  command: "cmd",
1740
1741
  args: ["/c", "npx", "-y", "@danainnovations/cortex-mcp@latest", "serve"]
1741
1742
  } : {
@@ -1821,9 +1822,10 @@ function resetCodex() {
1821
1822
  }
1822
1823
  function configureClient(clientType, serverUrl, apiKey, mcps) {
1823
1824
  switch (clientType) {
1824
- case "claude-desktop":
1825
- configureClaudeDesktop(serverUrl, apiKey, mcps);
1826
- return "Claude Desktop configured";
1825
+ case "claude-desktop": {
1826
+ const path = configureClaudeDesktop(serverUrl, apiKey, mcps);
1827
+ return `Claude Desktop configured (${path})`;
1828
+ }
1827
1829
  case "claude-code":
1828
1830
  configureClaudeCode(serverUrl, apiKey, mcps);
1829
1831
  return "Claude Code configured";
@@ -4079,7 +4081,7 @@ program.command("disconnect <provider>").description("Remove your personal OAuth
4079
4081
  });
4080
4082
  program.command("connect-mobile").description("Connect Cortex to Claude on mobile \u2014 opens setup page in browser").action(async () => {
4081
4083
  const { DEFAULT_SERVER_URL: DEFAULT_SERVER_URL3 } = await import("./constants-QSLA3TAZ.js");
4082
- const { openBrowser: openBrowser2 } = await import("./browser-WFTDXNKP.js");
4084
+ const { openBrowser: openBrowser2 } = await import("./browser-S7WMSQYY.js");
4083
4085
  const url = `${DEFAULT_SERVER_URL3}/connect`;
4084
4086
  console.log("\nOpening Cortex connect page...");
4085
4087
  console.log(` ${url}