@mcp-use/client 2.4.6-canary.1 → 2.4.6-canary.2
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/index-browser.js +19 -8
- package/dist/index-browser.js.map +1 -1
- package/dist/index.js +18 -7
- 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/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.
|
|
1665
|
+
var VERSION = "2.4.6-canary.2";
|
|
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 (
|
|
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
|
|
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
|
-
|
|
3220
|
+
oauthFetch ?? globalThis.fetch.bind(globalThis),
|
|
3212
3221
|
this.serverId
|
|
3213
|
-
) :
|
|
3222
|
+
) : oauthFetch;
|
|
3214
3223
|
this.clientInfo = opts.clientInfo ?? {
|
|
3215
3224
|
name: "http-connector",
|
|
3216
3225
|
version: "1.0.0"
|
|
@@ -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];
|