@mcp-use/client 2.4.6-canary.0 → 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/code-mode/executor-vm.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 +57 -12
- 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];
|
|
@@ -5256,6 +5267,44 @@ function isVMAvailable() {
|
|
|
5256
5267
|
tryLoadVM();
|
|
5257
5268
|
return vm !== null;
|
|
5258
5269
|
}
|
|
5270
|
+
function formatLogArgument(arg) {
|
|
5271
|
+
try {
|
|
5272
|
+
if (typeof arg !== "object" || arg === null) return String(arg);
|
|
5273
|
+
if (isErrorObject(arg)) return formatError(arg);
|
|
5274
|
+
return JSON.stringify(arg, jsonLogReplacer(), 2);
|
|
5275
|
+
} catch {
|
|
5276
|
+
try {
|
|
5277
|
+
return String(arg);
|
|
5278
|
+
} catch {
|
|
5279
|
+
return "[unserializable value]";
|
|
5280
|
+
}
|
|
5281
|
+
}
|
|
5282
|
+
}
|
|
5283
|
+
function isErrorObject(value) {
|
|
5284
|
+
return Object.prototype.toString.call(value) === "[object Error]";
|
|
5285
|
+
}
|
|
5286
|
+
var MAX_ERROR_CAUSE_DEPTH = 5;
|
|
5287
|
+
function formatError(error, depth = 0) {
|
|
5288
|
+
const text = String(error);
|
|
5289
|
+
const cause = error.cause;
|
|
5290
|
+
if (cause === void 0 || depth >= MAX_ERROR_CAUSE_DEPTH) return text;
|
|
5291
|
+
const causeText = isErrorObject(cause) ? formatError(cause, depth + 1) : formatLogArgument(cause);
|
|
5292
|
+
return `${text} (cause: ${causeText})`;
|
|
5293
|
+
}
|
|
5294
|
+
function jsonLogReplacer() {
|
|
5295
|
+
const ancestors = [];
|
|
5296
|
+
return function(_key, value) {
|
|
5297
|
+
if (typeof value === "bigint") return `${value}n`;
|
|
5298
|
+
if (typeof value !== "object" || value === null) return value;
|
|
5299
|
+
if (isErrorObject(value)) return formatError(value);
|
|
5300
|
+
while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this) {
|
|
5301
|
+
ancestors.pop();
|
|
5302
|
+
}
|
|
5303
|
+
if (ancestors.includes(value)) return "[Circular]";
|
|
5304
|
+
ancestors.push(value);
|
|
5305
|
+
return value;
|
|
5306
|
+
};
|
|
5307
|
+
}
|
|
5259
5308
|
var VMCodeExecutor = class extends BaseCodeExecutor {
|
|
5260
5309
|
defaultTimeout;
|
|
5261
5310
|
memoryLimitMb;
|
|
@@ -5336,11 +5385,7 @@ var VMCodeExecutor = class extends BaseCodeExecutor {
|
|
|
5336
5385
|
*/
|
|
5337
5386
|
async _buildContext(logs) {
|
|
5338
5387
|
const logHandler = (...args) => {
|
|
5339
|
-
logs.push(
|
|
5340
|
-
args.map(
|
|
5341
|
-
(arg) => typeof arg === "object" ? JSON.stringify(arg, null, 2) : String(arg)
|
|
5342
|
-
).join(" ")
|
|
5343
|
-
);
|
|
5388
|
+
logs.push(args.map(formatLogArgument).join(" "));
|
|
5344
5389
|
};
|
|
5345
5390
|
const sandbox = {
|
|
5346
5391
|
console: {
|