@danainnovations/cortex-mcp 1.0.76 → 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 +50 -26
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +98 -38
- 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";
|
|
@@ -1543,31 +1544,53 @@ function configureClaudeDesktop(_serverUrl, apiKey, _mcps) {
|
|
|
1543
1544
|
if (!existsSync(dir)) {
|
|
1544
1545
|
mkdirSync(dir, { recursive: true });
|
|
1545
1546
|
}
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
try {
|
|
1549
|
-
config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
1550
|
-
} catch {
|
|
1551
|
-
}
|
|
1552
|
-
}
|
|
1553
|
-
if (!config.mcpServers || typeof config.mcpServers !== "object") {
|
|
1554
|
-
config.mcpServers = {};
|
|
1555
|
-
}
|
|
1556
|
-
const servers = config.mcpServers;
|
|
1557
|
-
for (const key of Object.keys(servers)) {
|
|
1558
|
-
if (key.startsWith("cortex-") || key === "cortex") {
|
|
1559
|
-
delete servers[key];
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
const isWindows = getPlatform() === "windows";
|
|
1563
|
-
servers["cortex"] = isWindows ? {
|
|
1547
|
+
const isWindowsTarget = getPlatform() === "windows" || isWSL();
|
|
1548
|
+
const cortexEntry = isWindowsTarget ? {
|
|
1564
1549
|
command: "cmd",
|
|
1565
1550
|
args: ["/c", "npx", "-y", "@danainnovations/cortex-mcp@latest", "serve"]
|
|
1566
1551
|
} : {
|
|
1567
1552
|
command: "npx",
|
|
1568
1553
|
args: ["-y", "@danainnovations/cortex-mcp@latest", "serve"]
|
|
1569
1554
|
};
|
|
1570
|
-
|
|
1555
|
+
const maxAttempts = isWindowsTarget ? 3 : 1;
|
|
1556
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
1557
|
+
let config = {};
|
|
1558
|
+
if (existsSync(configPath)) {
|
|
1559
|
+
try {
|
|
1560
|
+
config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
1561
|
+
} catch {
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
if (!config.mcpServers || typeof config.mcpServers !== "object") {
|
|
1565
|
+
config.mcpServers = {};
|
|
1566
|
+
}
|
|
1567
|
+
const servers = config.mcpServers;
|
|
1568
|
+
for (const key of Object.keys(servers)) {
|
|
1569
|
+
if (key.startsWith("cortex-") || key === "cortex") {
|
|
1570
|
+
delete servers[key];
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
servers["cortex"] = cortexEntry;
|
|
1574
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
1575
|
+
if (isWindowsTarget) {
|
|
1576
|
+
const start = Date.now();
|
|
1577
|
+
while (Date.now() - start < 500) {
|
|
1578
|
+
}
|
|
1579
|
+
try {
|
|
1580
|
+
const verify = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
1581
|
+
const verifyServers = verify.mcpServers;
|
|
1582
|
+
if (verifyServers && "cortex" in verifyServers) {
|
|
1583
|
+
return configPath;
|
|
1584
|
+
}
|
|
1585
|
+
} catch {
|
|
1586
|
+
}
|
|
1587
|
+
continue;
|
|
1588
|
+
}
|
|
1589
|
+
return configPath;
|
|
1590
|
+
}
|
|
1591
|
+
throw new Error(
|
|
1592
|
+
"Claude Desktop is overwriting the config file. Please close Claude Desktop completely (quit from the system tray), then re-run setup."
|
|
1593
|
+
);
|
|
1571
1594
|
}
|
|
1572
1595
|
function configureClaudeCode(serverUrl, apiKey, mcps) {
|
|
1573
1596
|
for (const mcp of AVAILABLE_MCPS) {
|
|
@@ -1710,10 +1733,10 @@ function configurePerplexity(serverUrl, _apiKey, mcps) {
|
|
|
1710
1733
|
return lines.join("\n");
|
|
1711
1734
|
}
|
|
1712
1735
|
function generateStdioSnippet(_apiKey) {
|
|
1713
|
-
const
|
|
1736
|
+
const isWindowsTarget = getPlatform() === "windows" || isWSL();
|
|
1714
1737
|
const config = {
|
|
1715
1738
|
mcpServers: {
|
|
1716
|
-
cortex:
|
|
1739
|
+
cortex: isWindowsTarget ? {
|
|
1717
1740
|
command: "cmd",
|
|
1718
1741
|
args: ["/c", "npx", "-y", "@danainnovations/cortex-mcp@latest", "serve"]
|
|
1719
1742
|
} : {
|
|
@@ -1799,9 +1822,10 @@ function resetCodex() {
|
|
|
1799
1822
|
}
|
|
1800
1823
|
function configureClient(clientType, serverUrl, apiKey, mcps) {
|
|
1801
1824
|
switch (clientType) {
|
|
1802
|
-
case "claude-desktop":
|
|
1803
|
-
configureClaudeDesktop(serverUrl, apiKey, mcps);
|
|
1804
|
-
return
|
|
1825
|
+
case "claude-desktop": {
|
|
1826
|
+
const path = configureClaudeDesktop(serverUrl, apiKey, mcps);
|
|
1827
|
+
return `Claude Desktop configured (${path})`;
|
|
1828
|
+
}
|
|
1805
1829
|
case "claude-code":
|
|
1806
1830
|
configureClaudeCode(serverUrl, apiKey, mcps);
|
|
1807
1831
|
return "Claude Code configured";
|
|
@@ -4057,7 +4081,7 @@ program.command("disconnect <provider>").description("Remove your personal OAuth
|
|
|
4057
4081
|
});
|
|
4058
4082
|
program.command("connect-mobile").description("Connect Cortex to Claude on mobile \u2014 opens setup page in browser").action(async () => {
|
|
4059
4083
|
const { DEFAULT_SERVER_URL: DEFAULT_SERVER_URL3 } = await import("./constants-QSLA3TAZ.js");
|
|
4060
|
-
const { openBrowser: openBrowser2 } = await import("./browser-
|
|
4084
|
+
const { openBrowser: openBrowser2 } = await import("./browser-S7WMSQYY.js");
|
|
4061
4085
|
const url = `${DEFAULT_SERVER_URL3}/connect`;
|
|
4062
4086
|
console.log("\nOpening Cortex connect page...");
|
|
4063
4087
|
console.log(` ${url}
|