mcp-use 1.11.0-canary.17 → 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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MCPClient
3
- } from "./chunk-ETMSIR6K.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-JQMHLTXF.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-JQMHLTXF.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-ETMSIR6K.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-QEEFUZ22.js";
7
+ } from "./chunk-M6HG2X4Q.js";
8
8
  import {
9
9
  Tel,
10
10
  getPackageVersion
11
- } from "./chunk-JQMHLTXF.js";
11
+ } from "./chunk-MIY5EBAT.js";
12
12
  import {
13
13
  logger
14
14
  } from "./chunk-FRUZDWXH.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Tel,
3
3
  Telemetry
4
- } from "./chunk-JQMHLTXF.js";
4
+ } from "./chunk-MIY5EBAT.js";
5
5
  import {
6
6
  logger
7
7
  } from "./chunk-FRUZDWXH.js";
@@ -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.17";
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-QEEFUZ22.js";
4
+ } from "./chunk-M6HG2X4Q.js";
5
5
  import {
6
6
  Tel,
7
7
  getPackageVersion
8
- } from "./chunk-JQMHLTXF.js";
8
+ } from "./chunk-MIY5EBAT.js";
9
9
  import {
10
10
  logger
11
11
  } from "./chunk-FRUZDWXH.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  BrowserMCPClient
3
- } from "./chunk-NTB5TTZW.js";
3
+ } from "./chunk-OD724W55.js";
4
4
  import {
5
5
  Tel
6
- } from "./chunk-JQMHLTXF.js";
6
+ } from "./chunk-MIY5EBAT.js";
7
7
  import {
8
8
  BrowserOAuthClientProvider,
9
9
  sanitizeUrl
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.17";
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);
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  import "./chunk-GXNAXUDI.js";
12
12
  import {
13
13
  PROMPTS
14
- } from "./chunk-XZM65NMN.js";
14
+ } from "./chunk-DKK3OEIY.js";
15
15
  import {
16
16
  AcquireActiveMCPServerTool,
17
17
  AddMCPServerFromConfigTool,
@@ -26,7 +26,7 @@ import {
26
26
  getSupportedProviders,
27
27
  isValidLLMString,
28
28
  parseLLMString
29
- } from "./chunk-LQJZY6OD.js";
29
+ } from "./chunk-6TCXBLDE.js";
30
30
  import "./chunk-JRGQRPTN.js";
31
31
  import {
32
32
  BaseCodeExecutor,
@@ -36,7 +36,7 @@ import {
36
36
  VMCodeExecutor,
37
37
  isVMAvailable,
38
38
  loadConfigFile
39
- } from "./chunk-ETMSIR6K.js";
39
+ } from "./chunk-I3NZCYBR.js";
40
40
  import {
41
41
  BaseAdapter
42
42
  } from "./chunk-MFSO5PUW.js";
@@ -52,20 +52,20 @@ import {
52
52
  useWidgetProps,
53
53
  useWidgetState,
54
54
  useWidgetTheme
55
- } from "./chunk-HNNUDW4Q.js";
56
- import "./chunk-NTB5TTZW.js";
55
+ } from "./chunk-SRXA64QS.js";
56
+ import "./chunk-OD724W55.js";
57
57
  import {
58
58
  BaseConnector,
59
59
  HttpConnector,
60
60
  MCPSession
61
- } from "./chunk-QEEFUZ22.js";
61
+ } from "./chunk-M6HG2X4Q.js";
62
62
  import {
63
63
  Tel,
64
64
  Telemetry,
65
65
  VERSION,
66
66
  getPackageVersion,
67
67
  setTelemetrySource
68
- } from "./chunk-JQMHLTXF.js";
68
+ } from "./chunk-MIY5EBAT.js";
69
69
  import {
70
70
  Logger,
71
71
  logger