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
package/dist/index.js CHANGED
@@ -8,9 +8,10 @@ import {
8
8
  streamEventsToAISDK,
9
9
  streamEventsToAISDKWithTools
10
10
  } from "./chunk-LGDFGYRL.js";
11
+ import "./chunk-GXNAXUDI.js";
11
12
  import {
12
13
  PROMPTS
13
- } from "./chunk-76F72Y73.js";
14
+ } from "./chunk-DKK3OEIY.js";
14
15
  import {
15
16
  AcquireActiveMCPServerTool,
16
17
  AddMCPServerFromConfigTool,
@@ -25,7 +26,7 @@ import {
25
26
  getSupportedProviders,
26
27
  isValidLLMString,
27
28
  parseLLMString
28
- } from "./chunk-GVHS2DDJ.js";
29
+ } from "./chunk-6TCXBLDE.js";
29
30
  import "./chunk-JRGQRPTN.js";
30
31
  import {
31
32
  BaseCodeExecutor,
@@ -35,12 +36,11 @@ import {
35
36
  VMCodeExecutor,
36
37
  isVMAvailable,
37
38
  loadConfigFile
38
- } from "./chunk-FMK46JYP.js";
39
- import "./chunk-JQKKMUCT.js";
40
- import "./chunk-GXNAXUDI.js";
39
+ } from "./chunk-I3NZCYBR.js";
41
40
  import {
42
41
  BaseAdapter
43
42
  } from "./chunk-MFSO5PUW.js";
43
+ import "./chunk-JQKKMUCT.js";
44
44
  import {
45
45
  ErrorBoundary,
46
46
  Image,
@@ -52,28 +52,28 @@ import {
52
52
  useWidgetProps,
53
53
  useWidgetState,
54
54
  useWidgetTheme
55
- } from "./chunk-J56ACHX4.js";
56
- import "./chunk-6AB7U4KA.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-MGYJYTTX.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-2FOTPDUJ.js";
69
- import {
70
- BrowserOAuthClientProvider,
71
- onMcpAuthorization
72
- } from "./chunk-J75I2C26.js";
68
+ } from "./chunk-MIY5EBAT.js";
73
69
  import {
74
70
  Logger,
75
71
  logger
76
72
  } from "./chunk-FRUZDWXH.js";
73
+ import {
74
+ BrowserOAuthClientProvider,
75
+ onMcpAuthorization
76
+ } from "./chunk-J75I2C26.js";
77
77
  import {
78
78
  __name
79
79
  } from "./chunk-3GQAWCBQ.js";
@@ -1417,7 +1417,7 @@ __name(generateUUID, "generateUUID");
1417
1417
  init_logging();
1418
1418
 
1419
1419
  // src/version.ts
1420
- var VERSION = "1.11.0-canary.16";
1420
+ var VERSION = "1.11.0-canary.18";
1421
1421
  function getPackageVersion() {
1422
1422
  return VERSION;
1423
1423
  }
@@ -1587,12 +1587,26 @@ var Telemetry = class _Telemetry {
1587
1587
  "Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."
1588
1588
  );
1589
1589
  this._posthogLoading = this._initPostHog();
1590
- try {
1591
- this._scarfClient = new ScarfEventLogger(this.SCARF_GATEWAY_URL, 3e3);
1592
- } catch (e) {
1593
- logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
1590
+ if (this._runtimeEnvironment !== "browser") {
1591
+ try {
1592
+ this._scarfClient = new ScarfEventLogger(
1593
+ this.SCARF_GATEWAY_URL,
1594
+ 3e3
1595
+ );
1596
+ } catch (e) {
1597
+ logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
1598
+ this._scarfClient = null;
1599
+ }
1600
+ } else {
1594
1601
  this._scarfClient = null;
1595
1602
  }
1603
+ if (this._storageCapability === "filesystem" && this._scarfClient) {
1604
+ setTimeout(() => {
1605
+ this.trackPackageDownload({ triggered_by: "initialization" }).catch(
1606
+ (e) => logger.debug(`Failed to track package download: ${e}`)
1607
+ );
1608
+ }, 0);
1609
+ }
1596
1610
  }
1597
1611
  }
1598
1612
  _checkTelemetryDisabled() {
@@ -1717,47 +1731,65 @@ var Telemetry = class _Telemetry {
1717
1731
  break;
1718
1732
  case "session-only":
1719
1733
  default:
1720
- this._currUserId = `session-${generateUUID()}`;
1721
- logger.debug(
1722
- `Using session-based user ID (${this._runtimeEnvironment} environment)`
1723
- );
1734
+ try {
1735
+ this._currUserId = `session-${generateUUID()}`;
1736
+ } catch (uuidError) {
1737
+ this._currUserId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
1738
+ }
1724
1739
  break;
1725
1740
  }
1726
- if (this._storageCapability === "filesystem" && this._currUserId) {
1727
- this._trackPackageDownloadInternal(this._currUserId, {
1728
- triggered_by: "user_id_property"
1729
- }).catch((e) => logger.debug(`Failed to track package download: ${e}`));
1730
- }
1731
1741
  } catch (e) {
1732
- logger.debug(`Failed to get/create user ID: ${e}`);
1733
1742
  this._currUserId = this.UNKNOWN_USER_ID;
1734
1743
  }
1735
1744
  return this._currUserId;
1736
1745
  }
1737
1746
  /**
1738
1747
  * Get or create user ID from filesystem (Node.js/Bun)
1748
+ * Falls back to session ID if filesystem operations fail
1739
1749
  */
1740
1750
  _getUserIdFromFilesystem() {
1741
- const fs2 = require("fs");
1742
- const os = require("os");
1743
- const path2 = require("path");
1744
- if (!this._userIdPath) {
1745
- this._userIdPath = path2.join(
1746
- this._getCacheHome(os, path2),
1747
- "mcp_use_3",
1748
- "telemetry_user_id"
1749
- );
1750
- }
1751
- const isFirstTime = !fs2.existsSync(this._userIdPath);
1752
- if (isFirstTime) {
1753
- logger.debug(`Creating user ID path: ${this._userIdPath}`);
1754
- fs2.mkdirSync(path2.dirname(this._userIdPath), { recursive: true });
1755
- const newUserId = generateUUID();
1756
- fs2.writeFileSync(this._userIdPath, newUserId);
1757
- logger.debug(`User ID path created: ${this._userIdPath}`);
1758
- return newUserId;
1751
+ try {
1752
+ let fs2, os, path2;
1753
+ try {
1754
+ fs2 = require("fs");
1755
+ os = require("os");
1756
+ path2 = require("path");
1757
+ } catch (requireError) {
1758
+ try {
1759
+ const sessionId = `session-${generateUUID()}`;
1760
+ return sessionId;
1761
+ } catch (uuidError) {
1762
+ return `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
1763
+ }
1764
+ }
1765
+ if (!this._userIdPath) {
1766
+ this._userIdPath = path2.join(
1767
+ this._getCacheHome(os, path2),
1768
+ "mcp_use_3",
1769
+ "telemetry_user_id"
1770
+ );
1771
+ }
1772
+ const isFirstTime = !fs2.existsSync(this._userIdPath);
1773
+ if (isFirstTime) {
1774
+ fs2.mkdirSync(path2.dirname(this._userIdPath), { recursive: true });
1775
+ let newUserId;
1776
+ try {
1777
+ newUserId = generateUUID();
1778
+ } catch (uuidError) {
1779
+ newUserId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
1780
+ }
1781
+ fs2.writeFileSync(this._userIdPath, newUserId);
1782
+ return newUserId;
1783
+ }
1784
+ const userId = fs2.readFileSync(this._userIdPath, "utf-8").trim();
1785
+ return userId;
1786
+ } catch (e) {
1787
+ try {
1788
+ return `session-${generateUUID()}`;
1789
+ } catch (uuidError) {
1790
+ return `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
1791
+ }
1759
1792
  }
1760
- return fs2.readFileSync(this._userIdPath, "utf-8").trim();
1761
1793
  }
1762
1794
  /**
1763
1795
  * Get or create user ID from localStorage (Browser)
@@ -1766,14 +1798,22 @@ var Telemetry = class _Telemetry {
1766
1798
  try {
1767
1799
  let userId = localStorage.getItem(USER_ID_STORAGE_KEY);
1768
1800
  if (!userId) {
1769
- userId = generateUUID();
1801
+ try {
1802
+ userId = generateUUID();
1803
+ } catch (uuidError) {
1804
+ userId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
1805
+ }
1770
1806
  localStorage.setItem(USER_ID_STORAGE_KEY, userId);
1771
- logger.debug(`Created new browser user ID`);
1772
1807
  }
1773
1808
  return userId;
1774
1809
  } catch (e) {
1775
- logger.debug(`localStorage access failed: ${e}`);
1776
- return `session-${generateUUID()}`;
1810
+ let sessionId;
1811
+ try {
1812
+ sessionId = `session-${generateUUID()}`;
1813
+ } catch (uuidError) {
1814
+ sessionId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
1815
+ }
1816
+ return sessionId;
1777
1817
  }
1778
1818
  }
1779
1819
  _getCacheHome(os, path2) {
@@ -1802,6 +1842,7 @@ var Telemetry = class _Telemetry {
1802
1842
  if (!this._posthogNodeClient && !this._posthogBrowserClient && !this._scarfClient) {
1803
1843
  return;
1804
1844
  }
1845
+ const currentUserId = this.userId;
1805
1846
  const properties = { ...event.properties };
1806
1847
  properties.mcp_use_version = getPackageVersion();
1807
1848
  properties.language = "typescript";
@@ -1809,9 +1850,8 @@ var Telemetry = class _Telemetry {
1809
1850
  properties.runtime = this._runtimeEnvironment;
1810
1851
  if (this._posthogNodeClient) {
1811
1852
  try {
1812
- logger.debug(`CAPTURE: PostHog Node Event ${event.name}`);
1813
1853
  this._posthogNodeClient.capture({
1814
- distinctId: this.userId,
1854
+ distinctId: currentUserId,
1815
1855
  event: event.name,
1816
1856
  properties
1817
1857
  });
@@ -1821,10 +1861,9 @@ var Telemetry = class _Telemetry {
1821
1861
  }
1822
1862
  if (this._posthogBrowserClient) {
1823
1863
  try {
1824
- logger.debug(`CAPTURE: PostHog Browser Event ${event.name}`);
1825
1864
  this._posthogBrowserClient.capture(event.name, {
1826
1865
  ...properties,
1827
- distinct_id: this.userId
1866
+ distinct_id: currentUserId
1828
1867
  });
1829
1868
  } catch (e) {
1830
1869
  logger.debug(
@@ -1836,7 +1875,7 @@ var Telemetry = class _Telemetry {
1836
1875
  try {
1837
1876
  const scarfProperties = {
1838
1877
  ...properties,
1839
- user_id: this.userId,
1878
+ user_id: currentUserId,
1840
1879
  event: event.name
1841
1880
  };
1842
1881
  await this._scarfClient.logEvent(scarfProperties);
@@ -5082,6 +5121,7 @@ var HttpConnector = class extends BaseConnector {
5082
5121
  sseReadTimeout;
5083
5122
  clientInfo;
5084
5123
  preferSse;
5124
+ disableSseFallback;
5085
5125
  transportType = null;
5086
5126
  streamableTransport = null;
5087
5127
  constructor(baseUrl, opts = {}) {
@@ -5098,6 +5138,7 @@ var HttpConnector = class extends BaseConnector {
5098
5138
  version: "1.0.0"
5099
5139
  };
5100
5140
  this.preferSse = opts.preferSse ?? false;
5141
+ this.disableSseFallback = opts.disableSseFallback ?? false;
5101
5142
  }
5102
5143
  /** Establish connection to the MCP implementation via HTTP (streamable or SSE). */
5103
5144
  async connect() {
@@ -5154,6 +5195,13 @@ var HttpConnector = class extends BaseConnector {
5154
5195
  authError.code = 401;
5155
5196
  throw authError;
5156
5197
  }
5198
+ if (this.disableSseFallback) {
5199
+ logger.info("SSE fallback disabled - failing connection");
5200
+ await this.cleanupResources();
5201
+ throw new Error(
5202
+ `Streamable HTTP connection failed: ${fallbackReason}. SSE fallback is disabled.`
5203
+ );
5204
+ }
5157
5205
  logger.info("\u{1F504} Falling back to SSE transport...");
5158
5206
  try {
5159
5207
  await this.connectWithSse(baseUrl);
@@ -5520,6 +5568,8 @@ function createConnectorFromConfig(serverConfig, connectorOptions) {
5520
5568
  authToken: serverConfig.auth_token || serverConfig.authToken,
5521
5569
  // Only force SSE if explicitly requested
5522
5570
  preferSse: serverConfig.preferSse || transport === "sse",
5571
+ // Disable SSE fallback if explicitly disabled in config
5572
+ disableSseFallback: serverConfig.disableSseFallback,
5523
5573
  ...connectorOptions
5524
5574
  });
5525
5575
  }
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  BaseAgent,
3
3
  PROMPTS
4
- } from "../../chunk-76F72Y73.js";
4
+ } from "../../chunk-DKK3OEIY.js";
5
5
  import {
6
6
  MCPAgent,
7
7
  RemoteAgent
8
- } from "../../chunk-GVHS2DDJ.js";
8
+ } from "../../chunk-6TCXBLDE.js";
9
9
  import "../../chunk-JRGQRPTN.js";
10
- import "../../chunk-FMK46JYP.js";
10
+ import "../../chunk-I3NZCYBR.js";
11
11
  import "../../chunk-MFSO5PUW.js";
12
- import "../../chunk-MGYJYTTX.js";
13
- import "../../chunk-2FOTPDUJ.js";
12
+ import "../../chunk-M6HG2X4Q.js";
13
+ import "../../chunk-MIY5EBAT.js";
14
14
  import "../../chunk-FRUZDWXH.js";
15
15
  import "../../chunk-3GQAWCBQ.js";
16
16
  export {
@@ -1651,7 +1651,7 @@ __name(generateUUID, "generateUUID");
1651
1651
  init_logging();
1652
1652
 
1653
1653
  // src/version.ts
1654
- var VERSION = "1.11.0-canary.16";
1654
+ var VERSION = "1.11.0-canary.18";
1655
1655
  function getPackageVersion() {
1656
1656
  return VERSION;
1657
1657
  }
@@ -1821,12 +1821,26 @@ var Telemetry = class _Telemetry {
1821
1821
  "Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."
1822
1822
  );
1823
1823
  this._posthogLoading = this._initPostHog();
1824
- try {
1825
- this._scarfClient = new ScarfEventLogger(this.SCARF_GATEWAY_URL, 3e3);
1826
- } catch (e) {
1827
- logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
1824
+ if (this._runtimeEnvironment !== "browser") {
1825
+ try {
1826
+ this._scarfClient = new ScarfEventLogger(
1827
+ this.SCARF_GATEWAY_URL,
1828
+ 3e3
1829
+ );
1830
+ } catch (e) {
1831
+ logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
1832
+ this._scarfClient = null;
1833
+ }
1834
+ } else {
1828
1835
  this._scarfClient = null;
1829
1836
  }
1837
+ if (this._storageCapability === "filesystem" && this._scarfClient) {
1838
+ setTimeout(() => {
1839
+ this.trackPackageDownload({ triggered_by: "initialization" }).catch(
1840
+ (e) => logger.debug(`Failed to track package download: ${e}`)
1841
+ );
1842
+ }, 0);
1843
+ }
1830
1844
  }
1831
1845
  }
1832
1846
  _checkTelemetryDisabled() {
@@ -1951,47 +1965,65 @@ var Telemetry = class _Telemetry {
1951
1965
  break;
1952
1966
  case "session-only":
1953
1967
  default:
1954
- this._currUserId = `session-${generateUUID()}`;
1955
- logger.debug(
1956
- `Using session-based user ID (${this._runtimeEnvironment} environment)`
1957
- );
1968
+ try {
1969
+ this._currUserId = `session-${generateUUID()}`;
1970
+ } catch (uuidError) {
1971
+ this._currUserId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
1972
+ }
1958
1973
  break;
1959
1974
  }
1960
- if (this._storageCapability === "filesystem" && this._currUserId) {
1961
- this._trackPackageDownloadInternal(this._currUserId, {
1962
- triggered_by: "user_id_property"
1963
- }).catch((e) => logger.debug(`Failed to track package download: ${e}`));
1964
- }
1965
1975
  } catch (e) {
1966
- logger.debug(`Failed to get/create user ID: ${e}`);
1967
1976
  this._currUserId = this.UNKNOWN_USER_ID;
1968
1977
  }
1969
1978
  return this._currUserId;
1970
1979
  }
1971
1980
  /**
1972
1981
  * Get or create user ID from filesystem (Node.js/Bun)
1982
+ * Falls back to session ID if filesystem operations fail
1973
1983
  */
1974
1984
  _getUserIdFromFilesystem() {
1975
- const fs2 = require("fs");
1976
- const os = require("os");
1977
- const path2 = require("path");
1978
- if (!this._userIdPath) {
1979
- this._userIdPath = path2.join(
1980
- this._getCacheHome(os, path2),
1981
- "mcp_use_3",
1982
- "telemetry_user_id"
1983
- );
1984
- }
1985
- const isFirstTime = !fs2.existsSync(this._userIdPath);
1986
- if (isFirstTime) {
1987
- logger.debug(`Creating user ID path: ${this._userIdPath}`);
1988
- fs2.mkdirSync(path2.dirname(this._userIdPath), { recursive: true });
1989
- const newUserId = generateUUID();
1990
- fs2.writeFileSync(this._userIdPath, newUserId);
1991
- logger.debug(`User ID path created: ${this._userIdPath}`);
1992
- return newUserId;
1985
+ try {
1986
+ let fs2, os, path2;
1987
+ try {
1988
+ fs2 = require("fs");
1989
+ os = require("os");
1990
+ path2 = require("path");
1991
+ } catch (requireError) {
1992
+ try {
1993
+ const sessionId = `session-${generateUUID()}`;
1994
+ return sessionId;
1995
+ } catch (uuidError) {
1996
+ return `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
1997
+ }
1998
+ }
1999
+ if (!this._userIdPath) {
2000
+ this._userIdPath = path2.join(
2001
+ this._getCacheHome(os, path2),
2002
+ "mcp_use_3",
2003
+ "telemetry_user_id"
2004
+ );
2005
+ }
2006
+ const isFirstTime = !fs2.existsSync(this._userIdPath);
2007
+ if (isFirstTime) {
2008
+ fs2.mkdirSync(path2.dirname(this._userIdPath), { recursive: true });
2009
+ let newUserId;
2010
+ try {
2011
+ newUserId = generateUUID();
2012
+ } catch (uuidError) {
2013
+ newUserId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
2014
+ }
2015
+ fs2.writeFileSync(this._userIdPath, newUserId);
2016
+ return newUserId;
2017
+ }
2018
+ const userId = fs2.readFileSync(this._userIdPath, "utf-8").trim();
2019
+ return userId;
2020
+ } catch (e) {
2021
+ try {
2022
+ return `session-${generateUUID()}`;
2023
+ } catch (uuidError) {
2024
+ return `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
2025
+ }
1993
2026
  }
1994
- return fs2.readFileSync(this._userIdPath, "utf-8").trim();
1995
2027
  }
1996
2028
  /**
1997
2029
  * Get or create user ID from localStorage (Browser)
@@ -2000,14 +2032,22 @@ var Telemetry = class _Telemetry {
2000
2032
  try {
2001
2033
  let userId = localStorage.getItem(USER_ID_STORAGE_KEY);
2002
2034
  if (!userId) {
2003
- userId = generateUUID();
2035
+ try {
2036
+ userId = generateUUID();
2037
+ } catch (uuidError) {
2038
+ userId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
2039
+ }
2004
2040
  localStorage.setItem(USER_ID_STORAGE_KEY, userId);
2005
- logger.debug(`Created new browser user ID`);
2006
2041
  }
2007
2042
  return userId;
2008
2043
  } catch (e) {
2009
- logger.debug(`localStorage access failed: ${e}`);
2010
- return `session-${generateUUID()}`;
2044
+ let sessionId;
2045
+ try {
2046
+ sessionId = `session-${generateUUID()}`;
2047
+ } catch (uuidError) {
2048
+ sessionId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
2049
+ }
2050
+ return sessionId;
2011
2051
  }
2012
2052
  }
2013
2053
  _getCacheHome(os, path2) {
@@ -2036,6 +2076,7 @@ var Telemetry = class _Telemetry {
2036
2076
  if (!this._posthogNodeClient && !this._posthogBrowserClient && !this._scarfClient) {
2037
2077
  return;
2038
2078
  }
2079
+ const currentUserId = this.userId;
2039
2080
  const properties = { ...event.properties };
2040
2081
  properties.mcp_use_version = getPackageVersion();
2041
2082
  properties.language = "typescript";
@@ -2043,9 +2084,8 @@ var Telemetry = class _Telemetry {
2043
2084
  properties.runtime = this._runtimeEnvironment;
2044
2085
  if (this._posthogNodeClient) {
2045
2086
  try {
2046
- logger.debug(`CAPTURE: PostHog Node Event ${event.name}`);
2047
2087
  this._posthogNodeClient.capture({
2048
- distinctId: this.userId,
2088
+ distinctId: currentUserId,
2049
2089
  event: event.name,
2050
2090
  properties
2051
2091
  });
@@ -2055,10 +2095,9 @@ var Telemetry = class _Telemetry {
2055
2095
  }
2056
2096
  if (this._posthogBrowserClient) {
2057
2097
  try {
2058
- logger.debug(`CAPTURE: PostHog Browser Event ${event.name}`);
2059
2098
  this._posthogBrowserClient.capture(event.name, {
2060
2099
  ...properties,
2061
- distinct_id: this.userId
2100
+ distinct_id: currentUserId
2062
2101
  });
2063
2102
  } catch (e) {
2064
2103
  logger.debug(
@@ -2070,7 +2109,7 @@ var Telemetry = class _Telemetry {
2070
2109
  try {
2071
2110
  const scarfProperties = {
2072
2111
  ...properties,
2073
- user_id: this.userId,
2112
+ user_id: currentUserId,
2074
2113
  event: event.name
2075
2114
  };
2076
2115
  await this._scarfClient.logEvent(scarfProperties);
@@ -2808,6 +2847,7 @@ var HttpConnector = class extends BaseConnector {
2808
2847
  sseReadTimeout;
2809
2848
  clientInfo;
2810
2849
  preferSse;
2850
+ disableSseFallback;
2811
2851
  transportType = null;
2812
2852
  streamableTransport = null;
2813
2853
  constructor(baseUrl, opts = {}) {
@@ -2824,6 +2864,7 @@ var HttpConnector = class extends BaseConnector {
2824
2864
  version: "1.0.0"
2825
2865
  };
2826
2866
  this.preferSse = opts.preferSse ?? false;
2867
+ this.disableSseFallback = opts.disableSseFallback ?? false;
2827
2868
  }
2828
2869
  /** Establish connection to the MCP implementation via HTTP (streamable or SSE). */
2829
2870
  async connect() {
@@ -2880,6 +2921,13 @@ var HttpConnector = class extends BaseConnector {
2880
2921
  authError.code = 401;
2881
2922
  throw authError;
2882
2923
  }
2924
+ if (this.disableSseFallback) {
2925
+ logger.info("SSE fallback disabled - failing connection");
2926
+ await this.cleanupResources();
2927
+ throw new Error(
2928
+ `Streamable HTTP connection failed: ${fallbackReason}. SSE fallback is disabled.`
2929
+ );
2930
+ }
2883
2931
  logger.info("\u{1F504} Falling back to SSE transport...");
2884
2932
  try {
2885
2933
  await this.connectWithSse(baseUrl);
@@ -3527,7 +3575,9 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
3527
3575
  wrapTransport,
3528
3576
  clientOptions,
3529
3577
  samplingCallback,
3530
- elicitationCallback
3578
+ elicitationCallback,
3579
+ disableSseFallback,
3580
+ preferSse
3531
3581
  } = serverConfig;
3532
3582
  if (!url) {
3533
3583
  throw new Error("Server URL is required");
@@ -3543,8 +3593,12 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
3543
3593
  // ← Pass client options (capabilities, etc.) to connector
3544
3594
  samplingCallback,
3545
3595
  // ← Pass sampling callback to connector
3546
- elicitationCallback
3596
+ elicitationCallback,
3547
3597
  // ← Pass elicitation callback to connector
3598
+ disableSseFallback,
3599
+ // ← Disable automatic SSE fallback
3600
+ preferSse
3601
+ // ← Use SSE transport directly
3548
3602
  };
3549
3603
  if (clientOptions) {
3550
3604
  console.log(
@@ -5526,6 +5580,8 @@ function createConnectorFromConfig(serverConfig, connectorOptions) {
5526
5580
  authToken: serverConfig.auth_token || serverConfig.authToken,
5527
5581
  // Only force SSE if explicitly requested
5528
5582
  preferSse: serverConfig.preferSse || transport === "sse",
5583
+ // Disable SSE fallback if explicitly disabled in config
5584
+ disableSseFallback: serverConfig.disableSseFallback,
5529
5585
  ...connectorOptions
5530
5586
  });
5531
5587
  }
@@ -3,6 +3,7 @@ import {
3
3
  streamEventsToAISDK,
4
4
  streamEventsToAISDKWithTools
5
5
  } from "../chunk-LGDFGYRL.js";
6
+ import "../chunk-GXNAXUDI.js";
6
7
  import {
7
8
  MCPAgent,
8
9
  ObservabilityManager,
@@ -11,36 +12,35 @@ import {
11
12
  getSupportedProviders,
12
13
  isValidLLMString,
13
14
  parseLLMString
14
- } from "../chunk-GVHS2DDJ.js";
15
+ } from "../chunk-6TCXBLDE.js";
15
16
  import "../chunk-JRGQRPTN.js";
16
- import "../chunk-FMK46JYP.js";
17
- import "../chunk-GXNAXUDI.js";
17
+ import "../chunk-I3NZCYBR.js";
18
18
  import {
19
19
  BaseAdapter
20
20
  } from "../chunk-MFSO5PUW.js";
21
21
  import {
22
22
  BrowserMCPClient
23
- } from "../chunk-6AB7U4KA.js";
23
+ } from "../chunk-OD724W55.js";
24
24
  import {
25
25
  BaseConnector,
26
26
  HttpConnector,
27
27
  MCPSession
28
- } from "../chunk-MGYJYTTX.js";
28
+ } from "../chunk-M6HG2X4Q.js";
29
29
  import {
30
30
  Tel,
31
31
  Telemetry,
32
32
  VERSION,
33
33
  getPackageVersion,
34
34
  setTelemetrySource
35
- } from "../chunk-2FOTPDUJ.js";
36
- import {
37
- BrowserOAuthClientProvider,
38
- onMcpAuthorization
39
- } from "../chunk-J75I2C26.js";
35
+ } from "../chunk-MIY5EBAT.js";
40
36
  import {
41
37
  Logger,
42
38
  logger
43
39
  } from "../chunk-FRUZDWXH.js";
40
+ import {
41
+ BrowserOAuthClientProvider,
42
+ onMcpAuthorization
43
+ } from "../chunk-J75I2C26.js";
44
44
  import "../chunk-3GQAWCBQ.js";
45
45
  export {
46
46
  BaseAdapter,
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/client/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAK3D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,aAAa;IACjD;;;OAGG;WACW,iBAAiB,IAAI,MAAM;gBAI7B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAKxC,OAAO,CAAC,gBAAgB;WAkBV,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,gBAAgB;IAIlE;;;OAGG;IACH,SAAS,CAAC,yBAAyB,CACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAChC,aAAa;CA0CjB"}
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/client/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAK3D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,aAAa;IACjD;;;OAGG;WACW,iBAAiB,IAAI,MAAM;gBAI7B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAKxC,OAAO,CAAC,gBAAgB;WAkBV,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,gBAAgB;IAIlE;;;OAGG;IACH,SAAS,CAAC,yBAAyB,CACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAChC,aAAa;CA8CjB"}