@egain/egain-mcp-server 1.0.1 → 1.0.3

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/bin/mcp-server.js CHANGED
@@ -4046,9 +4046,9 @@ var init_config = __esm(() => {
4046
4046
  SDK_METADATA = {
4047
4047
  language: "typescript",
4048
4048
  openapiDocVersion: "1.0.0",
4049
- sdkVersion: "1.0.1",
4049
+ sdkVersion: "1.0.3",
4050
4050
  genVersion: "2.723.8",
4051
- userAgent: "speakeasy-sdk/mcp-typescript 1.0.1 2.723.8 1.0.0 @egain/egain-mcp-server"
4051
+ userAgent: "speakeasy-sdk/mcp-typescript 1.0.3 2.723.8 1.0.0 @egain/egain-mcp-server"
4052
4052
  };
4053
4053
  });
4054
4054
 
@@ -42537,9 +42537,130 @@ class ServerRoutingHook {
42537
42537
  }
42538
42538
  }
42539
42539
 
42540
+ // src/hooks/version-check-hook.ts
42541
+ import * as fs3 from "fs";
42542
+ import * as path3 from "path";
42543
+ import { fileURLToPath as fileURLToPath3 } from "url";
42544
+ function compareVersions(v1, v2) {
42545
+ const parts1 = v1.split(".").map(Number);
42546
+ const parts2 = v2.split(".").map(Number);
42547
+ for (let i = 0;i < Math.max(parts1.length, parts2.length); i++) {
42548
+ const part1 = parts1[i] || 0;
42549
+ const part2 = parts2[i] || 0;
42550
+ if (part1 > part2)
42551
+ return 1;
42552
+ if (part1 < part2)
42553
+ return -1;
42554
+ }
42555
+ return 0;
42556
+ }
42557
+ function isGitRepo(projectRoot) {
42558
+ try {
42559
+ const gitDir = path3.join(projectRoot, ".git");
42560
+ return fs3.existsSync(gitDir) || fs3.existsSync(path3.join(projectRoot, ".git", "HEAD"));
42561
+ } catch {
42562
+ return false;
42563
+ }
42564
+ }
42565
+ function getLocalVersion() {
42566
+ try {
42567
+ const projectRoot = getProjectRoot3();
42568
+ const packageJsonPath = path3.join(projectRoot, "package.json");
42569
+ if (fs3.existsSync(packageJsonPath)) {
42570
+ const packageJson = JSON.parse(fs3.readFileSync(packageJsonPath, "utf8"));
42571
+ return packageJson.version || null;
42572
+ }
42573
+ } catch (error) {
42574
+ console.error("⚠️ Could not read local version:", error);
42575
+ }
42576
+ return null;
42577
+ }
42578
+ async function getLatestVersion() {
42579
+ try {
42580
+ const packageName = "@egain/egain-mcp-server";
42581
+ const registryUrl = `https://registry.npmjs.org/${packageName}`;
42582
+ const response = await fetch(registryUrl, {
42583
+ headers: {
42584
+ Accept: "application/json"
42585
+ }
42586
+ });
42587
+ if (!response.ok) {
42588
+ throw new Error(`npm registry returned ${response.status}`);
42589
+ }
42590
+ const data = await response.json();
42591
+ return data["dist-tags"]?.latest || null;
42592
+ } catch (error) {
42593
+ return null;
42594
+ }
42595
+ }
42596
+
42597
+ class VersionCheckHook {
42598
+ checkPerformed = false;
42599
+ sdkInit(opts) {
42600
+ if (this.checkPerformed) {
42601
+ return opts;
42602
+ }
42603
+ this.checkPerformed = true;
42604
+ setImmediate(async () => {
42605
+ try {
42606
+ const localVersion = getLocalVersion();
42607
+ if (!localVersion) {
42608
+ console.error("⚠️ Could not determine local version");
42609
+ return;
42610
+ }
42611
+ console.error(`\uD83D\uDCE6 Checking for updates (current version: ${localVersion})...`);
42612
+ const latestVersion = await getLatestVersion();
42613
+ if (!latestVersion) {
42614
+ return;
42615
+ }
42616
+ if (compareVersions(latestVersion, localVersion) > 0) {
42617
+ const projectRoot = getProjectRoot3();
42618
+ const isGit = isGitRepo(projectRoot);
42619
+ console.error("");
42620
+ console.error("⚠️ UPDATE AVAILABLE");
42621
+ console.error(` Current version: ${localVersion}`);
42622
+ console.error(` Latest version: ${latestVersion}`);
42623
+ if (isGit) {
42624
+ console.error(` Update with: git pull && npm run build`);
42625
+ console.error(` Or visit: https://github.com/eGain/egain-mcp-server`);
42626
+ } else {
42627
+ console.error(` Update with: npm install -g @egain/egain-mcp-server@latest`);
42628
+ console.error(` Or visit: https://www.npmjs.com/package/@egain/egain-mcp-server`);
42629
+ }
42630
+ console.error("");
42631
+ } else {
42632
+ console.error(`✅ You are running the latest version (${localVersion})`);
42633
+ }
42634
+ } catch (error) {
42635
+ if (error instanceof Error && !error.message.includes("fetch")) {
42636
+ console.error("⚠️ Version check failed:", error.message);
42637
+ }
42638
+ }
42639
+ });
42640
+ return opts;
42641
+ }
42642
+ }
42643
+ var __filename4, __dirname4, getProjectRoot3 = () => {
42644
+ let currentDir = __dirname4;
42645
+ while (currentDir !== path3.dirname(currentDir)) {
42646
+ if (fs3.existsSync(path3.join(currentDir, "package.json"))) {
42647
+ return currentDir;
42648
+ }
42649
+ currentDir = path3.dirname(currentDir);
42650
+ }
42651
+ return process.cwd();
42652
+ };
42653
+ var init_version_check_hook = __esm(() => {
42654
+ __filename4 = fileURLToPath3(import.meta.url);
42655
+ __dirname4 = path3.dirname(__filename4);
42656
+ });
42657
+
42540
42658
  // src/hooks/registration.ts
42541
42659
  function initHooks(hooks) {
42542
42660
  console.error("\uD83D\uDE80 Initializing eGain MCP hooks...");
42661
+ const versionCheckHook = new VersionCheckHook;
42662
+ hooks.registerSDKInitHook(versionCheckHook);
42663
+ console.error("✅ VERSION: Registered version check hook for SDK init");
42543
42664
  const serverRoutingHook = new ServerRoutingHook;
42544
42665
  hooks.registerBeforeCreateRequestHook(serverRoutingHook);
42545
42666
  console.error("✅ ROUTING: Registered server routing hook for before create request");
@@ -42559,6 +42680,7 @@ function initHooks(hooks) {
42559
42680
  var init_registration = __esm(() => {
42560
42681
  init_auth_hook();
42561
42682
  init_portal_cache_hook();
42683
+ init_version_check_hook();
42562
42684
  });
42563
42685
 
42564
42686
  // src/hooks/hooks.ts
@@ -43282,14 +43404,14 @@ class ClientSDK {
43282
43404
  }
43283
43405
  }
43284
43406
  _createRequest(context, conf, options) {
43285
- const { method, path: path3, query, headers: opHeaders, security } = conf;
43407
+ const { method, path: path4, query, headers: opHeaders, security } = conf;
43286
43408
  const base = conf.baseURL ?? this._baseURL;
43287
43409
  if (!base) {
43288
43410
  return ERR(new InvalidRequestError("No base URL provided for operation"));
43289
43411
  }
43290
43412
  const reqURL = new URL(base);
43291
- const inputURL = new URL(path3, reqURL);
43292
- if (path3) {
43413
+ const inputURL = new URL(path4, reqURL);
43414
+ if (path4) {
43293
43415
  reqURL.pathname += reqURL.pathname.endsWith("/") ? "" : "/";
43294
43416
  reqURL.pathname += inputURL.pathname.replace(/^\/+/, "");
43295
43417
  }
@@ -43708,9 +43830,9 @@ ${pre}${str}`;
43708
43830
  append(`┌ ${headline}:`);
43709
43831
  }
43710
43832
  for (const issue of err.issues) {
43711
- let path3 = issue.path.join(".");
43712
- path3 = path3 ? `<root>.${path3}` : "<root>";
43713
- append(`│ • [${path3}]: ${issue.message} (${issue.code})`);
43833
+ let path4 = issue.path.join(".");
43834
+ path4 = path4 ? `<root>.${path4}` : "<root>";
43835
+ append(`│ • [${path4}]: ${issue.message} (${issue.code})`);
43714
43836
  switch (issue.code) {
43715
43837
  case "invalid_literal":
43716
43838
  case "invalid_type": {
@@ -46558,7 +46680,7 @@ The Search API is a hybrid search service that combines semantic understanding w
46558
46680
  function createMCPServer(deps) {
46559
46681
  const server = new McpServer({
46560
46682
  name: "EgainMcp",
46561
- version: "1.0.1"
46683
+ version: "1.0.3"
46562
46684
  });
46563
46685
  const getClient = deps.getSDK || (() => new EgainMcpCore({
46564
46686
  security: deps.security,
@@ -47805,7 +47927,7 @@ var routes = ln({
47805
47927
  var app = _e(routes, {
47806
47928
  name: "mcp",
47807
47929
  versionInfo: {
47808
- currentVersion: "1.0.1"
47930
+ currentVersion: "1.0.3"
47809
47931
  }
47810
47932
  });
47811
47933
  Yt(app, process3.argv.slice(2), buildContext(process3));
@@ -47813,5 +47935,5 @@ export {
47813
47935
  app
47814
47936
  };
47815
47937
 
47816
- //# debugId=CFDE82BD7FF7EE8864756E2164756E21
47938
+ //# debugId=A87EA3D49B80393764756E2164756E21
47817
47939
  //# sourceMappingURL=mcp-server.js.map