mcp-use 1.11.0-canary.8 → 1.11.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/{chunk-5RTMAOZ6.js → chunk-A4QJRN7Z.js} +5 -1041
- package/dist/{chunk-4LZSXUFM.js → chunk-B7AGEK7F.js} +1 -1
- package/dist/{chunk-TAEHPLGV.js → chunk-GN5HOAV3.js} +664 -136
- package/dist/chunk-QPIDKGV4.js +1246 -0
- package/dist/chunk-UWWLWLS2.js +62 -0
- package/dist/{chunk-ZFZPZ4GE.js → chunk-V77WS6CS.js} +9 -0
- package/dist/{chunk-EBSNALCB.js → chunk-VRHAF2WT.js} +10 -4
- package/dist/{chunk-X7JKFBPN.js → chunk-Y2HHHJQB.js} +159 -8
- package/dist/{chunk-JPKFN73V.js → chunk-ZLZOOXMJ.js} +96 -43
- package/dist/index.cjs +316 -53
- package/dist/index.js +22 -24
- package/dist/notifications-FLGIFS56.js +9 -0
- package/dist/src/agents/index.cjs +153 -47
- package/dist/src/agents/index.d.ts +1 -1
- package/dist/src/agents/index.d.ts.map +1 -1
- package/dist/src/agents/index.js +7 -10
- package/dist/src/agents/mcp_agent.d.ts.map +1 -1
- package/dist/src/{client/prompts.d.ts → agents/prompts/index.d.ts} +3 -3
- package/dist/src/agents/prompts/index.d.ts.map +1 -0
- package/dist/src/browser.cjs +160 -48
- package/dist/src/browser.js +10 -12
- package/dist/src/client/browser.d.ts.map +1 -1
- package/dist/src/client.cjs +3852 -0
- package/dist/src/client.d.ts +2 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +21 -0
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/connectors/http.d.ts +2 -0
- package/dist/src/connectors/http.d.ts.map +1 -1
- package/dist/src/react/index.cjs +313 -52
- package/dist/src/react/index.js +7 -8
- package/dist/src/react/types.d.ts +41 -1
- package/dist/src/react/types.d.ts.map +1 -1
- package/dist/src/react/useMcp.d.ts.map +1 -1
- package/dist/src/server/endpoints/mount-mcp.d.ts.map +1 -1
- package/dist/src/server/index.cjs +1339 -256
- package/dist/src/server/index.d.ts +2 -0
- package/dist/src/server/index.d.ts.map +1 -1
- package/dist/src/server/index.js +1119 -156
- package/dist/src/server/mcp-server.d.ts +4 -1
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/dist/src/server/notifications/index.d.ts +1 -1
- package/dist/src/server/notifications/index.d.ts.map +1 -1
- package/dist/src/server/notifications/notification-registration.d.ts +51 -0
- package/dist/src/server/notifications/notification-registration.d.ts.map +1 -1
- package/dist/src/server/sessions/index.d.ts +3 -1
- package/dist/src/server/sessions/index.d.ts.map +1 -1
- package/dist/src/server/sessions/session-manager.d.ts +30 -16
- package/dist/src/server/sessions/session-manager.d.ts.map +1 -1
- package/dist/src/server/sessions/stores/filesystem.d.ts +121 -0
- package/dist/src/server/sessions/stores/filesystem.d.ts.map +1 -0
- package/dist/src/server/sessions/stores/index.d.ts +94 -0
- package/dist/src/server/sessions/stores/index.d.ts.map +1 -0
- package/dist/src/server/sessions/stores/memory.d.ts +82 -0
- package/dist/src/server/sessions/stores/memory.d.ts.map +1 -0
- package/dist/src/server/sessions/stores/redis.d.ts +164 -0
- package/dist/src/server/sessions/stores/redis.d.ts.map +1 -0
- package/dist/src/server/sessions/streams/index.d.ts +77 -0
- package/dist/src/server/sessions/streams/index.d.ts.map +1 -0
- package/dist/src/server/sessions/streams/memory.d.ts +76 -0
- package/dist/src/server/sessions/streams/memory.d.ts.map +1 -0
- package/dist/src/server/sessions/streams/redis.d.ts +146 -0
- package/dist/src/server/sessions/streams/redis.d.ts.map +1 -0
- package/dist/src/server/types/common.d.ts +82 -28
- package/dist/src/server/types/common.d.ts.map +1 -1
- package/dist/src/server/types/widget.d.ts +2 -2
- package/dist/src/server/types/widget.d.ts.map +1 -1
- package/dist/src/server/utils/response-helpers.d.ts +4 -2
- package/dist/src/server/utils/response-helpers.d.ts.map +1 -1
- package/dist/src/server/widgets/mount-widgets-dev.d.ts.map +1 -1
- package/dist/src/server/widgets/ui-resource-registration.d.ts.map +1 -1
- package/dist/src/task_managers/index.d.ts +10 -0
- package/dist/src/task_managers/index.d.ts.map +1 -1
- package/dist/src/task_managers/sse.d.ts +34 -1
- package/dist/src/task_managers/sse.d.ts.map +1 -1
- package/dist/src/task_managers/streamable_http.d.ts +8 -2
- package/dist/src/task_managers/streamable_http.d.ts.map +1 -1
- package/dist/src/telemetry/telemetry.d.ts +1 -0
- package/dist/src/telemetry/telemetry.d.ts.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.d.ts.map +1 -1
- package/dist/{tool-execution-helpers-EYAIJERC.js → tool-execution-helpers-ZUA5D5IO.js} +2 -2
- package/dist/tsup.config.d.ts.map +1 -1
- package/package.json +62 -52
- package/dist/chunk-GVU7C2ZD.js +0 -12
- package/dist/chunk-JZNXOM7C.js +0 -204
- package/dist/chunk-XKTBHYNM.js +0 -491
- package/dist/src/client/prompts.cjs +0 -407
- package/dist/src/client/prompts.d.ts.map +0 -1
- package/dist/src/client/prompts.js +0 -11
package/dist/src/client.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ export interface MCPClientOptions {
|
|
|
39
39
|
elicitationCallback?: (params: ElicitRequestFormParams | ElicitRequestURLParams) => Promise<ElicitResult>;
|
|
40
40
|
}
|
|
41
41
|
export { BaseCodeExecutor, E2BCodeExecutor, isVMAvailable, VMCodeExecutor, } from "./client/codeExecutor.js";
|
|
42
|
+
export { MCPSession } from "./session.js";
|
|
43
|
+
export type { CallToolResult, Notification, Root, Tool } from "./session.js";
|
|
42
44
|
/**
|
|
43
45
|
* Node.js-specific MCPClient implementation
|
|
44
46
|
*
|
package/dist/src/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAA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G,CAAC,GAChC,aAAa;IAOhB,OAAO,CAAC,uBAAuB;IAU/B,OAAO,CAAC,mBAAmB;IAkE3B;;OAEG;IACU,WAAW,CACtB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,eAAe,CAAC;IAc3B;;OAEG;IACU,WAAW,CACtB,KAAK,GAAE,MAAW,EAClB,WAAW,GAAE,OAAO,GAAG,cAAc,GAAG,MAAe,GACtD,OAAO,CAAC,OAAO,0BAA0B,EAAE,kBAAkB,CAAC;IAUjE;;OAEG;IACI,cAAc,IAAI,MAAM,EAAE;IAOjC;;;OAGG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAUpC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseCodeExecutor,
|
|
3
|
+
E2BCodeExecutor,
|
|
4
|
+
MCPClient,
|
|
5
|
+
VMCodeExecutor,
|
|
6
|
+
isVMAvailable
|
|
7
|
+
} from "../chunk-QPIDKGV4.js";
|
|
8
|
+
import {
|
|
9
|
+
MCPSession
|
|
10
|
+
} from "../chunk-GN5HOAV3.js";
|
|
11
|
+
import "../chunk-ZLZOOXMJ.js";
|
|
12
|
+
import "../chunk-FRUZDWXH.js";
|
|
13
|
+
import "../chunk-3GQAWCBQ.js";
|
|
14
|
+
export {
|
|
15
|
+
BaseCodeExecutor,
|
|
16
|
+
E2BCodeExecutor,
|
|
17
|
+
MCPClient,
|
|
18
|
+
MCPSession,
|
|
19
|
+
VMCodeExecutor,
|
|
20
|
+
isVMAvailable
|
|
21
|
+
};
|
package/dist/src/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAKjE,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAGpE;AAED,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,gBAAgB,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAC/C,aAAa,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAKjE,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAGpE;AAED,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,gBAAgB,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAC/C,aAAa,CA0Bf"}
|
|
@@ -10,6 +10,7 @@ export interface HttpConnectorOptions extends ConnectorInitOptions {
|
|
|
10
10
|
version: string;
|
|
11
11
|
};
|
|
12
12
|
preferSse?: boolean;
|
|
13
|
+
disableSseFallback?: boolean;
|
|
13
14
|
}
|
|
14
15
|
export declare class HttpConnector extends BaseConnector {
|
|
15
16
|
private readonly baseUrl;
|
|
@@ -18,6 +19,7 @@ export declare class HttpConnector extends BaseConnector {
|
|
|
18
19
|
private readonly sseReadTimeout;
|
|
19
20
|
private readonly clientInfo;
|
|
20
21
|
private readonly preferSse;
|
|
22
|
+
private readonly disableSseFallback;
|
|
21
23
|
private transportType;
|
|
22
24
|
private streamableTransport;
|
|
23
25
|
constructor(baseUrl: string, opts?: HttpConnectorOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/connectors/http.ts"],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,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoC;IAC/D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAU;IACpC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAU;IAC7C,OAAO,CAAC,aAAa,CAA0C;IAC/D,OAAO,CAAC,mBAAmB,CAA8C;gBAE7D,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,oBAAyB;IAmB5D,mFAAmF;IAC7E,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YA8HhB,yBAAyB;YAkJzB,cAAc;IAqE5B,IAAI,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAM7C;IAED;;OAEG;IACH,gBAAgB,IAAI,iBAAiB,GAAG,KAAK,GAAG,IAAI;CAGrD"}
|
package/dist/src/react/index.cjs
CHANGED
|
@@ -482,6 +482,7 @@ var SseConnectionManager = class extends ConnectionManager {
|
|
|
482
482
|
url;
|
|
483
483
|
opts;
|
|
484
484
|
_transport = null;
|
|
485
|
+
reinitializing = false;
|
|
485
486
|
/**
|
|
486
487
|
* Create an SSE connection manager.
|
|
487
488
|
*
|
|
@@ -494,12 +495,53 @@ var SseConnectionManager = class extends ConnectionManager {
|
|
|
494
495
|
this.opts = opts;
|
|
495
496
|
}
|
|
496
497
|
/**
|
|
497
|
-
* Spawn a new `SSEClientTransport` and
|
|
498
|
+
* Spawn a new `SSEClientTransport` and wrap it with 404 handling.
|
|
499
|
+
* Per MCP spec, clients MUST re-initialize when receiving 404 for stale sessions.
|
|
498
500
|
*/
|
|
499
501
|
async establishConnection() {
|
|
500
|
-
|
|
502
|
+
const transport = new import_sse.SSEClientTransport(this.url, this.opts);
|
|
503
|
+
const originalSend = transport.send.bind(transport);
|
|
504
|
+
transport.send = async (message) => {
|
|
505
|
+
const sendMessage = /* @__PURE__ */ __name(async (msg) => {
|
|
506
|
+
if (Array.isArray(msg)) {
|
|
507
|
+
for (const singleMsg of msg) {
|
|
508
|
+
await originalSend(singleMsg);
|
|
509
|
+
}
|
|
510
|
+
} else {
|
|
511
|
+
await originalSend(msg);
|
|
512
|
+
}
|
|
513
|
+
}, "sendMessage");
|
|
514
|
+
try {
|
|
515
|
+
await sendMessage(message);
|
|
516
|
+
} catch (error) {
|
|
517
|
+
if (error?.code === 404 && transport.sessionId && !this.reinitializing) {
|
|
518
|
+
logger.warn(
|
|
519
|
+
`[SSE] Session not found (404), re-initializing per MCP spec...`
|
|
520
|
+
);
|
|
521
|
+
this.reinitializing = true;
|
|
522
|
+
try {
|
|
523
|
+
transport.sessionId = void 0;
|
|
524
|
+
await this.reinitialize(transport);
|
|
525
|
+
logger.info(`[SSE] Re-initialization successful, retrying request`);
|
|
526
|
+
await sendMessage(message);
|
|
527
|
+
} finally {
|
|
528
|
+
this.reinitializing = false;
|
|
529
|
+
}
|
|
530
|
+
} else {
|
|
531
|
+
throw error;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
this._transport = transport;
|
|
501
536
|
logger.debug(`${this.constructor.name} connected successfully`);
|
|
502
|
-
return
|
|
537
|
+
return transport;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Re-initialize the transport with a new session
|
|
541
|
+
* This is called when the server returns 404 for a stale session
|
|
542
|
+
*/
|
|
543
|
+
async reinitialize(transport) {
|
|
544
|
+
logger.debug(`[SSE] Re-initialization triggered`);
|
|
503
545
|
}
|
|
504
546
|
/**
|
|
505
547
|
* Close the underlying transport and clean up resources.
|
|
@@ -876,13 +918,27 @@ function generateUUID() {
|
|
|
876
918
|
__name(generateUUID, "generateUUID");
|
|
877
919
|
|
|
878
920
|
// src/version.ts
|
|
879
|
-
var VERSION = "1.11.0
|
|
921
|
+
var VERSION = "1.11.0";
|
|
880
922
|
function getPackageVersion() {
|
|
881
923
|
return VERSION;
|
|
882
924
|
}
|
|
883
925
|
__name(getPackageVersion, "getPackageVersion");
|
|
884
926
|
|
|
885
927
|
// src/telemetry/telemetry.ts
|
|
928
|
+
function secureRandomString() {
|
|
929
|
+
if (typeof window !== "undefined" && window.crypto && typeof window.crypto.getRandomValues === "function") {
|
|
930
|
+
const array = new Uint8Array(8);
|
|
931
|
+
window.crypto.getRandomValues(array);
|
|
932
|
+
return Array.from(array, (v) => v.toString(16).padStart(2, "0")).join("");
|
|
933
|
+
}
|
|
934
|
+
try {
|
|
935
|
+
const crypto = require("crypto");
|
|
936
|
+
return crypto.randomBytes(8).toString("hex");
|
|
937
|
+
} catch (e) {
|
|
938
|
+
return Math.random().toString(36).substring(2, 15);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
__name(secureRandomString, "secureRandomString");
|
|
886
942
|
var USER_ID_STORAGE_KEY = "mcp_use_user_id";
|
|
887
943
|
function detectRuntimeEnvironment() {
|
|
888
944
|
try {
|
|
@@ -1014,12 +1070,26 @@ var Telemetry = class _Telemetry {
|
|
|
1014
1070
|
"Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."
|
|
1015
1071
|
);
|
|
1016
1072
|
this._posthogLoading = this._initPostHog();
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1073
|
+
if (this._runtimeEnvironment !== "browser") {
|
|
1074
|
+
try {
|
|
1075
|
+
this._scarfClient = new ScarfEventLogger(
|
|
1076
|
+
this.SCARF_GATEWAY_URL,
|
|
1077
|
+
3e3
|
|
1078
|
+
);
|
|
1079
|
+
} catch (e) {
|
|
1080
|
+
logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
|
|
1081
|
+
this._scarfClient = null;
|
|
1082
|
+
}
|
|
1083
|
+
} else {
|
|
1021
1084
|
this._scarfClient = null;
|
|
1022
1085
|
}
|
|
1086
|
+
if (this._storageCapability === "filesystem" && this._scarfClient) {
|
|
1087
|
+
setTimeout(() => {
|
|
1088
|
+
this.trackPackageDownload({ triggered_by: "initialization" }).catch(
|
|
1089
|
+
(e) => logger.debug(`Failed to track package download: ${e}`)
|
|
1090
|
+
);
|
|
1091
|
+
}, 0);
|
|
1092
|
+
}
|
|
1023
1093
|
}
|
|
1024
1094
|
}
|
|
1025
1095
|
_checkTelemetryDisabled() {
|
|
@@ -1144,47 +1214,65 @@ var Telemetry = class _Telemetry {
|
|
|
1144
1214
|
break;
|
|
1145
1215
|
case "session-only":
|
|
1146
1216
|
default:
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1217
|
+
try {
|
|
1218
|
+
this._currUserId = `session-${generateUUID()}`;
|
|
1219
|
+
} catch (uuidError) {
|
|
1220
|
+
this._currUserId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
|
|
1221
|
+
}
|
|
1151
1222
|
break;
|
|
1152
1223
|
}
|
|
1153
|
-
if (this._storageCapability === "filesystem" && this._currUserId) {
|
|
1154
|
-
this._trackPackageDownloadInternal(this._currUserId, {
|
|
1155
|
-
triggered_by: "user_id_property"
|
|
1156
|
-
}).catch((e) => logger.debug(`Failed to track package download: ${e}`));
|
|
1157
|
-
}
|
|
1158
1224
|
} catch (e) {
|
|
1159
|
-
logger.debug(`Failed to get/create user ID: ${e}`);
|
|
1160
1225
|
this._currUserId = this.UNKNOWN_USER_ID;
|
|
1161
1226
|
}
|
|
1162
1227
|
return this._currUserId;
|
|
1163
1228
|
}
|
|
1164
1229
|
/**
|
|
1165
1230
|
* Get or create user ID from filesystem (Node.js/Bun)
|
|
1231
|
+
* Falls back to session ID if filesystem operations fail
|
|
1166
1232
|
*/
|
|
1167
1233
|
_getUserIdFromFilesystem() {
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1234
|
+
try {
|
|
1235
|
+
let fs, os, path;
|
|
1236
|
+
try {
|
|
1237
|
+
fs = require("fs");
|
|
1238
|
+
os = require("os");
|
|
1239
|
+
path = require("path");
|
|
1240
|
+
} catch (requireError) {
|
|
1241
|
+
try {
|
|
1242
|
+
const sessionId = `session-${generateUUID()}`;
|
|
1243
|
+
return sessionId;
|
|
1244
|
+
} catch (uuidError) {
|
|
1245
|
+
return `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
if (!this._userIdPath) {
|
|
1249
|
+
this._userIdPath = path.join(
|
|
1250
|
+
this._getCacheHome(os, path),
|
|
1251
|
+
"mcp_use_3",
|
|
1252
|
+
"telemetry_user_id"
|
|
1253
|
+
);
|
|
1254
|
+
}
|
|
1255
|
+
const isFirstTime = !fs.existsSync(this._userIdPath);
|
|
1256
|
+
if (isFirstTime) {
|
|
1257
|
+
fs.mkdirSync(path.dirname(this._userIdPath), { recursive: true });
|
|
1258
|
+
let newUserId;
|
|
1259
|
+
try {
|
|
1260
|
+
newUserId = generateUUID();
|
|
1261
|
+
} catch (uuidError) {
|
|
1262
|
+
newUserId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
|
|
1263
|
+
}
|
|
1264
|
+
fs.writeFileSync(this._userIdPath, newUserId);
|
|
1265
|
+
return newUserId;
|
|
1266
|
+
}
|
|
1267
|
+
const userId = fs.readFileSync(this._userIdPath, "utf-8").trim();
|
|
1268
|
+
return userId;
|
|
1269
|
+
} catch (e) {
|
|
1270
|
+
try {
|
|
1271
|
+
return `session-${generateUUID()}`;
|
|
1272
|
+
} catch (uuidError) {
|
|
1273
|
+
return `session-${Date.now()}-${secureRandomString()}`;
|
|
1274
|
+
}
|
|
1186
1275
|
}
|
|
1187
|
-
return fs.readFileSync(this._userIdPath, "utf-8").trim();
|
|
1188
1276
|
}
|
|
1189
1277
|
/**
|
|
1190
1278
|
* Get or create user ID from localStorage (Browser)
|
|
@@ -1193,14 +1281,22 @@ var Telemetry = class _Telemetry {
|
|
|
1193
1281
|
try {
|
|
1194
1282
|
let userId = localStorage.getItem(USER_ID_STORAGE_KEY);
|
|
1195
1283
|
if (!userId) {
|
|
1196
|
-
|
|
1284
|
+
try {
|
|
1285
|
+
userId = generateUUID();
|
|
1286
|
+
} catch (uuidError) {
|
|
1287
|
+
userId = `${Date.now()}-${secureRandomString()}`;
|
|
1288
|
+
}
|
|
1197
1289
|
localStorage.setItem(USER_ID_STORAGE_KEY, userId);
|
|
1198
|
-
logger.debug(`Created new browser user ID`);
|
|
1199
1290
|
}
|
|
1200
1291
|
return userId;
|
|
1201
1292
|
} catch (e) {
|
|
1202
|
-
|
|
1203
|
-
|
|
1293
|
+
let sessionId;
|
|
1294
|
+
try {
|
|
1295
|
+
sessionId = `session-${generateUUID()}`;
|
|
1296
|
+
} catch (uuidError) {
|
|
1297
|
+
sessionId = `session-${Date.now()}-${secureRandomString()}`;
|
|
1298
|
+
}
|
|
1299
|
+
return sessionId;
|
|
1204
1300
|
}
|
|
1205
1301
|
}
|
|
1206
1302
|
_getCacheHome(os, path) {
|
|
@@ -1229,6 +1325,7 @@ var Telemetry = class _Telemetry {
|
|
|
1229
1325
|
if (!this._posthogNodeClient && !this._posthogBrowserClient && !this._scarfClient) {
|
|
1230
1326
|
return;
|
|
1231
1327
|
}
|
|
1328
|
+
const currentUserId = this.userId;
|
|
1232
1329
|
const properties = { ...event.properties };
|
|
1233
1330
|
properties.mcp_use_version = getPackageVersion();
|
|
1234
1331
|
properties.language = "typescript";
|
|
@@ -1236,9 +1333,8 @@ var Telemetry = class _Telemetry {
|
|
|
1236
1333
|
properties.runtime = this._runtimeEnvironment;
|
|
1237
1334
|
if (this._posthogNodeClient) {
|
|
1238
1335
|
try {
|
|
1239
|
-
logger.debug(`CAPTURE: PostHog Node Event ${event.name}`);
|
|
1240
1336
|
this._posthogNodeClient.capture({
|
|
1241
|
-
distinctId:
|
|
1337
|
+
distinctId: currentUserId,
|
|
1242
1338
|
event: event.name,
|
|
1243
1339
|
properties
|
|
1244
1340
|
});
|
|
@@ -1248,10 +1344,9 @@ var Telemetry = class _Telemetry {
|
|
|
1248
1344
|
}
|
|
1249
1345
|
if (this._posthogBrowserClient) {
|
|
1250
1346
|
try {
|
|
1251
|
-
logger.debug(`CAPTURE: PostHog Browser Event ${event.name}`);
|
|
1252
1347
|
this._posthogBrowserClient.capture(event.name, {
|
|
1253
1348
|
...properties,
|
|
1254
|
-
distinct_id:
|
|
1349
|
+
distinct_id: currentUserId
|
|
1255
1350
|
});
|
|
1256
1351
|
} catch (e) {
|
|
1257
1352
|
logger.debug(
|
|
@@ -1263,7 +1358,7 @@ var Telemetry = class _Telemetry {
|
|
|
1263
1358
|
try {
|
|
1264
1359
|
const scarfProperties = {
|
|
1265
1360
|
...properties,
|
|
1266
|
-
user_id:
|
|
1361
|
+
user_id: currentUserId,
|
|
1267
1362
|
event: event.name
|
|
1268
1363
|
};
|
|
1269
1364
|
await this._scarfClient.logEvent(scarfProperties);
|
|
@@ -2001,6 +2096,7 @@ var HttpConnector = class extends BaseConnector {
|
|
|
2001
2096
|
sseReadTimeout;
|
|
2002
2097
|
clientInfo;
|
|
2003
2098
|
preferSse;
|
|
2099
|
+
disableSseFallback;
|
|
2004
2100
|
transportType = null;
|
|
2005
2101
|
streamableTransport = null;
|
|
2006
2102
|
constructor(baseUrl, opts = {}) {
|
|
@@ -2017,6 +2113,7 @@ var HttpConnector = class extends BaseConnector {
|
|
|
2017
2113
|
version: "1.0.0"
|
|
2018
2114
|
};
|
|
2019
2115
|
this.preferSse = opts.preferSse ?? false;
|
|
2116
|
+
this.disableSseFallback = opts.disableSseFallback ?? false;
|
|
2020
2117
|
}
|
|
2021
2118
|
/** Establish connection to the MCP implementation via HTTP (streamable or SSE). */
|
|
2022
2119
|
async connect() {
|
|
@@ -2073,6 +2170,13 @@ var HttpConnector = class extends BaseConnector {
|
|
|
2073
2170
|
authError.code = 401;
|
|
2074
2171
|
throw authError;
|
|
2075
2172
|
}
|
|
2173
|
+
if (this.disableSseFallback) {
|
|
2174
|
+
logger.info("SSE fallback disabled - failing connection");
|
|
2175
|
+
await this.cleanupResources();
|
|
2176
|
+
throw new Error(
|
|
2177
|
+
`Streamable HTTP connection failed: ${fallbackReason}. SSE fallback is disabled.`
|
|
2178
|
+
);
|
|
2179
|
+
}
|
|
2076
2180
|
logger.info("\u{1F504} Falling back to SSE transport...");
|
|
2077
2181
|
try {
|
|
2078
2182
|
await this.connectWithSse(baseUrl);
|
|
@@ -2714,7 +2818,9 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
|
2714
2818
|
wrapTransport,
|
|
2715
2819
|
clientOptions,
|
|
2716
2820
|
samplingCallback,
|
|
2717
|
-
elicitationCallback
|
|
2821
|
+
elicitationCallback,
|
|
2822
|
+
disableSseFallback,
|
|
2823
|
+
preferSse
|
|
2718
2824
|
} = serverConfig;
|
|
2719
2825
|
if (!url) {
|
|
2720
2826
|
throw new Error("Server URL is required");
|
|
@@ -2730,8 +2836,12 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
|
2730
2836
|
// ← Pass client options (capabilities, etc.) to connector
|
|
2731
2837
|
samplingCallback,
|
|
2732
2838
|
// ← Pass sampling callback to connector
|
|
2733
|
-
elicitationCallback
|
|
2839
|
+
elicitationCallback,
|
|
2734
2840
|
// ← Pass elicitation callback to connector
|
|
2841
|
+
disableSseFallback,
|
|
2842
|
+
// ← Disable automatic SSE fallback
|
|
2843
|
+
preferSse
|
|
2844
|
+
// ← Use SSE transport directly
|
|
2735
2845
|
};
|
|
2736
2846
|
if (clientOptions) {
|
|
2737
2847
|
console.log(
|
|
@@ -3065,6 +3175,11 @@ function useMcp(options) {
|
|
|
3065
3175
|
if (clientRef.current) {
|
|
3066
3176
|
try {
|
|
3067
3177
|
const serverName = "inspector-server";
|
|
3178
|
+
const session = clientRef.current.getSession(serverName);
|
|
3179
|
+
if (session && session._healthCheckCleanup) {
|
|
3180
|
+
session._healthCheckCleanup();
|
|
3181
|
+
session._healthCheckCleanup = null;
|
|
3182
|
+
}
|
|
3068
3183
|
await clientRef.current.closeSession(serverName);
|
|
3069
3184
|
} catch (err) {
|
|
3070
3185
|
if (!quiet) addLog("warn", "Error closing session:", err);
|
|
@@ -3166,7 +3281,12 @@ function useMcp(options) {
|
|
|
3166
3281
|
const serverName = "inspector-server";
|
|
3167
3282
|
const serverConfig = {
|
|
3168
3283
|
url,
|
|
3169
|
-
transport: transportTypeParam === "sse" ? "http" : transportTypeParam
|
|
3284
|
+
transport: transportTypeParam === "sse" ? "http" : transportTypeParam,
|
|
3285
|
+
// Disable SSE fallback when using explicit HTTP transport (not SSE)
|
|
3286
|
+
// This prevents automatic HTTP → SSE fallback at the connector level
|
|
3287
|
+
disableSseFallback: transportTypeParam === "http",
|
|
3288
|
+
// Use SSE transport when explicitly requested
|
|
3289
|
+
preferSse: transportTypeParam === "sse"
|
|
3170
3290
|
};
|
|
3171
3291
|
if (customHeaders && Object.keys(customHeaders).length > 0) {
|
|
3172
3292
|
serverConfig.headers = customHeaders;
|
|
@@ -3204,9 +3324,25 @@ function useMcp(options) {
|
|
|
3204
3324
|
serverName,
|
|
3205
3325
|
false
|
|
3206
3326
|
);
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3327
|
+
session.on("notification", (notification) => {
|
|
3328
|
+
onNotification?.(notification);
|
|
3329
|
+
if (notification.method === "notifications/tools/list_changed") {
|
|
3330
|
+
addLog("info", "Tools list changed, auto-refreshing...");
|
|
3331
|
+
refreshTools().catch(
|
|
3332
|
+
(err) => addLog("warn", "Auto-refresh tools failed:", err)
|
|
3333
|
+
);
|
|
3334
|
+
} else if (notification.method === "notifications/resources/list_changed") {
|
|
3335
|
+
addLog("info", "Resources list changed, auto-refreshing...");
|
|
3336
|
+
refreshResources().catch(
|
|
3337
|
+
(err) => addLog("warn", "Auto-refresh resources failed:", err)
|
|
3338
|
+
);
|
|
3339
|
+
} else if (notification.method === "notifications/prompts/list_changed") {
|
|
3340
|
+
addLog("info", "Prompts list changed, auto-refreshing...");
|
|
3341
|
+
refreshPrompts().catch(
|
|
3342
|
+
(err) => addLog("warn", "Auto-refresh prompts failed:", err)
|
|
3343
|
+
);
|
|
3344
|
+
}
|
|
3345
|
+
});
|
|
3210
3346
|
await session.initialize();
|
|
3211
3347
|
addLog("info", "\u2705 Successfully connected to MCP server");
|
|
3212
3348
|
addLog("info", "Server info:", session.connector.serverInfo);
|
|
@@ -3222,6 +3358,63 @@ function useMcp(options) {
|
|
|
3222
3358
|
);
|
|
3223
3359
|
setState("ready");
|
|
3224
3360
|
successfulTransportRef.current = transportTypeParam;
|
|
3361
|
+
const setupConnectionMonitoring = /* @__PURE__ */ __name(() => {
|
|
3362
|
+
let healthCheckInterval = null;
|
|
3363
|
+
let lastSuccessfulCheck = Date.now();
|
|
3364
|
+
const HEALTH_CHECK_INTERVAL = 1e4;
|
|
3365
|
+
const HEALTH_CHECK_TIMEOUT = 3e4;
|
|
3366
|
+
const checkConnectionHealth = /* @__PURE__ */ __name(async () => {
|
|
3367
|
+
if (!isMountedRef.current || stateRef.current !== "ready") {
|
|
3368
|
+
if (healthCheckInterval) {
|
|
3369
|
+
clearInterval(healthCheckInterval);
|
|
3370
|
+
healthCheckInterval = null;
|
|
3371
|
+
}
|
|
3372
|
+
return;
|
|
3373
|
+
}
|
|
3374
|
+
try {
|
|
3375
|
+
await session.connector.listTools();
|
|
3376
|
+
lastSuccessfulCheck = Date.now();
|
|
3377
|
+
} catch (err) {
|
|
3378
|
+
const timeSinceLastSuccess = Date.now() - lastSuccessfulCheck;
|
|
3379
|
+
if (timeSinceLastSuccess > HEALTH_CHECK_TIMEOUT) {
|
|
3380
|
+
addLog(
|
|
3381
|
+
"warn",
|
|
3382
|
+
`Connection appears to be broken (no response for ${Math.round(timeSinceLastSuccess / 1e3)}s), attempting to reconnect...`
|
|
3383
|
+
);
|
|
3384
|
+
if (healthCheckInterval) {
|
|
3385
|
+
clearInterval(healthCheckInterval);
|
|
3386
|
+
healthCheckInterval = null;
|
|
3387
|
+
}
|
|
3388
|
+
if (autoReconnectRef.current && isMountedRef.current) {
|
|
3389
|
+
setState("discovering");
|
|
3390
|
+
addLog("info", "Auto-reconnecting to MCP server...");
|
|
3391
|
+
setTimeout(
|
|
3392
|
+
() => {
|
|
3393
|
+
if (isMountedRef.current && stateRef.current === "discovering") {
|
|
3394
|
+
connect();
|
|
3395
|
+
}
|
|
3396
|
+
},
|
|
3397
|
+
typeof autoReconnectRef.current === "number" ? autoReconnectRef.current : DEFAULT_RECONNECT_DELAY
|
|
3398
|
+
);
|
|
3399
|
+
}
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
}, "checkConnectionHealth");
|
|
3403
|
+
healthCheckInterval = setInterval(
|
|
3404
|
+
checkConnectionHealth,
|
|
3405
|
+
HEALTH_CHECK_INTERVAL
|
|
3406
|
+
);
|
|
3407
|
+
return () => {
|
|
3408
|
+
if (healthCheckInterval) {
|
|
3409
|
+
clearInterval(healthCheckInterval);
|
|
3410
|
+
healthCheckInterval = null;
|
|
3411
|
+
}
|
|
3412
|
+
};
|
|
3413
|
+
}, "setupConnectionMonitoring");
|
|
3414
|
+
if (autoReconnect) {
|
|
3415
|
+
const cleanup = setupConnectionMonitoring();
|
|
3416
|
+
session._healthCheckCleanup = cleanup;
|
|
3417
|
+
}
|
|
3225
3418
|
Tel.getInstance().trackUseMcpConnection({
|
|
3226
3419
|
url,
|
|
3227
3420
|
transportType: transportTypeParam,
|
|
@@ -3573,6 +3766,70 @@ function useMcp(options) {
|
|
|
3573
3766
|
throw err;
|
|
3574
3767
|
}
|
|
3575
3768
|
}, [state]);
|
|
3769
|
+
const refreshTools = (0, import_react.useCallback)(async () => {
|
|
3770
|
+
if (stateRef.current !== "ready" || !clientRef.current) {
|
|
3771
|
+
addLog("debug", "Cannot refresh tools - client not ready");
|
|
3772
|
+
return;
|
|
3773
|
+
}
|
|
3774
|
+
addLog("debug", "Refreshing tools list");
|
|
3775
|
+
try {
|
|
3776
|
+
const serverName = "inspector-server";
|
|
3777
|
+
const session = clientRef.current.getSession(serverName);
|
|
3778
|
+
if (!session) {
|
|
3779
|
+
addLog("warn", "No active session found for tools refresh");
|
|
3780
|
+
return;
|
|
3781
|
+
}
|
|
3782
|
+
const toolsResult = await session.connector.listTools();
|
|
3783
|
+
setTools(toolsResult || []);
|
|
3784
|
+
addLog("info", "Tools list refreshed successfully");
|
|
3785
|
+
} catch (err) {
|
|
3786
|
+
addLog("warn", "Failed to refresh tools:", err);
|
|
3787
|
+
}
|
|
3788
|
+
}, [addLog]);
|
|
3789
|
+
const refreshResources = (0, import_react.useCallback)(async () => {
|
|
3790
|
+
if (stateRef.current !== "ready" || !clientRef.current) {
|
|
3791
|
+
addLog("debug", "Cannot refresh resources - client not ready");
|
|
3792
|
+
return;
|
|
3793
|
+
}
|
|
3794
|
+
addLog("debug", "Refreshing resources list");
|
|
3795
|
+
try {
|
|
3796
|
+
const serverName = "inspector-server";
|
|
3797
|
+
const session = clientRef.current.getSession(serverName);
|
|
3798
|
+
if (!session) {
|
|
3799
|
+
addLog("warn", "No active session found for resources refresh");
|
|
3800
|
+
return;
|
|
3801
|
+
}
|
|
3802
|
+
const resourcesResult = await session.connector.listAllResources();
|
|
3803
|
+
setResources(resourcesResult.resources || []);
|
|
3804
|
+
addLog("info", "Resources list refreshed successfully");
|
|
3805
|
+
} catch (err) {
|
|
3806
|
+
addLog("warn", "Failed to refresh resources:", err);
|
|
3807
|
+
}
|
|
3808
|
+
}, [addLog]);
|
|
3809
|
+
const refreshPrompts = (0, import_react.useCallback)(async () => {
|
|
3810
|
+
if (stateRef.current !== "ready" || !clientRef.current) {
|
|
3811
|
+
addLog("debug", "Cannot refresh prompts - client not ready");
|
|
3812
|
+
return;
|
|
3813
|
+
}
|
|
3814
|
+
addLog("debug", "Refreshing prompts list");
|
|
3815
|
+
try {
|
|
3816
|
+
const serverName = "inspector-server";
|
|
3817
|
+
const session = clientRef.current.getSession(serverName);
|
|
3818
|
+
if (!session) {
|
|
3819
|
+
addLog("warn", "No active session found for prompts refresh");
|
|
3820
|
+
return;
|
|
3821
|
+
}
|
|
3822
|
+
const promptsResult = await session.connector.listPrompts();
|
|
3823
|
+
setPrompts(promptsResult.prompts || []);
|
|
3824
|
+
addLog("info", "Prompts list refreshed successfully");
|
|
3825
|
+
} catch (err) {
|
|
3826
|
+
addLog("warn", "Failed to refresh prompts:", err);
|
|
3827
|
+
}
|
|
3828
|
+
}, [addLog]);
|
|
3829
|
+
const refreshAll = (0, import_react.useCallback)(async () => {
|
|
3830
|
+
addLog("info", "Refreshing all lists (tools, resources, prompts)");
|
|
3831
|
+
await Promise.all([refreshTools(), refreshResources(), refreshPrompts()]);
|
|
3832
|
+
}, [refreshTools, refreshResources, refreshPrompts, addLog]);
|
|
3576
3833
|
const getPrompt = (0, import_react.useCallback)(
|
|
3577
3834
|
async (name, args) => {
|
|
3578
3835
|
if (stateRef.current !== "ready" || !clientRef.current) {
|
|
@@ -3724,6 +3981,10 @@ function useMcp(options) {
|
|
|
3724
3981
|
listResources,
|
|
3725
3982
|
listPrompts,
|
|
3726
3983
|
getPrompt,
|
|
3984
|
+
refreshTools,
|
|
3985
|
+
refreshResources,
|
|
3986
|
+
refreshPrompts,
|
|
3987
|
+
refreshAll,
|
|
3727
3988
|
retry,
|
|
3728
3989
|
disconnect,
|
|
3729
3990
|
authenticate,
|
package/dist/src/react/index.js
CHANGED
|
@@ -9,19 +9,18 @@ import {
|
|
|
9
9
|
useWidgetProps,
|
|
10
10
|
useWidgetState,
|
|
11
11
|
useWidgetTheme
|
|
12
|
-
} from "../../chunk-
|
|
13
|
-
import "../../chunk-
|
|
14
|
-
import "../../chunk-
|
|
15
|
-
import {
|
|
16
|
-
onMcpAuthorization
|
|
17
|
-
} from "../../chunk-J75I2C26.js";
|
|
18
|
-
import "../../chunk-XKTBHYNM.js";
|
|
12
|
+
} from "../../chunk-Y2HHHJQB.js";
|
|
13
|
+
import "../../chunk-VRHAF2WT.js";
|
|
14
|
+
import "../../chunk-GN5HOAV3.js";
|
|
19
15
|
import {
|
|
20
16
|
Tel,
|
|
21
17
|
Telemetry,
|
|
22
18
|
setTelemetrySource
|
|
23
|
-
} from "../../chunk-
|
|
19
|
+
} from "../../chunk-ZLZOOXMJ.js";
|
|
24
20
|
import "../../chunk-FRUZDWXH.js";
|
|
21
|
+
import {
|
|
22
|
+
onMcpAuthorization
|
|
23
|
+
} from "../../chunk-J75I2C26.js";
|
|
25
24
|
import "../../chunk-3GQAWCBQ.js";
|
|
26
25
|
export {
|
|
27
26
|
Tel as BrowserTelemetry,
|