@danainnovations/cortex-mcp 1.0.78 → 1.0.80

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 CHANGED
@@ -1218,7 +1218,7 @@ function getWizardHtml() {
1218
1218
  resultEl.innerHTML = data.results.map(function(r) {
1219
1219
  var html = '<div class="status ' + (r.success ? 'status-success' : 'status-error') + '">' +
1220
1220
  '<span>' + (r.success ? '&#10003;' : '&#10007;') + '</span>' +
1221
- '<span>' + escapeHtml(r.client) + ': ' + (r.success ? 'Configured' : r.error || 'Failed') + '</span>' +
1221
+ '<span>' + (r.success ? escapeHtml(r.message || 'Configured') : escapeHtml(r.client) + ': ' + (r.error || 'Failed')) + '</span>' +
1222
1222
  '</div>';
1223
1223
  // Show copyable snippet for stdio/OpenClaw and Perplexity instructions
1224
1224
  if ((r.client === 'stdio' || r.client === 'perplexity') && r.success && r.message) {
@@ -1231,6 +1231,13 @@ function getWizardHtml() {
1231
1231
  return html;
1232
1232
  }).join('');
1233
1233
 
1234
+ // Add verify button for debugging config issues
1235
+ var verifyHtml = '<div style="margin-top: 12px; text-align: center;">' +
1236
+ '<button onclick="verifyConfig()" style="background: transparent; border: 1px solid #555; color: #aaa; padding: 6px 16px; border-radius: 6px; cursor: pointer; font-size: 12px;">Verify Config File</button>' +
1237
+ '<pre id="verify-result" style="display:none; margin-top: 8px; padding: 10px; background: #1a1a2e; border-radius: 6px; font-size: 11px; text-align: left; max-height: 200px; overflow: auto; color: #ccc;"></pre>' +
1238
+ '</div>';
1239
+ resultEl.innerHTML += verifyHtml;
1240
+
1234
1241
  btn.textContent = 'Continue';
1235
1242
  btn.disabled = false;
1236
1243
  btn.onclick = function() { goToStep('connect'); };
@@ -1427,6 +1434,19 @@ function getWizardHtml() {
1427
1434
  });
1428
1435
  }
1429
1436
 
1437
+ async function verifyConfig() {
1438
+ var el = document.getElementById('verify-result');
1439
+ el.style.display = 'block';
1440
+ el.textContent = 'Reading config file...';
1441
+ try {
1442
+ var resp = await fetch('/api/debug/config');
1443
+ var data = await resp.json();
1444
+ el.textContent = JSON.stringify(data, null, 2);
1445
+ } catch (err) {
1446
+ el.textContent = 'Error: ' + err.message;
1447
+ }
1448
+ }
1449
+
1430
1450
  function copySnippet(btn) {
1431
1451
  var pre = btn.parentElement.querySelector('pre');
1432
1452
  navigator.clipboard.writeText(pre.textContent).then(function() {
@@ -1445,6 +1465,9 @@ function getWizardHtml() {
1445
1465
  </html>`;
1446
1466
  }
1447
1467
 
1468
+ // src/wizard/routes.ts
1469
+ import { existsSync as existsSync4, readFileSync as readFileSync4 } from "fs";
1470
+
1448
1471
  // src/config/clients.ts
1449
1472
  import { existsSync, readFileSync, writeFileSync } from "fs";
1450
1473
  import { dirname } from "path";
@@ -1586,10 +1609,19 @@ function configureClaudeDesktop(_serverUrl, apiKey, _mcps) {
1586
1609
  }
1587
1610
  continue;
1588
1611
  }
1612
+ try {
1613
+ const verify = JSON.parse(readFileSync(configPath, "utf-8"));
1614
+ if (!verify.mcpServers || !("cortex" in verify.mcpServers)) {
1615
+ throw new Error(`Wrote to ${configPath} but mcpServers.cortex not found after write`);
1616
+ }
1617
+ } catch (e) {
1618
+ if (e instanceof Error && e.message.includes("mcpServers.cortex not found")) throw e;
1619
+ throw new Error(`Failed to verify config at ${configPath}: ${e}`);
1620
+ }
1589
1621
  return configPath;
1590
1622
  }
1591
1623
  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."
1624
+ `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.`
1593
1625
  );
1594
1626
  }
1595
1627
  function configureClaudeCode(serverUrl, apiKey, mcps) {
@@ -2098,6 +2130,28 @@ async function handleApiRoute(path, searchParams, req, res, options, onComplete)
2098
2130
  json(res, { results });
2099
2131
  return true;
2100
2132
  }
2133
+ if (path === "/api/debug/config" && method === "GET") {
2134
+ const configPath = getClaudeDesktopConfigPath();
2135
+ const result = {
2136
+ path: configPath,
2137
+ exists: existsSync4(configPath),
2138
+ platform: getPlatform()
2139
+ };
2140
+ if (existsSync4(configPath)) {
2141
+ try {
2142
+ const raw = readFileSync4(configPath, "utf-8");
2143
+ const parsed = JSON.parse(raw);
2144
+ result.contents = parsed;
2145
+ result.hasMcpServers = !!parsed?.mcpServers;
2146
+ result.hasCortex = !!parsed?.mcpServers?.cortex;
2147
+ } catch (e) {
2148
+ result.error = String(e);
2149
+ result.rawContents = readFileSync4(configPath, "utf-8");
2150
+ }
2151
+ }
2152
+ json(res, result);
2153
+ return true;
2154
+ }
2101
2155
  if (path === "/api/connections" && method === "GET") {
2102
2156
  const apiKey = getState().apiKey;
2103
2157
  try {
@@ -2333,7 +2387,7 @@ async function runConfigure(options) {
2333
2387
  }
2334
2388
 
2335
2389
  // src/proxy/stdio-server.ts
2336
- import { readFileSync as readFileSync5, statSync as statSync2 } from "fs";
2390
+ import { readFileSync as readFileSync6, statSync as statSync2 } from "fs";
2337
2391
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2338
2392
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
2339
2393
  import {
@@ -2449,9 +2503,9 @@ var CortexHttpClient = class {
2449
2503
  import {
2450
2504
  copyFileSync,
2451
2505
  cpSync,
2452
- existsSync as existsSync4,
2506
+ existsSync as existsSync5,
2453
2507
  mkdirSync as mkdirSync4,
2454
- readFileSync as readFileSync4,
2508
+ readFileSync as readFileSync5,
2455
2509
  readdirSync,
2456
2510
  rmSync,
2457
2511
  statSync,
@@ -2504,7 +2558,7 @@ function resolvePath(p) {
2504
2558
  }
2505
2559
  function isBinaryFile(filePath) {
2506
2560
  try {
2507
- const fd = readFileSync4(filePath, { flag: "r" });
2561
+ const fd = readFileSync5(filePath, { flag: "r" });
2508
2562
  const chunk = fd.subarray(0, BINARY_CHECK_SIZE);
2509
2563
  if (chunk.length === 0) return false;
2510
2564
  for (const sig of BINARY_SIGNATURES) {
@@ -2591,7 +2645,7 @@ function handleReadFile(args) {
2591
2645
  throw new Error(`File size (${stat.size} bytes) exceeds maximum allowed size (${MAX_READ_SIZE} bytes).`);
2592
2646
  }
2593
2647
  if (isBinaryFile(filePath)) {
2594
- const raw = readFileSync4(filePath);
2648
+ const raw = readFileSync5(filePath);
2595
2649
  return ok({
2596
2650
  content: raw.toString("base64"),
2597
2651
  is_binary: true,
@@ -2600,7 +2654,7 @@ function handleReadFile(args) {
2600
2654
  path: filePath
2601
2655
  });
2602
2656
  }
2603
- const text = readFileSync4(filePath, encoding);
2657
+ const text = readFileSync5(filePath, encoding);
2604
2658
  return ok({
2605
2659
  content: text,
2606
2660
  is_binary: false,
@@ -2621,7 +2675,7 @@ function handleReadFileLines(args) {
2621
2675
  }
2622
2676
  if (startLine < 1) throw new Error("start_line must be >= 1.");
2623
2677
  if (endLine !== void 0 && endLine < startLine) throw new Error("end_line must be >= start_line.");
2624
- const text = readFileSync4(filePath, encoding);
2678
+ const text = readFileSync5(filePath, encoding);
2625
2679
  const allLines = text.split(/\n/);
2626
2680
  const totalLines = allLines.length;
2627
2681
  const startIdx = startLine - 1;
@@ -2644,7 +2698,7 @@ function handleWriteFile(args) {
2644
2698
  const isBinary = args.is_binary || false;
2645
2699
  const overwrite = args.overwrite !== false;
2646
2700
  const createParents = args.create_parents || false;
2647
- const created = !existsSync4(filePath);
2701
+ const created = !existsSync5(filePath);
2648
2702
  if (!overwrite && !created) {
2649
2703
  throw new Error("File already exists.");
2650
2704
  }
@@ -2675,7 +2729,7 @@ function handleAppendFile(args) {
2675
2729
  const filePath = resolvePath(args.path);
2676
2730
  const content = args.content;
2677
2731
  const encoding = args.encoding || "utf-8";
2678
- if (!existsSync4(filePath)) throw new Error("File not found.");
2732
+ if (!existsSync5(filePath)) throw new Error("File not found.");
2679
2733
  const encoded = Buffer.from(content, encoding);
2680
2734
  appendFileSync(filePath, content, encoding);
2681
2735
  const newSize = statSync(filePath).size;
@@ -2688,7 +2742,7 @@ function handleAppendFile(args) {
2688
2742
  function handleCreateDirectory(args) {
2689
2743
  const dirPath = resolvePath(args.path);
2690
2744
  const parents = args.parents !== false;
2691
- if (existsSync4(dirPath)) {
2745
+ if (existsSync5(dirPath)) {
2692
2746
  return ok({ path: dirPath, created: false });
2693
2747
  }
2694
2748
  if (parents) {
@@ -2701,7 +2755,7 @@ function handleCreateDirectory(args) {
2701
2755
  function handleDelete(args) {
2702
2756
  const targetPath = resolvePath(args.path);
2703
2757
  const recursive = args.recursive || false;
2704
- if (!existsSync4(targetPath)) throw new Error("Path not found.");
2758
+ if (!existsSync5(targetPath)) throw new Error("Path not found.");
2705
2759
  const stat = statSync(targetPath, { throwIfNoEntry: false });
2706
2760
  if (!stat) throw new Error("Path not found.");
2707
2761
  if (stat.isDirectory()) {
@@ -2731,8 +2785,8 @@ function handleMove(args) {
2731
2785
  const source = resolvePath(args.source);
2732
2786
  const destination = resolvePath(args.destination);
2733
2787
  const overwrite = args.overwrite || false;
2734
- if (!existsSync4(source)) throw new Error("Source path not found.");
2735
- if (existsSync4(destination) && !overwrite) throw new Error("Destination already exists.");
2788
+ if (!existsSync5(source)) throw new Error("Source path not found.");
2789
+ if (existsSync5(destination) && !overwrite) throw new Error("Destination already exists.");
2736
2790
  const stat = statSync(source);
2737
2791
  const type = stat.isDirectory() ? "directory" : "file";
2738
2792
  const bytesMoved = stat.isDirectory() ? countDirectoryContents(source).bytes : stat.size;
@@ -2762,11 +2816,11 @@ function handleCopy(args) {
2762
2816
  const source = resolvePath(args.source);
2763
2817
  const destination = resolvePath(args.destination);
2764
2818
  const overwrite = args.overwrite || false;
2765
- if (!existsSync4(source)) throw new Error("Source path not found.");
2766
- if (existsSync4(destination) && !overwrite) throw new Error("Destination already exists.");
2819
+ if (!existsSync5(source)) throw new Error("Source path not found.");
2820
+ if (existsSync5(destination) && !overwrite) throw new Error("Destination already exists.");
2767
2821
  const stat = statSync(source);
2768
2822
  if (stat.isDirectory()) {
2769
- if (existsSync4(destination) && overwrite) {
2823
+ if (existsSync5(destination) && overwrite) {
2770
2824
  rmSync(destination, { recursive: true });
2771
2825
  }
2772
2826
  cpSync(source, destination, { recursive: true });
@@ -2783,7 +2837,7 @@ function handleListDirectory(args) {
2783
2837
  const maxDepth = args.max_depth || 1;
2784
2838
  const pattern = args.pattern;
2785
2839
  const includeHidden = args.include_hidden || false;
2786
- if (!existsSync4(dirPath)) throw new Error("Directory not found.");
2840
+ if (!existsSync5(dirPath)) throw new Error("Directory not found.");
2787
2841
  const stat = statSync(dirPath);
2788
2842
  if (!stat.isDirectory()) throw new Error("Path is not a directory.");
2789
2843
  const effectiveDepth = recursive ? maxDepth : 1;
@@ -2838,7 +2892,7 @@ function handleListDirectory(args) {
2838
2892
  }
2839
2893
  function handleExists(args) {
2840
2894
  const targetPath = resolvePath(args.path);
2841
- const pathExists = existsSync4(targetPath);
2895
+ const pathExists = existsSync5(targetPath);
2842
2896
  let type = null;
2843
2897
  if (pathExists) {
2844
2898
  const stat = statSync(targetPath, { throwIfNoEntry: false });
@@ -2850,7 +2904,7 @@ function handleExists(args) {
2850
2904
  }
2851
2905
  function handleGetFileInfo(args) {
2852
2906
  const filePath = resolvePath(args.path);
2853
- if (!existsSync4(filePath)) throw new Error("Path not found.");
2907
+ if (!existsSync5(filePath)) throw new Error("Path not found.");
2854
2908
  const stat = statSync(filePath, { throwIfNoEntry: false });
2855
2909
  if (!stat) throw new Error("Path not found.");
2856
2910
  const isDir = stat.isDirectory();
@@ -2876,7 +2930,7 @@ function handleSearchFiles(args) {
2876
2930
  const recursive = args.recursive !== false;
2877
2931
  const includeHidden = args.include_hidden || false;
2878
2932
  const maxResults = args.max_results || 1e3;
2879
- if (!existsSync4(searchPath)) throw new Error("Directory not found.");
2933
+ if (!existsSync5(searchPath)) throw new Error("Directory not found.");
2880
2934
  if (!statSync(searchPath).isDirectory()) throw new Error("Path is not a directory.");
2881
2935
  const patternRe = globToRegex(pattern);
2882
2936
  const matches = [];
@@ -2923,7 +2977,7 @@ function handleFindInFiles(args) {
2923
2977
  const contextLines = args.context_lines || 0;
2924
2978
  const maxResults = args.max_results || 500;
2925
2979
  const includeHidden = args.include_hidden || false;
2926
- if (!existsSync4(searchPath)) throw new Error("Directory not found.");
2980
+ if (!existsSync5(searchPath)) throw new Error("Directory not found.");
2927
2981
  if (!statSync(searchPath).isDirectory()) throw new Error("Path is not a directory.");
2928
2982
  const flags = caseSensitive ? "" : "i";
2929
2983
  const re = isRegex ? new RegExp(query, flags) : new RegExp(query.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), flags);
@@ -2952,7 +3006,7 @@ function handleFindInFiles(args) {
2952
3006
  let fileHasMatch = false;
2953
3007
  let lines;
2954
3008
  try {
2955
- const text = readFileSync4(fullPath, "utf-8");
3009
+ const text = readFileSync5(fullPath, "utf-8");
2956
3010
  lines = text.split("\n");
2957
3011
  } catch {
2958
3012
  continue;
@@ -2992,7 +3046,7 @@ function handleGetTree(args) {
2992
3046
  const maxDepth = args.max_depth || 3;
2993
3047
  const includeHidden = args.include_hidden || false;
2994
3048
  const maxEntries = args.max_entries || 500;
2995
- if (!existsSync4(rootPath)) throw new Error("Directory not found.");
3049
+ if (!existsSync5(rootPath)) throw new Error("Directory not found.");
2996
3050
  if (!statSync(rootPath).isDirectory()) throw new Error("Path is not a directory.");
2997
3051
  const lines = [];
2998
3052
  let entryCount = 0;
@@ -3147,7 +3201,7 @@ async function handleLocalFileUpload(cortex, toolName, args) {
3147
3201
  };
3148
3202
  }
3149
3203
  if (fileSize <= INLINE_UPLOAD_MAX) {
3150
- const fileBuffer2 = readFileSync5(filePath);
3204
+ const fileBuffer2 = readFileSync6(filePath);
3151
3205
  const base64Content = fileBuffer2.toString("base64");
3152
3206
  const forwardArgs = { ...args, content: base64Content };
3153
3207
  delete forwardArgs.file_path;
@@ -3199,7 +3253,7 @@ async function handleLocalFileUpload(cortex, toolName, args) {
3199
3253
  isError: true
3200
3254
  };
3201
3255
  }
3202
- const fileBuffer = readFileSync5(filePath);
3256
+ const fileBuffer = readFileSync6(filePath);
3203
3257
  const chunkSize = 2.5 * 1024 * 1024;
3204
3258
  const total = fileBuffer.length;
3205
3259
  let driveItem = {};
@@ -3366,7 +3420,7 @@ function runStatus() {
3366
3420
  }
3367
3421
 
3368
3422
  // src/cli/reset.ts
3369
- import { existsSync as existsSync5, unlinkSync as unlinkSync3, rmdirSync } from "fs";
3423
+ import { existsSync as existsSync6, unlinkSync as unlinkSync3, rmdirSync } from "fs";
3370
3424
  function runReset() {
3371
3425
  console.log("");
3372
3426
  console.log(" Resetting Cortex MCP configuration...");
@@ -3387,7 +3441,7 @@ function runReset() {
3387
3441
  ` Codex: ${codexReset ? "entries removed" : "no entries found"}`
3388
3442
  );
3389
3443
  const configPath = getConfigPath();
3390
- if (existsSync5(configPath)) {
3444
+ if (existsSync6(configPath)) {
3391
3445
  unlinkSync3(configPath);
3392
3446
  console.log(` Config file: removed`);
3393
3447
  }