@mcp-use/client 2.3.1-canary.3 → 2.3.2-canary.0
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/index-browser.js +9 -104
- package/dist/index-browser.js.map +1 -1
- package/dist/index.js +9 -105
- package/dist/index.js.map +1 -1
- package/dist/react/index.js +9 -104
- package/dist/react/index.js.map +1 -1
- package/dist/transport/base.d.ts +0 -11
- package/dist/transport/base.d.ts.map +1 -1
- package/dist/transport/http.d.ts +0 -5
- package/dist/transport/http.d.ts.map +1 -1
- package/dist/transport/stdio.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -475,7 +475,6 @@ var init_base = __esm({
|
|
|
475
475
|
opts;
|
|
476
476
|
notificationHandlers = [];
|
|
477
477
|
rootsCache = [];
|
|
478
|
-
activeProgressHandlers = /* @__PURE__ */ new Set();
|
|
479
478
|
/**
|
|
480
479
|
* Creates a connector with shared SDK and callback options.
|
|
481
480
|
*
|
|
@@ -512,9 +511,6 @@ var init_base = __esm({
|
|
|
512
511
|
*/
|
|
513
512
|
onNotification(handler) {
|
|
514
513
|
this.notificationHandlers.push(handler);
|
|
515
|
-
if (this.client) {
|
|
516
|
-
this.setupNotificationHandler();
|
|
517
|
-
}
|
|
518
514
|
}
|
|
519
515
|
/** Forward a normalized notification to every registered consumer. */
|
|
520
516
|
async forwardNotification(notification) {
|
|
@@ -567,40 +563,13 @@ var init_base = __esm({
|
|
|
567
563
|
]) {
|
|
568
564
|
const originalHandler = handlersMap.get(method);
|
|
569
565
|
if (originalHandler) {
|
|
570
|
-
handlersMap.set(method, async (notification) => {
|
|
571
|
-
await originalHandler(notification);
|
|
566
|
+
handlersMap.set(method, async (notification, ...args) => {
|
|
567
|
+
await originalHandler(notification, ...args);
|
|
572
568
|
await this.forwardNotification(notification);
|
|
573
569
|
});
|
|
574
570
|
}
|
|
575
571
|
}
|
|
576
572
|
}
|
|
577
|
-
/**
|
|
578
|
-
* Forward v2 MRTR progress whose retry request IDs are not associated with
|
|
579
|
-
* the original call callback by the current SDK beta.
|
|
580
|
-
*
|
|
581
|
-
* ponytail: fallback is enabled only when exactly one progress-aware call is
|
|
582
|
-
* active; remove it when the upstream SDK propagates handlers to MRTR rounds.
|
|
583
|
-
*/
|
|
584
|
-
setupRoundProgressForwarding() {
|
|
585
|
-
if (!this.client) return;
|
|
586
|
-
const sdkClient = this.client;
|
|
587
|
-
const original = sdkClient._onnotification.bind(this.client);
|
|
588
|
-
sdkClient._onnotification = async (message) => {
|
|
589
|
-
if (message && typeof message === "object" && message.method === "notifications/progress") {
|
|
590
|
-
this.forwardRoundProgress(message.params);
|
|
591
|
-
}
|
|
592
|
-
await original?.(message);
|
|
593
|
-
};
|
|
594
|
-
}
|
|
595
|
-
/** Forward progress parsed from a transport stream to the active call. */
|
|
596
|
-
forwardRoundProgress(params) {
|
|
597
|
-
if (this.activeProgressHandlers.size === 1) {
|
|
598
|
-
const [handler] = this.activeProgressHandlers;
|
|
599
|
-
handler?.(
|
|
600
|
-
params
|
|
601
|
-
);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
573
|
/**
|
|
605
574
|
* Auto-refresh tools cache when server sends tools/list_changed notification
|
|
606
575
|
*/
|
|
@@ -953,17 +922,11 @@ var init_base = __esm({
|
|
|
953
922
|
);
|
|
954
923
|
}
|
|
955
924
|
logger.debug(`Calling tool '${name}' with args`, args);
|
|
956
|
-
const
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
);
|
|
962
|
-
logger.debug(`Tool '${name}' returned`, res);
|
|
963
|
-
return res;
|
|
964
|
-
} finally {
|
|
965
|
-
if (progressHandler) this.activeProgressHandlers.delete(progressHandler);
|
|
966
|
-
}
|
|
925
|
+
const res = await this.executeRequest(
|
|
926
|
+
() => this.client.callTool({ name, arguments: args }, enhancedOptions)
|
|
927
|
+
);
|
|
928
|
+
logger.debug(`Tool '${name}' returned`, res);
|
|
929
|
+
return res;
|
|
967
930
|
}
|
|
968
931
|
/**
|
|
969
932
|
* List all available tools from the MCP server.
|
|
@@ -1494,7 +1457,6 @@ var init_stdio = __esm({
|
|
|
1494
1457
|
"Roots/sampling/elicitation handlers registered before connect (stdio)"
|
|
1495
1458
|
);
|
|
1496
1459
|
await this.client.connect(transport);
|
|
1497
|
-
this.setupRoundProgressForwarding();
|
|
1498
1460
|
this.setupNotificationHandler();
|
|
1499
1461
|
logger.debug(
|
|
1500
1462
|
`Successfully connected to MCP implementation: ${this.command}`
|
|
@@ -1597,7 +1559,7 @@ init_connector_telemetry();
|
|
|
1597
1559
|
init_logging();
|
|
1598
1560
|
|
|
1599
1561
|
// src/utils/version.ts
|
|
1600
|
-
var VERSION = "2.3.
|
|
1562
|
+
var VERSION = "2.3.2-canary.0";
|
|
1601
1563
|
function getPackageVersion() {
|
|
1602
1564
|
return VERSION;
|
|
1603
1565
|
}
|
|
@@ -3381,53 +3343,6 @@ var HttpConnector = class extends BaseConnector {
|
|
|
3381
3343
|
throw finalError;
|
|
3382
3344
|
}
|
|
3383
3345
|
}
|
|
3384
|
-
/**
|
|
3385
|
-
* Tee an SSE response so v2 MRTR progress can be correlated even when the
|
|
3386
|
-
* upstream SDK does not carry the original callback to retry request IDs.
|
|
3387
|
-
*/
|
|
3388
|
-
observeSseProgress(response) {
|
|
3389
|
-
if (!response.body || !response.headers.get("content-type")?.includes("text/event-stream")) {
|
|
3390
|
-
return response;
|
|
3391
|
-
}
|
|
3392
|
-
const [body, observed] = response.body.tee();
|
|
3393
|
-
void (async () => {
|
|
3394
|
-
const reader = observed.getReader();
|
|
3395
|
-
const decoder = new TextDecoder();
|
|
3396
|
-
let buffer = "";
|
|
3397
|
-
try {
|
|
3398
|
-
while (true) {
|
|
3399
|
-
const { done, value } = await reader.read();
|
|
3400
|
-
if (done) break;
|
|
3401
|
-
buffer += decoder.decode(value, { stream: true });
|
|
3402
|
-
const events = buffer.split(/\r?\n\r?\n/);
|
|
3403
|
-
buffer = events.pop() ?? "";
|
|
3404
|
-
for (const event of events) {
|
|
3405
|
-
for (const line of event.split(/\r?\n/)) {
|
|
3406
|
-
if (!line.startsWith("data:")) continue;
|
|
3407
|
-
try {
|
|
3408
|
-
const message = JSON.parse(line.slice(5).trim());
|
|
3409
|
-
if (message.method === "notifications/progress") {
|
|
3410
|
-
this.forwardRoundProgress(message.params);
|
|
3411
|
-
}
|
|
3412
|
-
} catch {
|
|
3413
|
-
}
|
|
3414
|
-
}
|
|
3415
|
-
}
|
|
3416
|
-
}
|
|
3417
|
-
} catch (error) {
|
|
3418
|
-
if (!(error instanceof DOMException && error.name === "AbortError")) {
|
|
3419
|
-
logger.debug("Progress observer stream ended:", error);
|
|
3420
|
-
}
|
|
3421
|
-
} finally {
|
|
3422
|
-
reader.releaseLock();
|
|
3423
|
-
}
|
|
3424
|
-
})();
|
|
3425
|
-
return new Response(body, {
|
|
3426
|
-
status: response.status,
|
|
3427
|
-
statusText: response.statusText,
|
|
3428
|
-
headers: response.headers
|
|
3429
|
-
});
|
|
3430
|
-
}
|
|
3431
3346
|
async connectWithStreamableHttp(baseUrl) {
|
|
3432
3347
|
try {
|
|
3433
3348
|
logger.debug("[HttpConnector] Connecting with Streamable HTTP", {
|
|
@@ -3437,23 +3352,12 @@ var HttpConnector = class extends BaseConnector {
|
|
|
3437
3352
|
authProviderUrl: this.opts.authProvider && "serverUrl" in this.opts.authProvider && typeof this.opts.authProvider.serverUrl === "string" ? this.opts.authProvider.serverUrl : "none",
|
|
3438
3353
|
headers: this.headers
|
|
3439
3354
|
});
|
|
3440
|
-
const baseFetch = this.customFetch ?? globalThis.fetch.bind(globalThis);
|
|
3441
|
-
const observedFetch = async (input, init) => {
|
|
3442
|
-
const response = await baseFetch(input, init);
|
|
3443
|
-
const requestHeaders = new Headers(
|
|
3444
|
-
input instanceof Request ? input.headers : void 0
|
|
3445
|
-
);
|
|
3446
|
-
new Headers(init?.headers).forEach((value, key) => {
|
|
3447
|
-
requestHeaders.set(key, value);
|
|
3448
|
-
});
|
|
3449
|
-
return requestHeaders.get("mcp-method") === "subscriptions/listen" ? response : this.observeSseProgress(response);
|
|
3450
|
-
};
|
|
3451
3355
|
const streamableTransport = new StreamableHTTPClientTransport(
|
|
3452
3356
|
new URL(baseUrl),
|
|
3453
3357
|
{
|
|
3454
3358
|
authProvider: this.opts.authProvider,
|
|
3455
3359
|
// ← Pass OAuth provider to SDK
|
|
3456
|
-
fetch:
|
|
3360
|
+
fetch: this.customFetch,
|
|
3457
3361
|
requestInit: {
|
|
3458
3362
|
headers: this.headers
|
|
3459
3363
|
},
|