@mcp-use/client 2.4.6-canary.1 → 2.4.6-canary.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/dist/index.js CHANGED
@@ -279,6 +279,9 @@ import {
279
279
  InsufficientScopeError,
280
280
  UnauthorizedError
281
281
  } from "@modelcontextprotocol/client";
282
+ function scopeOAuthFetch(provider, baseFetch) {
283
+ return provider?.getProxyFetch?.(baseFetch) ?? baseFetch;
284
+ }
282
285
  function isUnauthorized(err, depth = 0) {
283
286
  if (!err || depth > 5) return false;
284
287
  if (err instanceof UnauthorizedError) return true;
@@ -1659,7 +1662,7 @@ init_connector_telemetry();
1659
1662
  init_logging();
1660
1663
 
1661
1664
  // src/utils/version.ts
1662
- var VERSION = "2.4.6-canary.1";
1665
+ var VERSION = "2.4.6-canary.3";
1663
1666
  function getPackageVersion() {
1664
1667
  return VERSION;
1665
1668
  }
@@ -1875,8 +1878,11 @@ var configuredStorage = null;
1875
1878
  function configureTelemetryStorage(storage) {
1876
1879
  configuredStorage = storage;
1877
1880
  }
1881
+ function isBrowser() {
1882
+ return typeof window !== "undefined" && typeof document !== "undefined";
1883
+ }
1878
1884
  function isLocalStorageFunctional() {
1879
- return typeof localStorage !== "undefined" && typeof localStorage.getItem === "function" && typeof localStorage.setItem === "function" && typeof localStorage.removeItem === "function";
1885
+ return isBrowser() && typeof localStorage !== "undefined" && typeof localStorage.getItem === "function" && typeof localStorage.setItem === "function" && typeof localStorage.removeItem === "function";
1880
1886
  }
1881
1887
  function createLocalStorageBackend() {
1882
1888
  if (!isLocalStorageFunctional()) return null;
@@ -1916,7 +1922,7 @@ function detectRuntimeEnvironment() {
1916
1922
  if (typeof globalThis.EdgeRuntime !== "undefined") {
1917
1923
  return "edge";
1918
1924
  }
1919
- if (typeof window !== "undefined" && typeof document !== "undefined") {
1925
+ if (isBrowser()) {
1920
1926
  return "browser";
1921
1927
  }
1922
1928
  if (typeof process !== "undefined" && typeof process.versions?.node !== "undefined") {
@@ -3204,13 +3210,16 @@ var HttpConnector = class extends BaseConnector {
3204
3210
  this.headers.Authorization = `Bearer ${opts.authToken}`;
3205
3211
  }
3206
3212
  this.timeout = opts.timeout ?? 1e4;
3207
- const baseFetch = opts.fetch ?? globalThis.fetch.bind(globalThis);
3213
+ const oauthFetch = scopeOAuthFetch(
3214
+ isOAuthClientProvider(opts.authProvider) ? opts.authProvider : void 0,
3215
+ opts.fetch
3216
+ );
3208
3217
  this.customFetch = this.gatewayUrl ? createMcpProxyFetch(
3209
3218
  originalUrl,
3210
3219
  this.gatewayUrl,
3211
- baseFetch,
3220
+ oauthFetch ?? globalThis.fetch.bind(globalThis),
3212
3221
  this.serverId
3213
- ) : opts.fetch;
3222
+ ) : oauthFetch;
3214
3223
  this.clientInfo = opts.clientInfo ?? {
3215
3224
  name: "http-connector",
3216
3225
  version: "1.0.0"
@@ -3689,7 +3698,7 @@ function resolveClientOptions(clientOptions) {
3689
3698
  }
3690
3699
  function createConnectorFromConfig(serverConfig, connectorOptions) {
3691
3700
  const clientInfo = normalizeClientInfo(serverConfig.clientInfo);
3692
- if ("command" in serverConfig && "args" in serverConfig) {
3701
+ if ("command" in serverConfig) {
3693
3702
  throw new Error(
3694
3703
  "Stdio connector is not supported in this environment. Stdio connections require Node.js and are only available in the Node.js MCPClient."
3695
3704
  );
@@ -4509,7 +4518,9 @@ var BaseMCPClient = class {
4509
4518
  logger.info(
4510
4519
  `[MCPClient] Unauthorized connecting to '${serverName}'; completing OAuth\u2026`
4511
4520
  );
4512
- await completeOAuthFlow(oauthProvider, httpConfig.url);
4521
+ await completeOAuthFlow(oauthProvider, httpConfig.url, {
4522
+ fetchFn: scopeOAuthFetch(oauthProvider, httpConfig.fetch)
4523
+ });
4513
4524
  session = await openSession();
4514
4525
  }
4515
4526
  const previous = this.sessions[serverName];
@@ -6080,7 +6091,7 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
6080
6091
  ...serverConfig,
6081
6092
  clientInfo: serverConfig.clientInfo ?? this.config.clientInfo
6082
6093
  };
6083
- if ("command" in merged && "args" in merged) {
6094
+ if ("command" in merged) {
6084
6095
  const { StdioConnector: StdioConnector2 } = await Promise.resolve().then(() => (init_stdio(), stdio_exports));
6085
6096
  const stdioConfig = merged;
6086
6097
  return new StdioConnector2({