@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/.tsbuildinfo +1 -1
- package/dist/auth/flow.d.ts +13 -0
- package/dist/auth/flow.d.ts.map +1 -1
- package/dist/core/base.d.ts.map +1 -1
- package/dist/core/config.d.ts +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/index-browser.js +20 -9
- package/dist/index-browser.js.map +1 -1
- package/dist/index.js +20 -9
- package/dist/index.js.map +1 -1
- package/dist/react/index.js +22 -17
- package/dist/react/index.js.map +1 -1
- package/dist/react/useMcp.d.ts.map +1 -1
- package/dist/telemetry/telemetry-browser.d.ts +1 -1
- package/dist/telemetry/telemetry.d.ts.map +1 -1
- package/dist/transport/http.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -468,6 +468,9 @@ import {
|
|
|
468
468
|
UnauthorizedError
|
|
469
469
|
} from "@modelcontextprotocol/client";
|
|
470
470
|
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 6e4;
|
|
471
|
+
function scopeOAuthFetch(provider, baseFetch) {
|
|
472
|
+
return provider?.getProxyFetch?.(baseFetch) ?? baseFetch;
|
|
473
|
+
}
|
|
471
474
|
function isUnauthorized(err, depth = 0) {
|
|
472
475
|
if (!err || depth > 5) return false;
|
|
473
476
|
if (err instanceof UnauthorizedError) return true;
|
|
@@ -1560,13 +1563,16 @@ var HttpConnector = class extends BaseConnector {
|
|
|
1560
1563
|
this.headers.Authorization = `Bearer ${opts.authToken}`;
|
|
1561
1564
|
}
|
|
1562
1565
|
this.timeout = opts.timeout ?? 1e4;
|
|
1563
|
-
const
|
|
1566
|
+
const oauthFetch = scopeOAuthFetch(
|
|
1567
|
+
isOAuthClientProvider(opts.authProvider) ? opts.authProvider : void 0,
|
|
1568
|
+
opts.fetch
|
|
1569
|
+
);
|
|
1564
1570
|
this.customFetch = this.gatewayUrl ? createMcpProxyFetch(
|
|
1565
1571
|
originalUrl,
|
|
1566
1572
|
this.gatewayUrl,
|
|
1567
|
-
|
|
1573
|
+
oauthFetch ?? globalThis.fetch.bind(globalThis),
|
|
1568
1574
|
this.serverId
|
|
1569
|
-
) :
|
|
1575
|
+
) : oauthFetch;
|
|
1570
1576
|
this.clientInfo = opts.clientInfo ?? {
|
|
1571
1577
|
name: "http-connector",
|
|
1572
1578
|
version: "1.0.0"
|
|
@@ -1979,7 +1985,7 @@ var HttpConnector = class extends BaseConnector {
|
|
|
1979
1985
|
};
|
|
1980
1986
|
|
|
1981
1987
|
// src/utils/version.ts
|
|
1982
|
-
var VERSION = "2.4.6-canary.
|
|
1988
|
+
var VERSION = "2.4.6-canary.3";
|
|
1983
1989
|
function getPackageVersion() {
|
|
1984
1990
|
return VERSION;
|
|
1985
1991
|
}
|
|
@@ -3282,8 +3288,11 @@ var USER_ID_STORAGE_KEY = "mcp_use_user_id";
|
|
|
3282
3288
|
var PROJECT_API_KEY = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";
|
|
3283
3289
|
var HOST = "https://eu.i.posthog.com";
|
|
3284
3290
|
var configuredStorage = null;
|
|
3291
|
+
function isBrowser() {
|
|
3292
|
+
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
3293
|
+
}
|
|
3285
3294
|
function isLocalStorageFunctional() {
|
|
3286
|
-
return typeof localStorage !== "undefined" && typeof localStorage.getItem === "function" && typeof localStorage.setItem === "function" && typeof localStorage.removeItem === "function";
|
|
3295
|
+
return isBrowser() && typeof localStorage !== "undefined" && typeof localStorage.getItem === "function" && typeof localStorage.setItem === "function" && typeof localStorage.removeItem === "function";
|
|
3287
3296
|
}
|
|
3288
3297
|
function createLocalStorageBackend() {
|
|
3289
3298
|
if (!isLocalStorageFunctional()) return null;
|
|
@@ -3323,7 +3332,7 @@ function detectRuntimeEnvironment() {
|
|
|
3323
3332
|
if (typeof globalThis.EdgeRuntime !== "undefined") {
|
|
3324
3333
|
return "edge";
|
|
3325
3334
|
}
|
|
3326
|
-
if (
|
|
3335
|
+
if (isBrowser()) {
|
|
3327
3336
|
return "browser";
|
|
3328
3337
|
}
|
|
3329
3338
|
if (typeof process !== "undefined" && typeof process.versions?.node !== "undefined") {
|
|
@@ -4361,7 +4370,9 @@ var BaseMCPClient = class {
|
|
|
4361
4370
|
logger.info(
|
|
4362
4371
|
`[MCPClient] Unauthorized connecting to '${serverName}'; completing OAuth\u2026`
|
|
4363
4372
|
);
|
|
4364
|
-
await completeOAuthFlow(oauthProvider, httpConfig.url
|
|
4373
|
+
await completeOAuthFlow(oauthProvider, httpConfig.url, {
|
|
4374
|
+
fetchFn: scopeOAuthFetch(oauthProvider, httpConfig.fetch)
|
|
4375
|
+
});
|
|
4365
4376
|
session = await openSession();
|
|
4366
4377
|
}
|
|
4367
4378
|
const previous = this.sessions[serverName];
|
|
@@ -4710,7 +4721,7 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
|
4710
4721
|
);
|
|
4711
4722
|
const connectorOptions = {
|
|
4712
4723
|
headers,
|
|
4713
|
-
fetch: configuredFetch
|
|
4724
|
+
fetch: configuredFetch,
|
|
4714
4725
|
authToken,
|
|
4715
4726
|
authProvider,
|
|
4716
4727
|
detectMixedAuth,
|
|
@@ -5844,15 +5855,9 @@ function useMcp(options) {
|
|
|
5844
5855
|
// Use original URL, not transformed proxy URL
|
|
5845
5856
|
timeout,
|
|
5846
5857
|
clientInfo: mergedClientInfo,
|
|
5847
|
-
//
|
|
5848
|
-
//
|
|
5849
|
-
|
|
5850
|
-
// for OAuth metadata, and optionally routes OAuth through the BFF.
|
|
5851
|
-
// It never mutates the global fetch.
|
|
5852
|
-
...(() => {
|
|
5853
|
-
const scopedFetch = authProviderRef.current?.getProxyFetch?.(customFetch) ?? customFetch;
|
|
5854
|
-
return scopedFetch ? { fetch: scopedFetch } : {};
|
|
5855
|
-
})(),
|
|
5858
|
+
// The connector wraps this with the provider's OAuth-proxy fetch
|
|
5859
|
+
// (`getProxyFetch`), so pass the caller's fetch unwrapped.
|
|
5860
|
+
...customFetch ? { fetch: customFetch } : {},
|
|
5856
5861
|
// Pass clientOptions for custom capabilities (e.g., MCP Apps extension)
|
|
5857
5862
|
...effectiveClientOptions && {
|
|
5858
5863
|
clientOptions: effectiveClientOptions
|