mcp-use 1.11.0-canary.16 → 1.11.0-canary.18

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.
Files changed (34) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/{chunk-GVHS2DDJ.js → chunk-6TCXBLDE.js} +2 -2
  3. package/dist/{chunk-RU7FIJVM.js → chunk-BUUAJ4ZA.js} +1 -1
  4. package/dist/{chunk-76F72Y73.js → chunk-DKK3OEIY.js} +1 -1
  5. package/dist/{chunk-FMK46JYP.js → chunk-I3NZCYBR.js} +4 -2
  6. package/dist/{chunk-MGYJYTTX.js → chunk-M6HG2X4Q.js} +10 -1
  7. package/dist/{chunk-2FOTPDUJ.js → chunk-MIY5EBAT.js} +82 -43
  8. package/dist/{chunk-6AB7U4KA.js → chunk-OD724W55.js} +10 -4
  9. package/dist/{chunk-J56ACHX4.js → chunk-SRXA64QS.js} +8 -3
  10. package/dist/index.cjs +107 -46
  11. package/dist/index.js +13 -13
  12. package/dist/src/agents/index.cjs +93 -43
  13. package/dist/src/agents/index.js +5 -5
  14. package/dist/src/browser.cjs +101 -45
  15. package/dist/src/browser.js +10 -10
  16. package/dist/src/client/browser.d.ts.map +1 -1
  17. package/dist/src/client.cjs +93 -43
  18. package/dist/src/client.js +3 -3
  19. package/dist/src/config.d.ts.map +1 -1
  20. package/dist/src/connectors/http.d.ts +2 -0
  21. package/dist/src/connectors/http.d.ts.map +1 -1
  22. package/dist/src/react/index.cjs +105 -46
  23. package/dist/src/react/index.js +5 -5
  24. package/dist/src/react/useMcp.d.ts.map +1 -1
  25. package/dist/src/server/index.cjs +89 -46
  26. package/dist/src/server/index.js +12 -8
  27. package/dist/src/server/types/widget.d.ts +2 -2
  28. package/dist/src/server/types/widget.d.ts.map +1 -1
  29. package/dist/src/server/widgets/mount-widgets-dev.d.ts.map +1 -1
  30. package/dist/src/telemetry/telemetry.d.ts +1 -0
  31. package/dist/src/telemetry/telemetry.d.ts.map +1 -1
  32. package/dist/src/version.d.ts +1 -1
  33. package/dist/{tool-execution-helpers-7ZZVUHAM.js → tool-execution-helpers-YTLQZ7KG.js} +2 -2
  34. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MCPClient
3
- } from "./chunk-FMK46JYP.js";
3
+ } from "./chunk-I3NZCYBR.js";
4
4
  import {
5
5
  LangChainAdapter
6
6
  } from "./chunk-MFSO5PUW.js";
@@ -8,7 +8,7 @@ import {
8
8
  Telemetry,
9
9
  extractModelInfo,
10
10
  getPackageVersion
11
- } from "./chunk-2FOTPDUJ.js";
11
+ } from "./chunk-MIY5EBAT.js";
12
12
  import {
13
13
  logger
14
14
  } from "./chunk-FRUZDWXH.js";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  Telemetry,
6
6
  generateUUID
7
- } from "./chunk-2FOTPDUJ.js";
7
+ } from "./chunk-MIY5EBAT.js";
8
8
  import {
9
9
  __name
10
10
  } from "./chunk-3GQAWCBQ.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CODE_MODE_AGENT_PROMPT
3
- } from "./chunk-FMK46JYP.js";
3
+ } from "./chunk-I3NZCYBR.js";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-3GQAWCBQ.js";
@@ -4,11 +4,11 @@ import {
4
4
  ConnectionManager,
5
5
  HttpConnector,
6
6
  MCPSession
7
- } from "./chunk-MGYJYTTX.js";
7
+ } from "./chunk-M6HG2X4Q.js";
8
8
  import {
9
9
  Tel,
10
10
  getPackageVersion
11
- } from "./chunk-2FOTPDUJ.js";
11
+ } from "./chunk-MIY5EBAT.js";
12
12
  import {
13
13
  logger
14
14
  } from "./chunk-FRUZDWXH.js";
@@ -1024,6 +1024,8 @@ function createConnectorFromConfig(serverConfig, connectorOptions) {
1024
1024
  authToken: serverConfig.auth_token || serverConfig.authToken,
1025
1025
  // Only force SSE if explicitly requested
1026
1026
  preferSse: serverConfig.preferSse || transport === "sse",
1027
+ // Disable SSE fallback if explicitly disabled in config
1028
+ disableSseFallback: serverConfig.disableSseFallback,
1027
1029
  ...connectorOptions
1028
1030
  });
1029
1031
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Tel,
3
3
  Telemetry
4
- } from "./chunk-2FOTPDUJ.js";
4
+ } from "./chunk-MIY5EBAT.js";
5
5
  import {
6
6
  logger
7
7
  } from "./chunk-FRUZDWXH.js";
@@ -1111,6 +1111,7 @@ var HttpConnector = class extends BaseConnector {
1111
1111
  sseReadTimeout;
1112
1112
  clientInfo;
1113
1113
  preferSse;
1114
+ disableSseFallback;
1114
1115
  transportType = null;
1115
1116
  streamableTransport = null;
1116
1117
  constructor(baseUrl, opts = {}) {
@@ -1127,6 +1128,7 @@ var HttpConnector = class extends BaseConnector {
1127
1128
  version: "1.0.0"
1128
1129
  };
1129
1130
  this.preferSse = opts.preferSse ?? false;
1131
+ this.disableSseFallback = opts.disableSseFallback ?? false;
1130
1132
  }
1131
1133
  /** Establish connection to the MCP implementation via HTTP (streamable or SSE). */
1132
1134
  async connect() {
@@ -1183,6 +1185,13 @@ var HttpConnector = class extends BaseConnector {
1183
1185
  authError.code = 401;
1184
1186
  throw authError;
1185
1187
  }
1188
+ if (this.disableSseFallback) {
1189
+ logger.info("SSE fallback disabled - failing connection");
1190
+ await this.cleanupResources();
1191
+ throw new Error(
1192
+ `Streamable HTTP connection failed: ${fallbackReason}. SSE fallback is disabled.`
1193
+ );
1194
+ }
1186
1195
  logger.info("\u{1F504} Falling back to SSE transport...");
1187
1196
  try {
1188
1197
  await this.connectWithSse(baseUrl);
@@ -92,7 +92,7 @@ function generateUUID() {
92
92
  __name(generateUUID, "generateUUID");
93
93
 
94
94
  // src/version.ts
95
- var VERSION = "1.11.0-canary.16";
95
+ var VERSION = "1.11.0-canary.18";
96
96
  function getPackageVersion() {
97
97
  return VERSION;
98
98
  }
@@ -610,12 +610,26 @@ var Telemetry = class _Telemetry {
610
610
  "Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."
611
611
  );
612
612
  this._posthogLoading = this._initPostHog();
613
- try {
614
- this._scarfClient = new ScarfEventLogger(this.SCARF_GATEWAY_URL, 3e3);
615
- } catch (e) {
616
- logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
613
+ if (this._runtimeEnvironment !== "browser") {
614
+ try {
615
+ this._scarfClient = new ScarfEventLogger(
616
+ this.SCARF_GATEWAY_URL,
617
+ 3e3
618
+ );
619
+ } catch (e) {
620
+ logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
621
+ this._scarfClient = null;
622
+ }
623
+ } else {
617
624
  this._scarfClient = null;
618
625
  }
626
+ if (this._storageCapability === "filesystem" && this._scarfClient) {
627
+ setTimeout(() => {
628
+ this.trackPackageDownload({ triggered_by: "initialization" }).catch(
629
+ (e) => logger.debug(`Failed to track package download: ${e}`)
630
+ );
631
+ }, 0);
632
+ }
619
633
  }
620
634
  }
621
635
  _checkTelemetryDisabled() {
@@ -740,47 +754,65 @@ var Telemetry = class _Telemetry {
740
754
  break;
741
755
  case "session-only":
742
756
  default:
743
- this._currUserId = `session-${generateUUID()}`;
744
- logger.debug(
745
- `Using session-based user ID (${this._runtimeEnvironment} environment)`
746
- );
757
+ try {
758
+ this._currUserId = `session-${generateUUID()}`;
759
+ } catch (uuidError) {
760
+ this._currUserId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
761
+ }
747
762
  break;
748
763
  }
749
- if (this._storageCapability === "filesystem" && this._currUserId) {
750
- this._trackPackageDownloadInternal(this._currUserId, {
751
- triggered_by: "user_id_property"
752
- }).catch((e) => logger.debug(`Failed to track package download: ${e}`));
753
- }
754
764
  } catch (e) {
755
- logger.debug(`Failed to get/create user ID: ${e}`);
756
765
  this._currUserId = this.UNKNOWN_USER_ID;
757
766
  }
758
767
  return this._currUserId;
759
768
  }
760
769
  /**
761
770
  * Get or create user ID from filesystem (Node.js/Bun)
771
+ * Falls back to session ID if filesystem operations fail
762
772
  */
763
773
  _getUserIdFromFilesystem() {
764
- const fs = __require("fs");
765
- const os = __require("os");
766
- const path = __require("path");
767
- if (!this._userIdPath) {
768
- this._userIdPath = path.join(
769
- this._getCacheHome(os, path),
770
- "mcp_use_3",
771
- "telemetry_user_id"
772
- );
773
- }
774
- const isFirstTime = !fs.existsSync(this._userIdPath);
775
- if (isFirstTime) {
776
- logger.debug(`Creating user ID path: ${this._userIdPath}`);
777
- fs.mkdirSync(path.dirname(this._userIdPath), { recursive: true });
778
- const newUserId = generateUUID();
779
- fs.writeFileSync(this._userIdPath, newUserId);
780
- logger.debug(`User ID path created: ${this._userIdPath}`);
781
- return newUserId;
774
+ try {
775
+ let fs, os, path;
776
+ try {
777
+ fs = __require("fs");
778
+ os = __require("os");
779
+ path = __require("path");
780
+ } catch (requireError) {
781
+ try {
782
+ const sessionId = `session-${generateUUID()}`;
783
+ return sessionId;
784
+ } catch (uuidError) {
785
+ return `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
786
+ }
787
+ }
788
+ if (!this._userIdPath) {
789
+ this._userIdPath = path.join(
790
+ this._getCacheHome(os, path),
791
+ "mcp_use_3",
792
+ "telemetry_user_id"
793
+ );
794
+ }
795
+ const isFirstTime = !fs.existsSync(this._userIdPath);
796
+ if (isFirstTime) {
797
+ fs.mkdirSync(path.dirname(this._userIdPath), { recursive: true });
798
+ let newUserId;
799
+ try {
800
+ newUserId = generateUUID();
801
+ } catch (uuidError) {
802
+ newUserId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
803
+ }
804
+ fs.writeFileSync(this._userIdPath, newUserId);
805
+ return newUserId;
806
+ }
807
+ const userId = fs.readFileSync(this._userIdPath, "utf-8").trim();
808
+ return userId;
809
+ } catch (e) {
810
+ try {
811
+ return `session-${generateUUID()}`;
812
+ } catch (uuidError) {
813
+ return `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
814
+ }
782
815
  }
783
- return fs.readFileSync(this._userIdPath, "utf-8").trim();
784
816
  }
785
817
  /**
786
818
  * Get or create user ID from localStorage (Browser)
@@ -789,14 +821,22 @@ var Telemetry = class _Telemetry {
789
821
  try {
790
822
  let userId = localStorage.getItem(USER_ID_STORAGE_KEY);
791
823
  if (!userId) {
792
- userId = generateUUID();
824
+ try {
825
+ userId = generateUUID();
826
+ } catch (uuidError) {
827
+ userId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
828
+ }
793
829
  localStorage.setItem(USER_ID_STORAGE_KEY, userId);
794
- logger.debug(`Created new browser user ID`);
795
830
  }
796
831
  return userId;
797
832
  } catch (e) {
798
- logger.debug(`localStorage access failed: ${e}`);
799
- return `session-${generateUUID()}`;
833
+ let sessionId;
834
+ try {
835
+ sessionId = `session-${generateUUID()}`;
836
+ } catch (uuidError) {
837
+ sessionId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
838
+ }
839
+ return sessionId;
800
840
  }
801
841
  }
802
842
  _getCacheHome(os, path) {
@@ -825,6 +865,7 @@ var Telemetry = class _Telemetry {
825
865
  if (!this._posthogNodeClient && !this._posthogBrowserClient && !this._scarfClient) {
826
866
  return;
827
867
  }
868
+ const currentUserId = this.userId;
828
869
  const properties = { ...event.properties };
829
870
  properties.mcp_use_version = getPackageVersion();
830
871
  properties.language = "typescript";
@@ -832,9 +873,8 @@ var Telemetry = class _Telemetry {
832
873
  properties.runtime = this._runtimeEnvironment;
833
874
  if (this._posthogNodeClient) {
834
875
  try {
835
- logger.debug(`CAPTURE: PostHog Node Event ${event.name}`);
836
876
  this._posthogNodeClient.capture({
837
- distinctId: this.userId,
877
+ distinctId: currentUserId,
838
878
  event: event.name,
839
879
  properties
840
880
  });
@@ -844,10 +884,9 @@ var Telemetry = class _Telemetry {
844
884
  }
845
885
  if (this._posthogBrowserClient) {
846
886
  try {
847
- logger.debug(`CAPTURE: PostHog Browser Event ${event.name}`);
848
887
  this._posthogBrowserClient.capture(event.name, {
849
888
  ...properties,
850
- distinct_id: this.userId
889
+ distinct_id: currentUserId
851
890
  });
852
891
  } catch (e) {
853
892
  logger.debug(
@@ -859,7 +898,7 @@ var Telemetry = class _Telemetry {
859
898
  try {
860
899
  const scarfProperties = {
861
900
  ...properties,
862
- user_id: this.userId,
901
+ user_id: currentUserId,
863
902
  event: event.name
864
903
  };
865
904
  await this._scarfClient.logEvent(scarfProperties);
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  BaseMCPClient,
3
3
  HttpConnector
4
- } from "./chunk-MGYJYTTX.js";
4
+ } from "./chunk-M6HG2X4Q.js";
5
5
  import {
6
6
  Tel,
7
7
  getPackageVersion
8
- } from "./chunk-2FOTPDUJ.js";
8
+ } from "./chunk-MIY5EBAT.js";
9
9
  import {
10
10
  logger
11
11
  } from "./chunk-FRUZDWXH.js";
@@ -63,7 +63,9 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
63
63
  wrapTransport,
64
64
  clientOptions,
65
65
  samplingCallback,
66
- elicitationCallback
66
+ elicitationCallback,
67
+ disableSseFallback,
68
+ preferSse
67
69
  } = serverConfig;
68
70
  if (!url) {
69
71
  throw new Error("Server URL is required");
@@ -79,8 +81,12 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
79
81
  // ← Pass client options (capabilities, etc.) to connector
80
82
  samplingCallback,
81
83
  // ← Pass sampling callback to connector
82
- elicitationCallback
84
+ elicitationCallback,
83
85
  // ← Pass elicitation callback to connector
86
+ disableSseFallback,
87
+ // ← Disable automatic SSE fallback
88
+ preferSse
89
+ // ← Use SSE transport directly
84
90
  };
85
91
  if (clientOptions) {
86
92
  console.log(
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  BrowserMCPClient
3
- } from "./chunk-6AB7U4KA.js";
3
+ } from "./chunk-OD724W55.js";
4
4
  import {
5
5
  Tel
6
- } from "./chunk-2FOTPDUJ.js";
6
+ } from "./chunk-MIY5EBAT.js";
7
7
  import {
8
8
  BrowserOAuthClientProvider,
9
9
  sanitizeUrl
@@ -207,7 +207,12 @@ function useMcp(options) {
207
207
  const serverName = "inspector-server";
208
208
  const serverConfig = {
209
209
  url,
210
- transport: transportTypeParam === "sse" ? "http" : transportTypeParam
210
+ transport: transportTypeParam === "sse" ? "http" : transportTypeParam,
211
+ // Disable SSE fallback when using explicit HTTP transport (not SSE)
212
+ // This prevents automatic HTTP → SSE fallback at the connector level
213
+ disableSseFallback: transportTypeParam === "http",
214
+ // Use SSE transport when explicitly requested
215
+ preferSse: transportTypeParam === "sse"
211
216
  };
212
217
  if (customHeaders && Object.keys(customHeaders).length > 0) {
213
218
  serverConfig.headers = customHeaders;
package/dist/index.cjs CHANGED
@@ -2790,7 +2790,7 @@ __name(generateUUID, "generateUUID");
2790
2790
  init_logging();
2791
2791
 
2792
2792
  // src/version.ts
2793
- var VERSION = "1.11.0-canary.16";
2793
+ var VERSION = "1.11.0-canary.18";
2794
2794
  function getPackageVersion() {
2795
2795
  return VERSION;
2796
2796
  }
@@ -2960,12 +2960,26 @@ var Telemetry = class _Telemetry {
2960
2960
  "Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."
2961
2961
  );
2962
2962
  this._posthogLoading = this._initPostHog();
2963
- try {
2964
- this._scarfClient = new ScarfEventLogger(this.SCARF_GATEWAY_URL, 3e3);
2965
- } catch (e) {
2966
- logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
2963
+ if (this._runtimeEnvironment !== "browser") {
2964
+ try {
2965
+ this._scarfClient = new ScarfEventLogger(
2966
+ this.SCARF_GATEWAY_URL,
2967
+ 3e3
2968
+ );
2969
+ } catch (e) {
2970
+ logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
2971
+ this._scarfClient = null;
2972
+ }
2973
+ } else {
2967
2974
  this._scarfClient = null;
2968
2975
  }
2976
+ if (this._storageCapability === "filesystem" && this._scarfClient) {
2977
+ setTimeout(() => {
2978
+ this.trackPackageDownload({ triggered_by: "initialization" }).catch(
2979
+ (e) => logger.debug(`Failed to track package download: ${e}`)
2980
+ );
2981
+ }, 0);
2982
+ }
2969
2983
  }
2970
2984
  }
2971
2985
  _checkTelemetryDisabled() {
@@ -3090,47 +3104,65 @@ var Telemetry = class _Telemetry {
3090
3104
  break;
3091
3105
  case "session-only":
3092
3106
  default:
3093
- this._currUserId = `session-${generateUUID()}`;
3094
- logger.debug(
3095
- `Using session-based user ID (${this._runtimeEnvironment} environment)`
3096
- );
3107
+ try {
3108
+ this._currUserId = `session-${generateUUID()}`;
3109
+ } catch (uuidError) {
3110
+ this._currUserId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
3111
+ }
3097
3112
  break;
3098
3113
  }
3099
- if (this._storageCapability === "filesystem" && this._currUserId) {
3100
- this._trackPackageDownloadInternal(this._currUserId, {
3101
- triggered_by: "user_id_property"
3102
- }).catch((e) => logger.debug(`Failed to track package download: ${e}`));
3103
- }
3104
3114
  } catch (e) {
3105
- logger.debug(`Failed to get/create user ID: ${e}`);
3106
3115
  this._currUserId = this.UNKNOWN_USER_ID;
3107
3116
  }
3108
3117
  return this._currUserId;
3109
3118
  }
3110
3119
  /**
3111
3120
  * Get or create user ID from filesystem (Node.js/Bun)
3121
+ * Falls back to session ID if filesystem operations fail
3112
3122
  */
3113
3123
  _getUserIdFromFilesystem() {
3114
- const fs2 = require("fs");
3115
- const os = require("os");
3116
- const path2 = require("path");
3117
- if (!this._userIdPath) {
3118
- this._userIdPath = path2.join(
3119
- this._getCacheHome(os, path2),
3120
- "mcp_use_3",
3121
- "telemetry_user_id"
3122
- );
3123
- }
3124
- const isFirstTime = !fs2.existsSync(this._userIdPath);
3125
- if (isFirstTime) {
3126
- logger.debug(`Creating user ID path: ${this._userIdPath}`);
3127
- fs2.mkdirSync(path2.dirname(this._userIdPath), { recursive: true });
3128
- const newUserId = generateUUID();
3129
- fs2.writeFileSync(this._userIdPath, newUserId);
3130
- logger.debug(`User ID path created: ${this._userIdPath}`);
3131
- return newUserId;
3124
+ try {
3125
+ let fs2, os, path2;
3126
+ try {
3127
+ fs2 = require("fs");
3128
+ os = require("os");
3129
+ path2 = require("path");
3130
+ } catch (requireError) {
3131
+ try {
3132
+ const sessionId = `session-${generateUUID()}`;
3133
+ return sessionId;
3134
+ } catch (uuidError) {
3135
+ return `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
3136
+ }
3137
+ }
3138
+ if (!this._userIdPath) {
3139
+ this._userIdPath = path2.join(
3140
+ this._getCacheHome(os, path2),
3141
+ "mcp_use_3",
3142
+ "telemetry_user_id"
3143
+ );
3144
+ }
3145
+ const isFirstTime = !fs2.existsSync(this._userIdPath);
3146
+ if (isFirstTime) {
3147
+ fs2.mkdirSync(path2.dirname(this._userIdPath), { recursive: true });
3148
+ let newUserId;
3149
+ try {
3150
+ newUserId = generateUUID();
3151
+ } catch (uuidError) {
3152
+ newUserId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
3153
+ }
3154
+ fs2.writeFileSync(this._userIdPath, newUserId);
3155
+ return newUserId;
3156
+ }
3157
+ const userId = fs2.readFileSync(this._userIdPath, "utf-8").trim();
3158
+ return userId;
3159
+ } catch (e) {
3160
+ try {
3161
+ return `session-${generateUUID()}`;
3162
+ } catch (uuidError) {
3163
+ return `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
3164
+ }
3132
3165
  }
3133
- return fs2.readFileSync(this._userIdPath, "utf-8").trim();
3134
3166
  }
3135
3167
  /**
3136
3168
  * Get or create user ID from localStorage (Browser)
@@ -3139,14 +3171,22 @@ var Telemetry = class _Telemetry {
3139
3171
  try {
3140
3172
  let userId = localStorage.getItem(USER_ID_STORAGE_KEY);
3141
3173
  if (!userId) {
3142
- userId = generateUUID();
3174
+ try {
3175
+ userId = generateUUID();
3176
+ } catch (uuidError) {
3177
+ userId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
3178
+ }
3143
3179
  localStorage.setItem(USER_ID_STORAGE_KEY, userId);
3144
- logger.debug(`Created new browser user ID`);
3145
3180
  }
3146
3181
  return userId;
3147
3182
  } catch (e) {
3148
- logger.debug(`localStorage access failed: ${e}`);
3149
- return `session-${generateUUID()}`;
3183
+ let sessionId;
3184
+ try {
3185
+ sessionId = `session-${generateUUID()}`;
3186
+ } catch (uuidError) {
3187
+ sessionId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
3188
+ }
3189
+ return sessionId;
3150
3190
  }
3151
3191
  }
3152
3192
  _getCacheHome(os, path2) {
@@ -3175,6 +3215,7 @@ var Telemetry = class _Telemetry {
3175
3215
  if (!this._posthogNodeClient && !this._posthogBrowserClient && !this._scarfClient) {
3176
3216
  return;
3177
3217
  }
3218
+ const currentUserId = this.userId;
3178
3219
  const properties = { ...event.properties };
3179
3220
  properties.mcp_use_version = getPackageVersion();
3180
3221
  properties.language = "typescript";
@@ -3182,9 +3223,8 @@ var Telemetry = class _Telemetry {
3182
3223
  properties.runtime = this._runtimeEnvironment;
3183
3224
  if (this._posthogNodeClient) {
3184
3225
  try {
3185
- logger.debug(`CAPTURE: PostHog Node Event ${event.name}`);
3186
3226
  this._posthogNodeClient.capture({
3187
- distinctId: this.userId,
3227
+ distinctId: currentUserId,
3188
3228
  event: event.name,
3189
3229
  properties
3190
3230
  });
@@ -3194,10 +3234,9 @@ var Telemetry = class _Telemetry {
3194
3234
  }
3195
3235
  if (this._posthogBrowserClient) {
3196
3236
  try {
3197
- logger.debug(`CAPTURE: PostHog Browser Event ${event.name}`);
3198
3237
  this._posthogBrowserClient.capture(event.name, {
3199
3238
  ...properties,
3200
- distinct_id: this.userId
3239
+ distinct_id: currentUserId
3201
3240
  });
3202
3241
  } catch (e) {
3203
3242
  logger.debug(
@@ -3209,7 +3248,7 @@ var Telemetry = class _Telemetry {
3209
3248
  try {
3210
3249
  const scarfProperties = {
3211
3250
  ...properties,
3212
- user_id: this.userId,
3251
+ user_id: currentUserId,
3213
3252
  event: event.name
3214
3253
  };
3215
3254
  await this._scarfClient.logEvent(scarfProperties);
@@ -5121,6 +5160,7 @@ var HttpConnector = class extends BaseConnector {
5121
5160
  sseReadTimeout;
5122
5161
  clientInfo;
5123
5162
  preferSse;
5163
+ disableSseFallback;
5124
5164
  transportType = null;
5125
5165
  streamableTransport = null;
5126
5166
  constructor(baseUrl, opts = {}) {
@@ -5137,6 +5177,7 @@ var HttpConnector = class extends BaseConnector {
5137
5177
  version: "1.0.0"
5138
5178
  };
5139
5179
  this.preferSse = opts.preferSse ?? false;
5180
+ this.disableSseFallback = opts.disableSseFallback ?? false;
5140
5181
  }
5141
5182
  /** Establish connection to the MCP implementation via HTTP (streamable or SSE). */
5142
5183
  async connect() {
@@ -5193,6 +5234,13 @@ var HttpConnector = class extends BaseConnector {
5193
5234
  authError.code = 401;
5194
5235
  throw authError;
5195
5236
  }
5237
+ if (this.disableSseFallback) {
5238
+ logger.info("SSE fallback disabled - failing connection");
5239
+ await this.cleanupResources();
5240
+ throw new Error(
5241
+ `Streamable HTTP connection failed: ${fallbackReason}. SSE fallback is disabled.`
5242
+ );
5243
+ }
5196
5244
  logger.info("\u{1F504} Falling back to SSE transport...");
5197
5245
  try {
5198
5246
  await this.connectWithSse(baseUrl);
@@ -5559,6 +5607,8 @@ function createConnectorFromConfig(serverConfig, connectorOptions) {
5559
5607
  authToken: serverConfig.auth_token || serverConfig.authToken,
5560
5608
  // Only force SSE if explicitly requested
5561
5609
  preferSse: serverConfig.preferSse || transport === "sse",
5610
+ // Disable SSE fallback if explicitly disabled in config
5611
+ disableSseFallback: serverConfig.disableSseFallback,
5562
5612
  ...connectorOptions
5563
5613
  });
5564
5614
  }
@@ -9318,7 +9368,9 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
9318
9368
  wrapTransport,
9319
9369
  clientOptions,
9320
9370
  samplingCallback,
9321
- elicitationCallback
9371
+ elicitationCallback,
9372
+ disableSseFallback,
9373
+ preferSse
9322
9374
  } = serverConfig;
9323
9375
  if (!url) {
9324
9376
  throw new Error("Server URL is required");
@@ -9334,8 +9386,12 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
9334
9386
  // ← Pass client options (capabilities, etc.) to connector
9335
9387
  samplingCallback,
9336
9388
  // ← Pass sampling callback to connector
9337
- elicitationCallback
9389
+ elicitationCallback,
9338
9390
  // ← Pass elicitation callback to connector
9391
+ disableSseFallback,
9392
+ // ← Disable automatic SSE fallback
9393
+ preferSse
9394
+ // ← Use SSE transport directly
9339
9395
  };
9340
9396
  if (clientOptions) {
9341
9397
  console.log(
@@ -9543,7 +9599,12 @@ function useMcp(options) {
9543
9599
  const serverName = "inspector-server";
9544
9600
  const serverConfig = {
9545
9601
  url,
9546
- transport: transportTypeParam === "sse" ? "http" : transportTypeParam
9602
+ transport: transportTypeParam === "sse" ? "http" : transportTypeParam,
9603
+ // Disable SSE fallback when using explicit HTTP transport (not SSE)
9604
+ // This prevents automatic HTTP → SSE fallback at the connector level
9605
+ disableSseFallback: transportTypeParam === "http",
9606
+ // Use SSE transport when explicitly requested
9607
+ preferSse: transportTypeParam === "sse"
9547
9608
  };
9548
9609
  if (customHeaders && Object.keys(customHeaders).length > 0) {
9549
9610
  serverConfig.headers = customHeaders;