@leadbay/mcp 0.23.0 → 0.23.1

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.
@@ -90,11 +90,11 @@ var init_install_claude_code = __esm({
90
90
  // installer/install-json-config.ts
91
91
  async function installInJsonConfig(configPath, token, region, includeWrite, telemetryEnabled, localBinPath) {
92
92
  try {
93
- const { readFileSync: readFileSync3, writeFileSync, existsSync: existsSync3, mkdirSync, statSync } = await import("fs");
93
+ const { readFileSync: readFileSync3, writeFileSync, existsSync: existsSync4, mkdirSync, statSync } = await import("fs");
94
94
  const { dirname } = await import("path");
95
95
  let parsed = {};
96
96
  let preserved = {};
97
- const existed = existsSync3(configPath);
97
+ const existed = existsSync4(configPath);
98
98
  if (existed) {
99
99
  const raw = readFileSync3(configPath, "utf8");
100
100
  try {
@@ -144,8 +144,8 @@ function stripJsonMcpEntry(existing) {
144
144
  }
145
145
  async function uninstallFromJsonConfig(configPath) {
146
146
  try {
147
- const { existsSync: existsSync3, readFileSync: readFileSync3, writeFileSync } = await import("fs");
148
- if (!existsSync3(configPath)) return { ok: true, message: "config not found \u2014 nothing to do" };
147
+ const { existsSync: existsSync4, readFileSync: readFileSync3, writeFileSync } = await import("fs");
148
+ if (!existsSync4(configPath)) return { ok: true, message: "config not found \u2014 nothing to do" };
149
149
  const existing = readFileSync3(configPath, "utf8");
150
150
  const { content, changed } = stripJsonMcpEntry(existing);
151
151
  if (!changed) return { ok: true, message: "leadbay entry not present" };
@@ -233,10 +233,10 @@ function stripShellExportBlock(existing) {
233
233
  }
234
234
  async function installInCodexConfig(configPath, includeWrite, telemetryEnabled, localBinPath) {
235
235
  try {
236
- const { readFileSync: readFileSync3, writeFileSync, existsSync: existsSync3, mkdirSync, statSync, renameSync, chmodSync } = await import("fs");
236
+ const { readFileSync: readFileSync3, writeFileSync, existsSync: existsSync4, mkdirSync, statSync, renameSync, chmodSync } = await import("fs");
237
237
  const { dirname } = await import("path");
238
238
  let existing = "";
239
- const existed = existsSync3(configPath);
239
+ const existed = existsSync4(configPath);
240
240
  if (existed) {
241
241
  existing = readFileSync3(configPath, "utf8");
242
242
  } else {
@@ -282,15 +282,15 @@ async function appendShellExports(token, region, includeWrite, telemetryEnabled)
282
282
  }
283
283
  return { ok: true, message: "env exported with setx; restart Codex/terminal" };
284
284
  }
285
- const { existsSync: existsSync3, readFileSync: readFileSync3, writeFileSync, renameSync } = await import("fs");
285
+ const { existsSync: existsSync4, readFileSync: readFileSync3, writeFileSync, renameSync } = await import("fs");
286
286
  const os = await import("os");
287
287
  const home = os.homedir();
288
- const preferred = [`${home}/.zshrc`, `${home}/.bashrc`].filter((path) => existsSync3(path));
288
+ const preferred = [`${home}/.zshrc`, `${home}/.bashrc`].filter((path) => existsSync4(path));
289
289
  const paths = preferred.length ? preferred : [`${home}/.profile`];
290
290
  const block = buildShellExportBlock(token, region, includeWrite, telemetryEnabled);
291
291
  const updated = [];
292
292
  for (const path of paths) {
293
- const existing = existsSync3(path) ? readFileSync3(path, "utf8") : "";
293
+ const existing = existsSync4(path) ? readFileSync3(path, "utf8") : "";
294
294
  const merged = mergeShellExportBlock(existing, block);
295
295
  if (!merged.changed) continue;
296
296
  const tmp = `${path}.leadbay.tmp`;
@@ -308,8 +308,8 @@ async function appendShellExports(token, region, includeWrite, telemetryEnabled)
308
308
  }
309
309
  async function uninstallFromCodexConfig(configPath) {
310
310
  try {
311
- const { existsSync: existsSync3, readFileSync: readFileSync3, writeFileSync } = await import("fs");
312
- if (!existsSync3(configPath)) return { ok: true, message: "config not found \u2014 nothing to do" };
311
+ const { existsSync: existsSync4, readFileSync: readFileSync3, writeFileSync } = await import("fs");
312
+ if (!existsSync4(configPath)) return { ok: true, message: "config not found \u2014 nothing to do" };
313
313
  const existing = readFileSync3(configPath, "utf8");
314
314
  const { content, changed } = stripCodexBlock(existing);
315
315
  if (!changed) return { ok: true, message: "leadbay block not present" };
@@ -321,11 +321,11 @@ async function uninstallFromCodexConfig(configPath) {
321
321
  }
322
322
  async function uninstallShellExports() {
323
323
  try {
324
- const { existsSync: existsSync3, readFileSync: readFileSync3, writeFileSync, renameSync } = await import("fs");
324
+ const { existsSync: existsSync4, readFileSync: readFileSync3, writeFileSync, renameSync } = await import("fs");
325
325
  const os = await import("os");
326
326
  const home = os.homedir();
327
327
  const candidates = [`${home}/.zshrc`, `${home}/.bashrc`, `${home}/.profile`].filter(
328
- (p) => existsSync3(p)
328
+ (p) => existsSync4(p)
329
329
  );
330
330
  const updated = [];
331
331
  for (const p of candidates) {
@@ -354,17 +354,17 @@ var init_install_codex = __esm({
354
354
  // installer/install-dxt.ts
355
355
  async function removeDxtExtension(claudeSupportDir) {
356
356
  try {
357
- const { existsSync: existsSync3, readFileSync: readFileSync3, writeFileSync, rmSync } = await import("fs");
357
+ const { existsSync: existsSync4, readFileSync: readFileSync3, writeFileSync, rmSync } = await import("fs");
358
358
  const { join: join2 } = await import("path");
359
359
  const extensionDir = join2(claudeSupportDir, "Claude Extensions", DXT_EXTENSION_ID);
360
360
  const registryPath = join2(claudeSupportDir, "extensions-installations.json");
361
361
  let removedDir = false;
362
362
  let removedEntry = false;
363
- if (existsSync3(extensionDir)) {
363
+ if (existsSync4(extensionDir)) {
364
364
  rmSync(extensionDir, { recursive: true, force: true });
365
365
  removedDir = true;
366
366
  }
367
- if (existsSync3(registryPath)) {
367
+ if (existsSync4(registryPath)) {
368
368
  try {
369
369
  const raw = readFileSync3(registryPath, "utf8");
370
370
  const parsed = JSON.parse(raw);
@@ -550,7 +550,7 @@ import { createHash, randomBytes } from "crypto";
550
550
  import { createServer } from "http";
551
551
  import { request as httpsRequestRaw } from "https";
552
552
  import { spawn as spawn3 } from "child_process";
553
- import { readdirSync } from "fs";
553
+ import { readdirSync, existsSync as existsSync2 } from "fs";
554
554
  async function inferRegionViaStargate(opts) {
555
555
  const url = STARGATE_URLS[opts.staging ? "staging" : "prod"];
556
556
  const res = await httpsCall("GET", url, { Accept: "application/json" });
@@ -837,7 +837,19 @@ function browserOpenCandidates(url) {
837
837
  function browserLaunchEnv(debug) {
838
838
  const env = { ...process.env };
839
839
  if (process.platform !== "linux") return env;
840
- const runtimeDir = env.XDG_RUNTIME_DIR;
840
+ let runtimeDir = env.XDG_RUNTIME_DIR;
841
+ if (!runtimeDir || !existsSync2(runtimeDir)) {
842
+ try {
843
+ const uid = process.getuid?.();
844
+ const candidate = uid !== void 0 ? `/run/user/${uid}` : void 0;
845
+ if (candidate && existsSync2(candidate)) {
846
+ runtimeDir = candidate;
847
+ env.XDG_RUNTIME_DIR = candidate;
848
+ debug?.(`browserLaunchEnv: injected XDG_RUNTIME_DIR=${candidate}`);
849
+ }
850
+ } catch {
851
+ }
852
+ }
841
853
  if (!env.WAYLAND_DISPLAY && runtimeDir) {
842
854
  try {
843
855
  const sock = readdirSync(runtimeDir).find((f) => /^wayland-\d+$/.test(f));
@@ -848,6 +860,13 @@ function browserLaunchEnv(debug) {
848
860
  } catch {
849
861
  }
850
862
  }
863
+ if (!env.DBUS_SESSION_BUS_ADDRESS && runtimeDir) {
864
+ const busPath = `${runtimeDir}/bus`;
865
+ if (existsSync2(busPath)) {
866
+ env.DBUS_SESSION_BUS_ADDRESS = `unix:path=${busPath}`;
867
+ debug?.(`browserLaunchEnv: injected DBUS_SESSION_BUS_ADDRESS=unix:path=${busPath}`);
868
+ }
869
+ }
851
870
  if (!env.DISPLAY) {
852
871
  try {
853
872
  const x = readdirSync("/tmp/.X11-unix").map((f) => f.match(/^X(\d+)$/)?.[1]).filter((n) => !!n).sort((a, b) => Number(a) - Number(b))[0];
@@ -857,6 +876,25 @@ function browserLaunchEnv(debug) {
857
876
  }
858
877
  debug?.(`browserLaunchEnv: injected DISPLAY=${env.DISPLAY}`);
859
878
  }
879
+ if (!env.XAUTHORITY) {
880
+ try {
881
+ let xauth;
882
+ if (runtimeDir) {
883
+ const cookie = readdirSync(runtimeDir).find(
884
+ (f) => /^\.mutter-Xwaylandauth\./.test(f)
885
+ );
886
+ if (cookie) xauth = `${runtimeDir}/${cookie}`;
887
+ }
888
+ if (!xauth && env.HOME && existsSync2(`${env.HOME}/.Xauthority`)) {
889
+ xauth = `${env.HOME}/.Xauthority`;
890
+ }
891
+ if (xauth) {
892
+ env.XAUTHORITY = xauth;
893
+ debug?.(`browserLaunchEnv: injected XAUTHORITY=${xauth}`);
894
+ }
895
+ } catch {
896
+ }
897
+ }
860
898
  return env;
861
899
  }
862
900
  async function openInBrowser(url, debug) {
@@ -1018,14 +1056,14 @@ import { createServer as createServer2 } from "http";
1018
1056
  import { randomUUID } from "crypto";
1019
1057
  import { resolve as resolvePath } from "path";
1020
1058
  import { fileURLToPath } from "url";
1021
- import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
1059
+ import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
1022
1060
  async function isLeadbayConfigured(client) {
1023
1061
  if (client.id === "claude-code") {
1024
1062
  return await isLeadbayConfiguredInClaudeCode();
1025
1063
  }
1026
1064
  if (client.id === "codex") {
1027
1065
  const configPath2 = client.detail;
1028
- if (!existsSync2(configPath2)) return false;
1066
+ if (!existsSync3(configPath2)) return false;
1029
1067
  try {
1030
1068
  return readFileSync2(configPath2, "utf8").includes("[mcp_servers.leadbay]");
1031
1069
  } catch {
@@ -1034,7 +1072,7 @@ async function isLeadbayConfigured(client) {
1034
1072
  }
1035
1073
  if (client.id === "chatgpt-desktop") return false;
1036
1074
  const configPath = client.configPath;
1037
- if (!configPath || !existsSync2(configPath)) return false;
1075
+ if (!configPath || !existsSync3(configPath)) return false;
1038
1076
  try {
1039
1077
  const parsed = JSON.parse(readFileSync2(configPath, "utf8"));
1040
1078
  return Boolean(parsed?.mcpServers?.leadbay);
@@ -82,11 +82,11 @@ async function uninstallFromClaudeCode() {
82
82
  // installer/install-json-config.ts
83
83
  async function installInJsonConfig(configPath, token, region, includeWrite, telemetryEnabled, localBinPath) {
84
84
  try {
85
- const { readFileSync: readFileSync3, writeFileSync, existsSync: existsSync3, mkdirSync, statSync } = await import("fs");
85
+ const { readFileSync: readFileSync3, writeFileSync, existsSync: existsSync4, mkdirSync, statSync } = await import("fs");
86
86
  const { dirname } = await import("path");
87
87
  let parsed = {};
88
88
  let preserved = {};
89
- const existed = existsSync3(configPath);
89
+ const existed = existsSync4(configPath);
90
90
  if (existed) {
91
91
  const raw = readFileSync3(configPath, "utf8");
92
92
  try {
@@ -136,8 +136,8 @@ function stripJsonMcpEntry(existing) {
136
136
  }
137
137
  async function uninstallFromJsonConfig(configPath) {
138
138
  try {
139
- const { existsSync: existsSync3, readFileSync: readFileSync3, writeFileSync } = await import("fs");
140
- if (!existsSync3(configPath)) return { ok: true, message: "config not found \u2014 nothing to do" };
139
+ const { existsSync: existsSync4, readFileSync: readFileSync3, writeFileSync } = await import("fs");
140
+ if (!existsSync4(configPath)) return { ok: true, message: "config not found \u2014 nothing to do" };
141
141
  const existing = readFileSync3(configPath, "utf8");
142
142
  const { content, changed } = stripJsonMcpEntry(existing);
143
143
  if (!changed) return { ok: true, message: "leadbay entry not present" };
@@ -220,10 +220,10 @@ function stripShellExportBlock(existing) {
220
220
  }
221
221
  async function installInCodexConfig(configPath, includeWrite, telemetryEnabled, localBinPath) {
222
222
  try {
223
- const { readFileSync: readFileSync3, writeFileSync, existsSync: existsSync3, mkdirSync, statSync, renameSync, chmodSync } = await import("fs");
223
+ const { readFileSync: readFileSync3, writeFileSync, existsSync: existsSync4, mkdirSync, statSync, renameSync, chmodSync } = await import("fs");
224
224
  const { dirname } = await import("path");
225
225
  let existing = "";
226
- const existed = existsSync3(configPath);
226
+ const existed = existsSync4(configPath);
227
227
  if (existed) {
228
228
  existing = readFileSync3(configPath, "utf8");
229
229
  } else {
@@ -269,15 +269,15 @@ async function appendShellExports(token, region, includeWrite, telemetryEnabled)
269
269
  }
270
270
  return { ok: true, message: "env exported with setx; restart Codex/terminal" };
271
271
  }
272
- const { existsSync: existsSync3, readFileSync: readFileSync3, writeFileSync, renameSync } = await import("fs");
272
+ const { existsSync: existsSync4, readFileSync: readFileSync3, writeFileSync, renameSync } = await import("fs");
273
273
  const os = await import("os");
274
274
  const home = os.homedir();
275
- const preferred = [`${home}/.zshrc`, `${home}/.bashrc`].filter((path) => existsSync3(path));
275
+ const preferred = [`${home}/.zshrc`, `${home}/.bashrc`].filter((path) => existsSync4(path));
276
276
  const paths = preferred.length ? preferred : [`${home}/.profile`];
277
277
  const block = buildShellExportBlock(token, region, includeWrite, telemetryEnabled);
278
278
  const updated = [];
279
279
  for (const path of paths) {
280
- const existing = existsSync3(path) ? readFileSync3(path, "utf8") : "";
280
+ const existing = existsSync4(path) ? readFileSync3(path, "utf8") : "";
281
281
  const merged = mergeShellExportBlock(existing, block);
282
282
  if (!merged.changed) continue;
283
283
  const tmp = `${path}.leadbay.tmp`;
@@ -295,8 +295,8 @@ async function appendShellExports(token, region, includeWrite, telemetryEnabled)
295
295
  }
296
296
  async function uninstallFromCodexConfig(configPath) {
297
297
  try {
298
- const { existsSync: existsSync3, readFileSync: readFileSync3, writeFileSync } = await import("fs");
299
- if (!existsSync3(configPath)) return { ok: true, message: "config not found \u2014 nothing to do" };
298
+ const { existsSync: existsSync4, readFileSync: readFileSync3, writeFileSync } = await import("fs");
299
+ if (!existsSync4(configPath)) return { ok: true, message: "config not found \u2014 nothing to do" };
300
300
  const existing = readFileSync3(configPath, "utf8");
301
301
  const { content, changed } = stripCodexBlock(existing);
302
302
  if (!changed) return { ok: true, message: "leadbay block not present" };
@@ -308,11 +308,11 @@ async function uninstallFromCodexConfig(configPath) {
308
308
  }
309
309
  async function uninstallShellExports() {
310
310
  try {
311
- const { existsSync: existsSync3, readFileSync: readFileSync3, writeFileSync, renameSync } = await import("fs");
311
+ const { existsSync: existsSync4, readFileSync: readFileSync3, writeFileSync, renameSync } = await import("fs");
312
312
  const os = await import("os");
313
313
  const home = os.homedir();
314
314
  const candidates = [`${home}/.zshrc`, `${home}/.bashrc`, `${home}/.profile`].filter(
315
- (p) => existsSync3(p)
315
+ (p) => existsSync4(p)
316
316
  );
317
317
  const updated = [];
318
318
  for (const p of candidates) {
@@ -337,17 +337,17 @@ async function uninstallShellExports() {
337
337
  var DXT_EXTENSION_ID = "local.dxt.leadbay.leadbay";
338
338
  async function removeDxtExtension(claudeSupportDir) {
339
339
  try {
340
- const { existsSync: existsSync3, readFileSync: readFileSync3, writeFileSync, rmSync } = await import("fs");
340
+ const { existsSync: existsSync4, readFileSync: readFileSync3, writeFileSync, rmSync } = await import("fs");
341
341
  const { join: join2 } = await import("path");
342
342
  const extensionDir = join2(claudeSupportDir, "Claude Extensions", DXT_EXTENSION_ID);
343
343
  const registryPath = join2(claudeSupportDir, "extensions-installations.json");
344
344
  let removedDir = false;
345
345
  let removedEntry = false;
346
- if (existsSync3(extensionDir)) {
346
+ if (existsSync4(extensionDir)) {
347
347
  rmSync(extensionDir, { recursive: true, force: true });
348
348
  removedDir = true;
349
349
  }
350
- if (existsSync3(registryPath)) {
350
+ if (existsSync4(registryPath)) {
351
351
  try {
352
352
  const raw = readFileSync3(registryPath, "utf8");
353
353
  const parsed = JSON.parse(raw);
@@ -374,7 +374,7 @@ async function removeDxtExtension(claudeSupportDir) {
374
374
  }
375
375
 
376
376
  // installer/installer-gui.ts
377
- import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
377
+ import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
378
378
 
379
379
  // installer/install-shared.ts
380
380
  import { spawn as spawn2 } from "child_process";
@@ -523,7 +523,7 @@ import { createHash, randomBytes } from "crypto";
523
523
  import { createServer } from "http";
524
524
  import { request as httpsRequestRaw } from "https";
525
525
  import { spawn as spawn3 } from "child_process";
526
- import { readdirSync } from "fs";
526
+ import { readdirSync, existsSync as existsSync2 } from "fs";
527
527
  var LEADBAY_LOOPBACK_PORTS = [51789, 51790, 51791, 51792];
528
528
  var BrowserOpenFailedError = class extends Error {
529
529
  authorizeUrl;
@@ -843,7 +843,19 @@ function browserOpenCandidates(url) {
843
843
  function browserLaunchEnv(debug) {
844
844
  const env = { ...process.env };
845
845
  if (process.platform !== "linux") return env;
846
- const runtimeDir = env.XDG_RUNTIME_DIR;
846
+ let runtimeDir = env.XDG_RUNTIME_DIR;
847
+ if (!runtimeDir || !existsSync2(runtimeDir)) {
848
+ try {
849
+ const uid = process.getuid?.();
850
+ const candidate = uid !== void 0 ? `/run/user/${uid}` : void 0;
851
+ if (candidate && existsSync2(candidate)) {
852
+ runtimeDir = candidate;
853
+ env.XDG_RUNTIME_DIR = candidate;
854
+ debug?.(`browserLaunchEnv: injected XDG_RUNTIME_DIR=${candidate}`);
855
+ }
856
+ } catch {
857
+ }
858
+ }
847
859
  if (!env.WAYLAND_DISPLAY && runtimeDir) {
848
860
  try {
849
861
  const sock = readdirSync(runtimeDir).find((f) => /^wayland-\d+$/.test(f));
@@ -854,6 +866,13 @@ function browserLaunchEnv(debug) {
854
866
  } catch {
855
867
  }
856
868
  }
869
+ if (!env.DBUS_SESSION_BUS_ADDRESS && runtimeDir) {
870
+ const busPath = `${runtimeDir}/bus`;
871
+ if (existsSync2(busPath)) {
872
+ env.DBUS_SESSION_BUS_ADDRESS = `unix:path=${busPath}`;
873
+ debug?.(`browserLaunchEnv: injected DBUS_SESSION_BUS_ADDRESS=unix:path=${busPath}`);
874
+ }
875
+ }
857
876
  if (!env.DISPLAY) {
858
877
  try {
859
878
  const x = readdirSync("/tmp/.X11-unix").map((f) => f.match(/^X(\d+)$/)?.[1]).filter((n) => !!n).sort((a, b) => Number(a) - Number(b))[0];
@@ -863,6 +882,25 @@ function browserLaunchEnv(debug) {
863
882
  }
864
883
  debug?.(`browserLaunchEnv: injected DISPLAY=${env.DISPLAY}`);
865
884
  }
885
+ if (!env.XAUTHORITY) {
886
+ try {
887
+ let xauth;
888
+ if (runtimeDir) {
889
+ const cookie = readdirSync(runtimeDir).find(
890
+ (f) => /^\.mutter-Xwaylandauth\./.test(f)
891
+ );
892
+ if (cookie) xauth = `${runtimeDir}/${cookie}`;
893
+ }
894
+ if (!xauth && env.HOME && existsSync2(`${env.HOME}/.Xauthority`)) {
895
+ xauth = `${env.HOME}/.Xauthority`;
896
+ }
897
+ if (xauth) {
898
+ env.XAUTHORITY = xauth;
899
+ debug?.(`browserLaunchEnv: injected XAUTHORITY=${xauth}`);
900
+ }
901
+ } catch {
902
+ }
903
+ }
866
904
  return env;
867
905
  }
868
906
  async function openInBrowser(url, debug) {
@@ -988,7 +1026,7 @@ async function isLeadbayConfigured(client) {
988
1026
  }
989
1027
  if (client.id === "codex") {
990
1028
  const configPath2 = client.detail;
991
- if (!existsSync2(configPath2)) return false;
1029
+ if (!existsSync3(configPath2)) return false;
992
1030
  try {
993
1031
  return readFileSync2(configPath2, "utf8").includes("[mcp_servers.leadbay]");
994
1032
  } catch {
@@ -997,7 +1035,7 @@ async function isLeadbayConfigured(client) {
997
1035
  }
998
1036
  if (client.id === "chatgpt-desktop") return false;
999
1037
  const configPath = client.configPath;
1000
- if (!configPath || !existsSync2(configPath)) return false;
1038
+ if (!configPath || !existsSync3(configPath)) return false;
1001
1039
  try {
1002
1040
  const parsed = JSON.parse(readFileSync2(configPath, "utf8"));
1003
1041
  return Boolean(parsed?.mcpServers?.leadbay);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leadbay/mcp",
3
- "version": "0.23.0",
3
+ "version": "0.23.1",
4
4
  "mcpName": "io.github.leadbay/leadbay-mcp",
5
5
  "description": "Model Context Protocol (MCP) server for Leadbay — AI lead discovery, qualification, and enrichment for Claude Desktop, Cursor, and Claude Code.",
6
6
  "type": "module",