@mcp-use/client 2.1.2 → 2.1.3-canary.1
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/node.d.ts +2 -0
- package/dist/auth/node.d.ts.map +1 -1
- package/dist/auth/storage-file.d.ts.map +1 -1
- package/dist/index-browser.js +3 -29
- package/dist/index-browser.js.map +1 -1
- package/dist/index.js +19 -35
- package/dist/index.js.map +1 -1
- package/dist/react/index.js +3 -29
- package/dist/react/index.js.map +1 -1
- package/dist/transport/http.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1525,7 +1525,7 @@ init_connector_telemetry();
|
|
|
1525
1525
|
init_logging();
|
|
1526
1526
|
|
|
1527
1527
|
// src/utils/version.ts
|
|
1528
|
-
var VERSION = "2.1.
|
|
1528
|
+
var VERSION = "2.1.3-canary.1";
|
|
1529
1529
|
function getPackageVersion() {
|
|
1530
1530
|
return VERSION;
|
|
1531
1531
|
}
|
|
@@ -2115,7 +2115,6 @@ var FileKVStore = class {
|
|
|
2115
2115
|
constructor(serverUrlHash, baseDir) {
|
|
2116
2116
|
const root = baseDir ?? join(homedir(), ".mcp-use", "oauth");
|
|
2117
2117
|
this.dir = join(root, serverUrlHash);
|
|
2118
|
-
this.ensureDir();
|
|
2119
2118
|
}
|
|
2120
2119
|
ensureDir() {
|
|
2121
2120
|
if (!existsSync(this.dir)) {
|
|
@@ -2570,6 +2569,8 @@ var NodeOAuthClientProvider = class _NodeOAuthClientProvider {
|
|
|
2570
2569
|
kv;
|
|
2571
2570
|
authTimeoutMs;
|
|
2572
2571
|
openBrowserOverride;
|
|
2572
|
+
/** Whether the selected callback port still needs to be written to storage. */
|
|
2573
|
+
shouldPersistSelectedPort;
|
|
2573
2574
|
server = null;
|
|
2574
2575
|
/** Provider authorization URL, exposed only through the local redirect route. */
|
|
2575
2576
|
authorizationUrl = null;
|
|
@@ -2578,13 +2579,14 @@ var NodeOAuthClientProvider = class _NodeOAuthClientProvider {
|
|
|
2578
2579
|
/** Latest deferred (settled or in-flight) for the loopback response. */
|
|
2579
2580
|
lastFlow = null;
|
|
2580
2581
|
pendingTimer = null;
|
|
2581
|
-
constructor(serverUrl, port, session, kv, options) {
|
|
2582
|
+
constructor(serverUrl, port, session, kv, options, shouldPersistSelectedPort) {
|
|
2582
2583
|
this.serverUrl = serverUrl;
|
|
2583
2584
|
this.port = port;
|
|
2584
2585
|
this.session = session;
|
|
2585
2586
|
this.kv = kv;
|
|
2586
2587
|
this.authTimeoutMs = options.authTimeoutMs ?? DEFAULT_AUTH_TIMEOUT_MS2;
|
|
2587
2588
|
this.openBrowserOverride = options.openBrowser;
|
|
2589
|
+
this.shouldPersistSelectedPort = shouldPersistSelectedPort;
|
|
2588
2590
|
}
|
|
2589
2591
|
/**
|
|
2590
2592
|
* Creates a Node OAuth provider and reserves a localhost callback port.
|
|
@@ -2613,16 +2615,20 @@ var NodeOAuthClientProvider = class _NodeOAuthClientProvider {
|
|
|
2613
2615
|
probe.listen(0, "127.0.0.1");
|
|
2614
2616
|
});
|
|
2615
2617
|
}
|
|
2616
|
-
if (port !== persistedPort) {
|
|
2617
|
-
await kv.set("port", String(port));
|
|
2618
|
-
}
|
|
2619
2618
|
const callbackUrl = `http://127.0.0.1:${port}/callback`;
|
|
2620
2619
|
const session = new OAuthSessionStore(
|
|
2621
2620
|
serverUrl,
|
|
2622
2621
|
{ ...options, callbackUrl },
|
|
2623
2622
|
kv
|
|
2624
2623
|
);
|
|
2625
|
-
return new _NodeOAuthClientProvider(
|
|
2624
|
+
return new _NodeOAuthClientProvider(
|
|
2625
|
+
serverUrl,
|
|
2626
|
+
port,
|
|
2627
|
+
session,
|
|
2628
|
+
kv,
|
|
2629
|
+
options,
|
|
2630
|
+
port !== persistedPort
|
|
2631
|
+
);
|
|
2626
2632
|
}
|
|
2627
2633
|
// --- Identity passthroughs (parallel to BrowserOAuthClientProvider) ---
|
|
2628
2634
|
/** Prefix used for persisted OAuth session keys. */
|
|
@@ -2737,6 +2743,10 @@ var NodeOAuthClientProvider = class _NodeOAuthClientProvider {
|
|
|
2737
2743
|
"NodeOAuthClientProvider: an authorization is already in progress"
|
|
2738
2744
|
);
|
|
2739
2745
|
}
|
|
2746
|
+
if (this.shouldPersistSelectedPort) {
|
|
2747
|
+
await this.kv.set("port", String(this.port));
|
|
2748
|
+
this.shouldPersistSelectedPort = false;
|
|
2749
|
+
}
|
|
2740
2750
|
const sanitizedUrl = await this.session.storeAuthorizationState(
|
|
2741
2751
|
authorizationUrl,
|
|
2742
2752
|
{ flowType: "redirect" }
|
|
@@ -3349,23 +3359,15 @@ var HttpConnector = class extends BaseConnector {
|
|
|
3349
3359
|
authProviderUrl: this.opts.authProvider && "serverUrl" in this.opts.authProvider && typeof this.opts.authProvider.serverUrl === "string" ? this.opts.authProvider.serverUrl : "none",
|
|
3350
3360
|
headers: this.headers
|
|
3351
3361
|
});
|
|
3352
|
-
let markPushStreamReady;
|
|
3353
|
-
const pushStreamReady = new Promise((resolve) => {
|
|
3354
|
-
markPushStreamReady = resolve;
|
|
3355
|
-
});
|
|
3356
3362
|
const baseFetch = this.customFetch ?? globalThis.fetch.bind(globalThis);
|
|
3357
3363
|
const observedFetch = async (input, init) => {
|
|
3358
3364
|
const response = await baseFetch(input, init);
|
|
3359
|
-
const method = init?.method ?? (input instanceof Request ? input.method : "GET");
|
|
3360
3365
|
const requestHeaders = new Headers(
|
|
3361
3366
|
input instanceof Request ? input.headers : void 0
|
|
3362
3367
|
);
|
|
3363
3368
|
new Headers(init?.headers).forEach((value, key) => {
|
|
3364
3369
|
requestHeaders.set(key, value);
|
|
3365
3370
|
});
|
|
3366
|
-
if (method.toUpperCase() === "GET" && response.ok && response.headers.get("content-type")?.includes("text/event-stream")) {
|
|
3367
|
-
markPushStreamReady?.();
|
|
3368
|
-
}
|
|
3369
3371
|
return requestHeaders.get("mcp-method") === "subscriptions/listen" ? response : this.observeSseProgress(response);
|
|
3370
3372
|
};
|
|
3371
3373
|
const streamableTransport = new StreamableHTTPClientTransport(
|
|
@@ -3404,8 +3406,9 @@ var HttpConnector = class extends BaseConnector {
|
|
|
3404
3406
|
this.setupRootsHandler();
|
|
3405
3407
|
this.setupSamplingHandler();
|
|
3406
3408
|
this.setupElicitationHandler();
|
|
3409
|
+
this.setupNotificationHandler();
|
|
3407
3410
|
logger.debug(
|
|
3408
|
-
"Roots/sampling/elicitation handlers registered before connect"
|
|
3411
|
+
"Roots/sampling/elicitation/notification handlers registered before connect"
|
|
3409
3412
|
);
|
|
3410
3413
|
try {
|
|
3411
3414
|
let connectTimeout;
|
|
@@ -3422,24 +3425,6 @@ var HttpConnector = class extends BaseConnector {
|
|
|
3422
3425
|
]).finally(() => {
|
|
3423
3426
|
if (connectTimeout !== void 0) clearTimeout(connectTimeout);
|
|
3424
3427
|
});
|
|
3425
|
-
if ((this.client.getProtocolEra?.() ?? "legacy") === "legacy" && streamableTransport.sessionId) {
|
|
3426
|
-
let readinessTimeout;
|
|
3427
|
-
const attached = await Promise.race([
|
|
3428
|
-
pushStreamReady.then(() => true),
|
|
3429
|
-
new Promise(
|
|
3430
|
-
(resolve) => readinessTimeout = setTimeout(
|
|
3431
|
-
() => resolve(false),
|
|
3432
|
-
Math.min(this.timeout, 5e3)
|
|
3433
|
-
)
|
|
3434
|
-
)
|
|
3435
|
-
]);
|
|
3436
|
-
if (readinessTimeout) clearTimeout(readinessTimeout);
|
|
3437
|
-
if (!attached) {
|
|
3438
|
-
logger.warn(
|
|
3439
|
-
"Legacy server push stream did not attach before connect completed"
|
|
3440
|
-
);
|
|
3441
|
-
}
|
|
3442
|
-
}
|
|
3443
3428
|
const sessionId2 = streamableTransport.sessionId;
|
|
3444
3429
|
if (sessionId2) {
|
|
3445
3430
|
logger.debug(`Session ID obtained: ${sessionId2}`);
|
|
@@ -3473,7 +3458,6 @@ var HttpConnector = class extends BaseConnector {
|
|
|
3473
3458
|
};
|
|
3474
3459
|
this.connected = true;
|
|
3475
3460
|
this.transportType = "streamable-http";
|
|
3476
|
-
this.setupNotificationHandler();
|
|
3477
3461
|
logger.debug(
|
|
3478
3462
|
`Successfully connected to MCP implementation via streamable HTTP: ${baseUrl}`
|
|
3479
3463
|
);
|