mcp-use 1.10.0-canary.8 → 1.10.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-CAIRNNL6.js → chunk-BLIJYL2F.js} +1 -1
- package/dist/{chunk-BBOYAKT6.js → chunk-D3GIGCHA.js} +1 -1
- package/dist/{chunk-X5QAXENQ.js → chunk-EKIKWKIM.js} +1 -1
- package/dist/{chunk-QBKQ6JN2.js → chunk-J76TXLP2.js} +24 -2
- package/dist/{chunk-6W6MURTQ.js → chunk-TWQ72HSN.js} +51 -2
- package/dist/{chunk-MSA3YBQE.js → chunk-UZJK3IKC.js} +1 -1
- package/dist/{chunk-ITRC7CNB.js → chunk-X5EWD2UY.js} +344 -157
- package/dist/index.cjs +424 -166
- package/dist/index.js +24 -18
- package/dist/src/agents/index.cjs +337 -151
- package/dist/src/agents/index.js +4 -4
- package/dist/src/browser.cjs +371 -151
- package/dist/src/browser.d.ts +3 -0
- package/dist/src/browser.d.ts.map +1 -1
- package/dist/src/browser.js +13 -5
- package/dist/src/client/base.d.ts.map +1 -1
- package/dist/src/client/browser.d.ts +1 -0
- package/dist/src/client/browser.d.ts.map +1 -1
- package/dist/src/client/prompts.cjs +3 -9
- package/dist/src/client/prompts.js +3 -3
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/react/index.cjs +414 -151
- package/dist/src/react/index.d.ts +3 -0
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/react/index.js +13 -4
- package/dist/src/react/useMcp.d.ts.map +1 -1
- package/dist/src/server/index.cjs +756 -569
- package/dist/src/server/index.js +5 -5
- package/dist/src/telemetry/events.d.ts +28 -0
- package/dist/src/telemetry/events.d.ts.map +1 -1
- package/dist/src/telemetry/index.d.ts +4 -4
- package/dist/src/telemetry/index.d.ts.map +1 -1
- package/dist/src/telemetry/telemetry.d.ts +74 -11
- 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-BMGQQKS2.js → tool-execution-helpers-IMWBWRMK.js} +2 -2
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -35,9 +35,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
35
35
|
async function getNodeModules() {
|
|
36
36
|
if (typeof process !== "undefined" && process.platform) {
|
|
37
37
|
try {
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
return { fs:
|
|
38
|
+
const fs2 = await import("fs");
|
|
39
|
+
const path2 = await import("path");
|
|
40
|
+
return { fs: fs2.default, path: path2.default };
|
|
41
41
|
} catch {
|
|
42
42
|
return { fs: null, path: null };
|
|
43
43
|
}
|
|
@@ -1053,6 +1053,7 @@ __export(index_exports, {
|
|
|
1053
1053
|
BaseCodeExecutor: () => BaseCodeExecutor,
|
|
1054
1054
|
BaseConnector: () => BaseConnector,
|
|
1055
1055
|
BrowserOAuthClientProvider: () => BrowserOAuthClientProvider,
|
|
1056
|
+
BrowserTelemetry: () => Tel,
|
|
1056
1057
|
ConnectMCPServerTool: () => ConnectMCPServerTool,
|
|
1057
1058
|
E2BCodeExecutor: () => E2BCodeExecutor,
|
|
1058
1059
|
ElicitationDeclinedError: () => ElicitationDeclinedError,
|
|
@@ -1076,6 +1077,7 @@ __export(index_exports, {
|
|
|
1076
1077
|
RemoteAgent: () => RemoteAgent,
|
|
1077
1078
|
ServerManager: () => ServerManager,
|
|
1078
1079
|
StdioConnector: () => StdioConnector,
|
|
1080
|
+
Tel: () => Tel,
|
|
1079
1081
|
Telemetry: () => Telemetry,
|
|
1080
1082
|
ThemeProvider: () => ThemeProvider,
|
|
1081
1083
|
VERSION: () => VERSION,
|
|
@@ -1089,6 +1091,7 @@ __export(index_exports, {
|
|
|
1089
1091
|
loadConfigFile: () => loadConfigFile,
|
|
1090
1092
|
logger: () => logger,
|
|
1091
1093
|
onMcpAuthorization: () => onMcpAuthorization,
|
|
1094
|
+
setBrowserTelemetrySource: () => setTelemetrySource,
|
|
1092
1095
|
setTelemetrySource: () => setTelemetrySource,
|
|
1093
1096
|
streamEventsToAISDK: () => streamEventsToAISDK,
|
|
1094
1097
|
streamEventsToAISDKWithTools: () => streamEventsToAISDKWithTools,
|
|
@@ -2514,22 +2517,6 @@ var ObservabilityManager = class {
|
|
|
2514
2517
|
}
|
|
2515
2518
|
};
|
|
2516
2519
|
|
|
2517
|
-
// src/telemetry/telemetry.ts
|
|
2518
|
-
var fs = __toESM(require("fs"), 1);
|
|
2519
|
-
var os = __toESM(require("os"), 1);
|
|
2520
|
-
var path = __toESM(require("path"), 1);
|
|
2521
|
-
var import_posthog_node = require("posthog-node");
|
|
2522
|
-
|
|
2523
|
-
// src/server/utils/runtime.ts
|
|
2524
|
-
var isDeno = typeof globalThis.Deno !== "undefined";
|
|
2525
|
-
function generateUUID() {
|
|
2526
|
-
return globalThis.crypto.randomUUID();
|
|
2527
|
-
}
|
|
2528
|
-
__name(generateUUID, "generateUUID");
|
|
2529
|
-
|
|
2530
|
-
// src/telemetry/telemetry.ts
|
|
2531
|
-
init_logging();
|
|
2532
|
-
|
|
2533
2520
|
// src/telemetry/events.ts
|
|
2534
2521
|
var BaseTelemetryEvent = class {
|
|
2535
2522
|
static {
|
|
@@ -2805,7 +2792,8 @@ var MCPClientInitEvent = class extends BaseTelemetryEvent {
|
|
|
2805
2792
|
all_callbacks: this.data.allCallbacks,
|
|
2806
2793
|
verify: this.data.verify,
|
|
2807
2794
|
servers: this.data.servers,
|
|
2808
|
-
num_servers: this.data.numServers
|
|
2795
|
+
num_servers: this.data.numServers,
|
|
2796
|
+
is_browser: this.data.isBrowser
|
|
2809
2797
|
};
|
|
2810
2798
|
}
|
|
2811
2799
|
};
|
|
@@ -2830,9 +2818,65 @@ var ConnectorInitEvent = class extends BaseTelemetryEvent {
|
|
|
2830
2818
|
};
|
|
2831
2819
|
}
|
|
2832
2820
|
};
|
|
2821
|
+
var ClientAddServerEvent = class extends BaseTelemetryEvent {
|
|
2822
|
+
constructor(data) {
|
|
2823
|
+
super();
|
|
2824
|
+
this.data = data;
|
|
2825
|
+
}
|
|
2826
|
+
static {
|
|
2827
|
+
__name(this, "ClientAddServerEvent");
|
|
2828
|
+
}
|
|
2829
|
+
get name() {
|
|
2830
|
+
return "client_add_server";
|
|
2831
|
+
}
|
|
2832
|
+
get properties() {
|
|
2833
|
+
const { serverName, serverConfig } = this.data;
|
|
2834
|
+
const url = serverConfig.url;
|
|
2835
|
+
return {
|
|
2836
|
+
server_name: serverName,
|
|
2837
|
+
server_url_domain: url ? this._extractHostname(url) : null,
|
|
2838
|
+
transport: serverConfig.transport ?? null,
|
|
2839
|
+
has_auth: !!(serverConfig.authToken || serverConfig.authProvider)
|
|
2840
|
+
};
|
|
2841
|
+
}
|
|
2842
|
+
_extractHostname(url) {
|
|
2843
|
+
try {
|
|
2844
|
+
return new URL(url).hostname;
|
|
2845
|
+
} catch {
|
|
2846
|
+
return null;
|
|
2847
|
+
}
|
|
2848
|
+
}
|
|
2849
|
+
};
|
|
2850
|
+
var ClientRemoveServerEvent = class extends BaseTelemetryEvent {
|
|
2851
|
+
constructor(data) {
|
|
2852
|
+
super();
|
|
2853
|
+
this.data = data;
|
|
2854
|
+
}
|
|
2855
|
+
static {
|
|
2856
|
+
__name(this, "ClientRemoveServerEvent");
|
|
2857
|
+
}
|
|
2858
|
+
get name() {
|
|
2859
|
+
return "client_remove_server";
|
|
2860
|
+
}
|
|
2861
|
+
get properties() {
|
|
2862
|
+
return {
|
|
2863
|
+
server_name: this.data.serverName
|
|
2864
|
+
};
|
|
2865
|
+
}
|
|
2866
|
+
};
|
|
2867
|
+
|
|
2868
|
+
// src/server/utils/runtime.ts
|
|
2869
|
+
var isDeno = typeof globalThis.Deno !== "undefined";
|
|
2870
|
+
function generateUUID() {
|
|
2871
|
+
return globalThis.crypto.randomUUID();
|
|
2872
|
+
}
|
|
2873
|
+
__name(generateUUID, "generateUUID");
|
|
2874
|
+
|
|
2875
|
+
// src/telemetry/telemetry.ts
|
|
2876
|
+
init_logging();
|
|
2833
2877
|
|
|
2834
2878
|
// src/version.ts
|
|
2835
|
-
var VERSION = "1.10.0
|
|
2879
|
+
var VERSION = "1.10.0";
|
|
2836
2880
|
function getPackageVersion() {
|
|
2837
2881
|
return VERSION;
|
|
2838
2882
|
}
|
|
@@ -2886,12 +2930,12 @@ function detectRuntimeEnvironment() {
|
|
|
2886
2930
|
if (typeof globalThis.EdgeRuntime !== "undefined") {
|
|
2887
2931
|
return "edge";
|
|
2888
2932
|
}
|
|
2889
|
-
if (typeof process !== "undefined" && typeof process.versions?.node !== "undefined" && typeof fs !== "undefined" && typeof fs.existsSync === "function") {
|
|
2890
|
-
return "node";
|
|
2891
|
-
}
|
|
2892
2933
|
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
2893
2934
|
return "browser";
|
|
2894
2935
|
}
|
|
2936
|
+
if (typeof process !== "undefined" && typeof process.versions?.node !== "undefined") {
|
|
2937
|
+
return "node";
|
|
2938
|
+
}
|
|
2895
2939
|
return "unknown";
|
|
2896
2940
|
} catch {
|
|
2897
2941
|
return "unknown";
|
|
@@ -2928,11 +2972,6 @@ function getRuntimeEnvironment() {
|
|
|
2928
2972
|
return cachedEnvironment;
|
|
2929
2973
|
}
|
|
2930
2974
|
__name(getRuntimeEnvironment, "getRuntimeEnvironment");
|
|
2931
|
-
function isNodeJSEnvironment2() {
|
|
2932
|
-
const env = getRuntimeEnvironment();
|
|
2933
|
-
return env === "node" || env === "bun";
|
|
2934
|
-
}
|
|
2935
|
-
__name(isNodeJSEnvironment2, "isNodeJSEnvironment");
|
|
2936
2975
|
var ScarfEventLogger = class {
|
|
2937
2976
|
static {
|
|
2938
2977
|
__name(this, "ScarfEventLogger");
|
|
@@ -2964,71 +3003,40 @@ var ScarfEventLogger = class {
|
|
|
2964
3003
|
}
|
|
2965
3004
|
}
|
|
2966
3005
|
};
|
|
2967
|
-
function getCacheHome() {
|
|
2968
|
-
if (!isNodeJSEnvironment2()) {
|
|
2969
|
-
return "/tmp/mcp_use_cache";
|
|
2970
|
-
}
|
|
2971
|
-
const envVar = process.env.XDG_CACHE_HOME;
|
|
2972
|
-
if (envVar && path.isAbsolute(envVar)) {
|
|
2973
|
-
return envVar;
|
|
2974
|
-
}
|
|
2975
|
-
const platform = process.platform;
|
|
2976
|
-
const homeDir = os.homedir();
|
|
2977
|
-
if (platform === "win32") {
|
|
2978
|
-
const appdata = process.env.LOCALAPPDATA || process.env.APPDATA;
|
|
2979
|
-
if (appdata) {
|
|
2980
|
-
return appdata;
|
|
2981
|
-
}
|
|
2982
|
-
return path.join(homeDir, "AppData", "Local");
|
|
2983
|
-
} else if (platform === "darwin") {
|
|
2984
|
-
return path.join(homeDir, "Library", "Caches");
|
|
2985
|
-
} else {
|
|
2986
|
-
return path.join(homeDir, ".cache");
|
|
2987
|
-
}
|
|
2988
|
-
}
|
|
2989
|
-
__name(getCacheHome, "getCacheHome");
|
|
2990
3006
|
var Telemetry = class _Telemetry {
|
|
2991
3007
|
static {
|
|
2992
3008
|
__name(this, "Telemetry");
|
|
2993
3009
|
}
|
|
2994
3010
|
static instance = null;
|
|
2995
|
-
USER_ID_PATH = path.join(
|
|
2996
|
-
getCacheHome(),
|
|
2997
|
-
"mcp_use_3",
|
|
2998
|
-
"telemetry_user_id"
|
|
2999
|
-
);
|
|
3000
|
-
VERSION_DOWNLOAD_PATH = path.join(
|
|
3001
|
-
getCacheHome(),
|
|
3002
|
-
"mcp_use",
|
|
3003
|
-
"download_version"
|
|
3004
|
-
);
|
|
3005
3011
|
PROJECT_API_KEY = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";
|
|
3006
3012
|
HOST = "https://eu.i.posthog.com";
|
|
3007
3013
|
SCARF_GATEWAY_URL = "https://mcpuse.gateway.scarf.sh/events-ts";
|
|
3008
3014
|
UNKNOWN_USER_ID = "UNKNOWN_USER_ID";
|
|
3009
3015
|
_currUserId = null;
|
|
3010
|
-
|
|
3016
|
+
_posthogNodeClient = null;
|
|
3017
|
+
_posthogBrowserClient = null;
|
|
3018
|
+
_posthogLoading = null;
|
|
3011
3019
|
_scarfClient = null;
|
|
3012
3020
|
_runtimeEnvironment;
|
|
3013
3021
|
_storageCapability;
|
|
3014
3022
|
_source;
|
|
3023
|
+
// Node.js specific paths (lazily computed)
|
|
3024
|
+
_userIdPath = null;
|
|
3025
|
+
_versionDownloadPath = null;
|
|
3015
3026
|
constructor() {
|
|
3016
3027
|
this._runtimeEnvironment = getRuntimeEnvironment();
|
|
3017
3028
|
this._storageCapability = getStorageCapability(this._runtimeEnvironment);
|
|
3018
3029
|
this._source = typeof process !== "undefined" && process.env?.MCP_USE_TELEMETRY_SOURCE || this._runtimeEnvironment;
|
|
3019
|
-
const telemetryDisabled =
|
|
3030
|
+
const telemetryDisabled = this._checkTelemetryDisabled();
|
|
3020
3031
|
const canSupportTelemetry = this._runtimeEnvironment !== "unknown";
|
|
3021
|
-
const isServerlessEnvironment = [
|
|
3022
|
-
"cloudflare-workers",
|
|
3023
|
-
"edge",
|
|
3024
|
-
"deno"
|
|
3025
|
-
].includes(this._runtimeEnvironment);
|
|
3026
3032
|
if (telemetryDisabled) {
|
|
3027
|
-
this.
|
|
3033
|
+
this._posthogNodeClient = null;
|
|
3034
|
+
this._posthogBrowserClient = null;
|
|
3028
3035
|
this._scarfClient = null;
|
|
3029
|
-
logger.debug("Telemetry disabled via environment
|
|
3036
|
+
logger.debug("Telemetry disabled via environment/localStorage");
|
|
3030
3037
|
} else if (!canSupportTelemetry) {
|
|
3031
|
-
this.
|
|
3038
|
+
this._posthogNodeClient = null;
|
|
3039
|
+
this._posthogBrowserClient = null;
|
|
3032
3040
|
this._scarfClient = null;
|
|
3033
3041
|
logger.debug(
|
|
3034
3042
|
`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`
|
|
@@ -3037,27 +3045,7 @@ var Telemetry = class _Telemetry {
|
|
|
3037
3045
|
logger.info(
|
|
3038
3046
|
"Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."
|
|
3039
3047
|
);
|
|
3040
|
-
|
|
3041
|
-
try {
|
|
3042
|
-
const posthogOptions = {
|
|
3043
|
-
host: this.HOST,
|
|
3044
|
-
disableGeoip: false
|
|
3045
|
-
};
|
|
3046
|
-
if (isServerlessEnvironment) {
|
|
3047
|
-
posthogOptions.flushAt = 1;
|
|
3048
|
-
posthogOptions.flushInterval = 0;
|
|
3049
|
-
}
|
|
3050
|
-
this._posthogClient = new import_posthog_node.PostHog(
|
|
3051
|
-
this.PROJECT_API_KEY,
|
|
3052
|
-
posthogOptions
|
|
3053
|
-
);
|
|
3054
|
-
} catch (e) {
|
|
3055
|
-
logger.warn(`Failed to initialize PostHog telemetry: ${e}`);
|
|
3056
|
-
this._posthogClient = null;
|
|
3057
|
-
}
|
|
3058
|
-
} else {
|
|
3059
|
-
this._posthogClient = null;
|
|
3060
|
-
}
|
|
3048
|
+
this._posthogLoading = this._initPostHog();
|
|
3061
3049
|
try {
|
|
3062
3050
|
this._scarfClient = new ScarfEventLogger(this.SCARF_GATEWAY_URL, 3e3);
|
|
3063
3051
|
} catch (e) {
|
|
@@ -3066,6 +3054,75 @@ var Telemetry = class _Telemetry {
|
|
|
3066
3054
|
}
|
|
3067
3055
|
}
|
|
3068
3056
|
}
|
|
3057
|
+
_checkTelemetryDisabled() {
|
|
3058
|
+
if (typeof process !== "undefined" && process.env?.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase() === "false") {
|
|
3059
|
+
return true;
|
|
3060
|
+
}
|
|
3061
|
+
if (typeof localStorage !== "undefined" && localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY") === "false") {
|
|
3062
|
+
return true;
|
|
3063
|
+
}
|
|
3064
|
+
return false;
|
|
3065
|
+
}
|
|
3066
|
+
async _initPostHog() {
|
|
3067
|
+
const isBrowser = this._runtimeEnvironment === "browser";
|
|
3068
|
+
if (isBrowser) {
|
|
3069
|
+
await this._initPostHogBrowser();
|
|
3070
|
+
} else {
|
|
3071
|
+
await this._initPostHogNode();
|
|
3072
|
+
}
|
|
3073
|
+
}
|
|
3074
|
+
async _initPostHogBrowser() {
|
|
3075
|
+
try {
|
|
3076
|
+
const posthogModule = await import("posthog-js");
|
|
3077
|
+
const posthog = posthogModule.default || posthogModule.posthog;
|
|
3078
|
+
if (!posthog || typeof posthog.init !== "function") {
|
|
3079
|
+
throw new Error("posthog-js module did not export expected interface");
|
|
3080
|
+
}
|
|
3081
|
+
posthog.init(this.PROJECT_API_KEY, {
|
|
3082
|
+
api_host: this.HOST,
|
|
3083
|
+
persistence: "localStorage",
|
|
3084
|
+
autocapture: false,
|
|
3085
|
+
// We only want explicit captures
|
|
3086
|
+
capture_pageview: false,
|
|
3087
|
+
// We don't want automatic pageview tracking
|
|
3088
|
+
disable_session_recording: true,
|
|
3089
|
+
// No session recording
|
|
3090
|
+
loaded: /* @__PURE__ */ __name(() => {
|
|
3091
|
+
logger.debug("PostHog browser client initialized");
|
|
3092
|
+
}, "loaded")
|
|
3093
|
+
});
|
|
3094
|
+
this._posthogBrowserClient = posthog;
|
|
3095
|
+
} catch (e) {
|
|
3096
|
+
logger.warn(`Failed to initialize PostHog browser telemetry: ${e}`);
|
|
3097
|
+
this._posthogBrowserClient = null;
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3100
|
+
async _initPostHogNode() {
|
|
3101
|
+
try {
|
|
3102
|
+
const { PostHog } = await import("posthog-node");
|
|
3103
|
+
const isServerlessEnvironment = [
|
|
3104
|
+
"cloudflare-workers",
|
|
3105
|
+
"edge",
|
|
3106
|
+
"deno"
|
|
3107
|
+
].includes(this._runtimeEnvironment);
|
|
3108
|
+
const posthogOptions = {
|
|
3109
|
+
host: this.HOST,
|
|
3110
|
+
disableGeoip: false
|
|
3111
|
+
};
|
|
3112
|
+
if (isServerlessEnvironment) {
|
|
3113
|
+
posthogOptions.flushAt = 1;
|
|
3114
|
+
posthogOptions.flushInterval = 0;
|
|
3115
|
+
}
|
|
3116
|
+
this._posthogNodeClient = new PostHog(
|
|
3117
|
+
this.PROJECT_API_KEY,
|
|
3118
|
+
posthogOptions
|
|
3119
|
+
);
|
|
3120
|
+
logger.debug("PostHog Node.js client initialized");
|
|
3121
|
+
} catch (e) {
|
|
3122
|
+
logger.warn(`Failed to initialize PostHog Node.js telemetry: ${e}`);
|
|
3123
|
+
this._posthogNodeClient = null;
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3069
3126
|
/**
|
|
3070
3127
|
* Get the detected runtime environment
|
|
3071
3128
|
*/
|
|
@@ -3101,10 +3158,9 @@ var Telemetry = class _Telemetry {
|
|
|
3101
3158
|
}
|
|
3102
3159
|
/**
|
|
3103
3160
|
* Check if telemetry is enabled.
|
|
3104
|
-
* Returns false if telemetry was disabled via environment variable or if not in Node.js environment.
|
|
3105
3161
|
*/
|
|
3106
3162
|
get isEnabled() {
|
|
3107
|
-
return this.
|
|
3163
|
+
return this._posthogNodeClient !== null || this._posthogBrowserClient !== null || this._scarfClient !== null;
|
|
3108
3164
|
}
|
|
3109
3165
|
get userId() {
|
|
3110
3166
|
if (this._currUserId) {
|
|
@@ -3113,10 +3169,10 @@ var Telemetry = class _Telemetry {
|
|
|
3113
3169
|
try {
|
|
3114
3170
|
switch (this._storageCapability) {
|
|
3115
3171
|
case "filesystem":
|
|
3116
|
-
this._currUserId = this.
|
|
3172
|
+
this._currUserId = this._getUserIdFromFilesystem();
|
|
3117
3173
|
break;
|
|
3118
3174
|
case "localStorage":
|
|
3119
|
-
this._currUserId = this.
|
|
3175
|
+
this._currUserId = this._getUserIdFromLocalStorage();
|
|
3120
3176
|
break;
|
|
3121
3177
|
case "session-only":
|
|
3122
3178
|
default:
|
|
@@ -3127,7 +3183,7 @@ var Telemetry = class _Telemetry {
|
|
|
3127
3183
|
break;
|
|
3128
3184
|
}
|
|
3129
3185
|
if (this._storageCapability === "filesystem" && this._currUserId) {
|
|
3130
|
-
this.
|
|
3186
|
+
this._trackPackageDownloadInternal(this._currUserId, {
|
|
3131
3187
|
triggered_by: "user_id_property"
|
|
3132
3188
|
}).catch((e) => logger.debug(`Failed to track package download: ${e}`));
|
|
3133
3189
|
}
|
|
@@ -3140,22 +3196,32 @@ var Telemetry = class _Telemetry {
|
|
|
3140
3196
|
/**
|
|
3141
3197
|
* Get or create user ID from filesystem (Node.js/Bun)
|
|
3142
3198
|
*/
|
|
3143
|
-
|
|
3144
|
-
const
|
|
3199
|
+
_getUserIdFromFilesystem() {
|
|
3200
|
+
const fs2 = require("fs");
|
|
3201
|
+
const os = require("os");
|
|
3202
|
+
const path2 = require("path");
|
|
3203
|
+
if (!this._userIdPath) {
|
|
3204
|
+
this._userIdPath = path2.join(
|
|
3205
|
+
this._getCacheHome(os, path2),
|
|
3206
|
+
"mcp_use_3",
|
|
3207
|
+
"telemetry_user_id"
|
|
3208
|
+
);
|
|
3209
|
+
}
|
|
3210
|
+
const isFirstTime = !fs2.existsSync(this._userIdPath);
|
|
3145
3211
|
if (isFirstTime) {
|
|
3146
|
-
logger.debug(`Creating user ID path: ${this.
|
|
3147
|
-
|
|
3212
|
+
logger.debug(`Creating user ID path: ${this._userIdPath}`);
|
|
3213
|
+
fs2.mkdirSync(path2.dirname(this._userIdPath), { recursive: true });
|
|
3148
3214
|
const newUserId = generateUUID();
|
|
3149
|
-
|
|
3150
|
-
logger.debug(`User ID path created: ${this.
|
|
3215
|
+
fs2.writeFileSync(this._userIdPath, newUserId);
|
|
3216
|
+
logger.debug(`User ID path created: ${this._userIdPath}`);
|
|
3151
3217
|
return newUserId;
|
|
3152
3218
|
}
|
|
3153
|
-
return
|
|
3219
|
+
return fs2.readFileSync(this._userIdPath, "utf-8").trim();
|
|
3154
3220
|
}
|
|
3155
3221
|
/**
|
|
3156
3222
|
* Get or create user ID from localStorage (Browser)
|
|
3157
3223
|
*/
|
|
3158
|
-
|
|
3224
|
+
_getUserIdFromLocalStorage() {
|
|
3159
3225
|
try {
|
|
3160
3226
|
let userId = localStorage.getItem(USER_ID_STORAGE_KEY);
|
|
3161
3227
|
if (!userId) {
|
|
@@ -3169,60 +3235,89 @@ var Telemetry = class _Telemetry {
|
|
|
3169
3235
|
return `session-${generateUUID()}`;
|
|
3170
3236
|
}
|
|
3171
3237
|
}
|
|
3238
|
+
_getCacheHome(os, path2) {
|
|
3239
|
+
const envVar = process.env.XDG_CACHE_HOME;
|
|
3240
|
+
if (envVar && path2.isAbsolute(envVar)) {
|
|
3241
|
+
return envVar;
|
|
3242
|
+
}
|
|
3243
|
+
const platform = process.platform;
|
|
3244
|
+
const homeDir = os.homedir();
|
|
3245
|
+
if (platform === "win32") {
|
|
3246
|
+
const appdata = process.env.LOCALAPPDATA || process.env.APPDATA;
|
|
3247
|
+
if (appdata) {
|
|
3248
|
+
return appdata;
|
|
3249
|
+
}
|
|
3250
|
+
return path2.join(homeDir, "AppData", "Local");
|
|
3251
|
+
} else if (platform === "darwin") {
|
|
3252
|
+
return path2.join(homeDir, "Library", "Caches");
|
|
3253
|
+
} else {
|
|
3254
|
+
return path2.join(homeDir, ".cache");
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3172
3257
|
async capture(event) {
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
if (!this.
|
|
3258
|
+
if (this._posthogLoading) {
|
|
3259
|
+
await this._posthogLoading;
|
|
3260
|
+
}
|
|
3261
|
+
if (!this._posthogNodeClient && !this._posthogBrowserClient && !this._scarfClient) {
|
|
3177
3262
|
return;
|
|
3178
3263
|
}
|
|
3179
|
-
|
|
3264
|
+
const properties = { ...event.properties };
|
|
3265
|
+
properties.mcp_use_version = getPackageVersion();
|
|
3266
|
+
properties.language = "typescript";
|
|
3267
|
+
properties.source = this._source;
|
|
3268
|
+
properties.runtime = this._runtimeEnvironment;
|
|
3269
|
+
if (this._posthogNodeClient) {
|
|
3180
3270
|
try {
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
properties.language = "typescript";
|
|
3184
|
-
properties.source = this._source;
|
|
3185
|
-
properties.runtime = this._runtimeEnvironment;
|
|
3186
|
-
logger.debug(`CAPTURE: PostHog Event ${event.name}`);
|
|
3187
|
-
logger.debug(
|
|
3188
|
-
`CAPTURE: PostHog Properties ${JSON.stringify(properties)}`
|
|
3189
|
-
);
|
|
3190
|
-
this._posthogClient.capture({
|
|
3271
|
+
logger.debug(`CAPTURE: PostHog Node Event ${event.name}`);
|
|
3272
|
+
this._posthogNodeClient.capture({
|
|
3191
3273
|
distinctId: this.userId,
|
|
3192
3274
|
event: event.name,
|
|
3193
3275
|
properties
|
|
3194
3276
|
});
|
|
3195
3277
|
} catch (e) {
|
|
3196
|
-
logger.debug(`Failed to track PostHog event ${event.name}: ${e}`);
|
|
3278
|
+
logger.debug(`Failed to track PostHog Node event ${event.name}: ${e}`);
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
if (this._posthogBrowserClient) {
|
|
3282
|
+
try {
|
|
3283
|
+
logger.debug(`CAPTURE: PostHog Browser Event ${event.name}`);
|
|
3284
|
+
this._posthogBrowserClient.capture(event.name, {
|
|
3285
|
+
...properties,
|
|
3286
|
+
distinct_id: this.userId
|
|
3287
|
+
});
|
|
3288
|
+
} catch (e) {
|
|
3289
|
+
logger.debug(
|
|
3290
|
+
`Failed to track PostHog Browser event ${event.name}: ${e}`
|
|
3291
|
+
);
|
|
3197
3292
|
}
|
|
3198
3293
|
}
|
|
3199
3294
|
if (this._scarfClient) {
|
|
3200
3295
|
try {
|
|
3201
|
-
const
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
properties.runtime = this._runtimeEnvironment;
|
|
3208
|
-
await this._scarfClient.logEvent(properties);
|
|
3296
|
+
const scarfProperties = {
|
|
3297
|
+
...properties,
|
|
3298
|
+
user_id: this.userId,
|
|
3299
|
+
event: event.name
|
|
3300
|
+
};
|
|
3301
|
+
await this._scarfClient.logEvent(scarfProperties);
|
|
3209
3302
|
} catch (e) {
|
|
3210
3303
|
logger.debug(`Failed to track Scarf event ${event.name}: ${e}`);
|
|
3211
3304
|
}
|
|
3212
3305
|
}
|
|
3213
3306
|
}
|
|
3307
|
+
// ============================================================================
|
|
3308
|
+
// Package Download Tracking (Node.js only)
|
|
3309
|
+
// ============================================================================
|
|
3214
3310
|
/**
|
|
3215
3311
|
* Track package download event.
|
|
3216
3312
|
* This is a public wrapper that safely accesses userId.
|
|
3217
3313
|
*/
|
|
3218
3314
|
async trackPackageDownload(properties) {
|
|
3219
|
-
return this.
|
|
3315
|
+
return this._trackPackageDownloadInternal(this.userId, properties);
|
|
3220
3316
|
}
|
|
3221
3317
|
/**
|
|
3222
3318
|
* Internal method to track package download with explicit userId.
|
|
3223
|
-
* This avoids circular dependency when called from the userId getter.
|
|
3224
3319
|
*/
|
|
3225
|
-
async
|
|
3320
|
+
async _trackPackageDownloadInternal(userId, properties) {
|
|
3226
3321
|
if (!this._scarfClient) {
|
|
3227
3322
|
return;
|
|
3228
3323
|
}
|
|
@@ -3230,22 +3325,32 @@ var Telemetry = class _Telemetry {
|
|
|
3230
3325
|
return;
|
|
3231
3326
|
}
|
|
3232
3327
|
try {
|
|
3328
|
+
const fs2 = require("fs");
|
|
3329
|
+
const path2 = require("path");
|
|
3330
|
+
const os = require("os");
|
|
3331
|
+
if (!this._versionDownloadPath) {
|
|
3332
|
+
this._versionDownloadPath = path2.join(
|
|
3333
|
+
this._getCacheHome(os, path2),
|
|
3334
|
+
"mcp_use",
|
|
3335
|
+
"download_version"
|
|
3336
|
+
);
|
|
3337
|
+
}
|
|
3233
3338
|
const currentVersion = getPackageVersion();
|
|
3234
3339
|
let shouldTrack = false;
|
|
3235
3340
|
let firstDownload = false;
|
|
3236
|
-
if (!
|
|
3341
|
+
if (!fs2.existsSync(this._versionDownloadPath)) {
|
|
3237
3342
|
shouldTrack = true;
|
|
3238
3343
|
firstDownload = true;
|
|
3239
|
-
|
|
3344
|
+
fs2.mkdirSync(path2.dirname(this._versionDownloadPath), {
|
|
3240
3345
|
recursive: true
|
|
3241
3346
|
});
|
|
3242
|
-
|
|
3347
|
+
fs2.writeFileSync(this._versionDownloadPath, currentVersion);
|
|
3243
3348
|
} else {
|
|
3244
|
-
const savedVersion =
|
|
3349
|
+
const savedVersion = fs2.readFileSync(this._versionDownloadPath, "utf-8").trim();
|
|
3245
3350
|
if (currentVersion > savedVersion) {
|
|
3246
3351
|
shouldTrack = true;
|
|
3247
3352
|
firstDownload = false;
|
|
3248
|
-
|
|
3353
|
+
fs2.writeFileSync(this._versionDownloadPath, currentVersion);
|
|
3249
3354
|
}
|
|
3250
3355
|
}
|
|
3251
3356
|
if (shouldTrack) {
|
|
@@ -3279,9 +3384,6 @@ var Telemetry = class _Telemetry {
|
|
|
3279
3384
|
// ============================================================================
|
|
3280
3385
|
/**
|
|
3281
3386
|
* Track server run event directly from an MCPServer instance.
|
|
3282
|
-
* This extracts the necessary data from the server and creates the event.
|
|
3283
|
-
* @param server - The MCPServer instance (or any object conforming to MCPServerTelemetryInfo)
|
|
3284
|
-
* @param transport - The transport type (e.g., "http", "stdio", "supabase")
|
|
3285
3387
|
*/
|
|
3286
3388
|
async trackServerRunFromServer(server, transport) {
|
|
3287
3389
|
if (!this.isEnabled) return;
|
|
@@ -3327,37 +3429,123 @@ var Telemetry = class _Telemetry {
|
|
|
3327
3429
|
const event = new ConnectorInitEvent(data);
|
|
3328
3430
|
await this.capture(event);
|
|
3329
3431
|
}
|
|
3432
|
+
async trackClientAddServer(serverName, serverConfig) {
|
|
3433
|
+
if (!this.isEnabled) return;
|
|
3434
|
+
const event = new ClientAddServerEvent({ serverName, serverConfig });
|
|
3435
|
+
await this.capture(event);
|
|
3436
|
+
}
|
|
3437
|
+
async trackClientRemoveServer(serverName) {
|
|
3438
|
+
if (!this.isEnabled) return;
|
|
3439
|
+
const event = new ClientRemoveServerEvent({ serverName });
|
|
3440
|
+
await this.capture(event);
|
|
3441
|
+
}
|
|
3442
|
+
// ============================================================================
|
|
3443
|
+
// React Hook / Browser specific events
|
|
3444
|
+
// ============================================================================
|
|
3445
|
+
async trackUseMcpConnection(data) {
|
|
3446
|
+
if (!this.isEnabled) return;
|
|
3447
|
+
await this.capture({
|
|
3448
|
+
name: "usemcp_connection",
|
|
3449
|
+
properties: {
|
|
3450
|
+
url_domain: new URL(data.url).hostname,
|
|
3451
|
+
// Only domain for privacy
|
|
3452
|
+
transport_type: data.transportType,
|
|
3453
|
+
success: data.success,
|
|
3454
|
+
error_type: data.errorType ?? null,
|
|
3455
|
+
connection_time_ms: data.connectionTimeMs ?? null,
|
|
3456
|
+
has_oauth: data.hasOAuth,
|
|
3457
|
+
has_sampling: data.hasSampling,
|
|
3458
|
+
has_elicitation: data.hasElicitation
|
|
3459
|
+
}
|
|
3460
|
+
});
|
|
3461
|
+
}
|
|
3462
|
+
async trackUseMcpToolCall(data) {
|
|
3463
|
+
if (!this.isEnabled) return;
|
|
3464
|
+
await this.capture({
|
|
3465
|
+
name: "usemcp_tool_call",
|
|
3466
|
+
properties: {
|
|
3467
|
+
tool_name: data.toolName,
|
|
3468
|
+
success: data.success,
|
|
3469
|
+
error_type: data.errorType ?? null,
|
|
3470
|
+
execution_time_ms: data.executionTimeMs ?? null
|
|
3471
|
+
}
|
|
3472
|
+
});
|
|
3473
|
+
}
|
|
3474
|
+
async trackUseMcpResourceRead(data) {
|
|
3475
|
+
if (!this.isEnabled) return;
|
|
3476
|
+
await this.capture({
|
|
3477
|
+
name: "usemcp_resource_read",
|
|
3478
|
+
properties: {
|
|
3479
|
+
resource_uri_scheme: data.resourceUri.split(":")[0],
|
|
3480
|
+
// Only scheme for privacy
|
|
3481
|
+
success: data.success,
|
|
3482
|
+
error_type: data.errorType ?? null
|
|
3483
|
+
}
|
|
3484
|
+
});
|
|
3485
|
+
}
|
|
3486
|
+
// ============================================================================
|
|
3487
|
+
// Browser-specific Methods
|
|
3488
|
+
// ============================================================================
|
|
3489
|
+
/**
|
|
3490
|
+
* Identify the current user (useful for linking sessions)
|
|
3491
|
+
* Browser only - no-op in Node.js
|
|
3492
|
+
*/
|
|
3493
|
+
identify(userId, properties) {
|
|
3494
|
+
if (this._posthogBrowserClient) {
|
|
3495
|
+
try {
|
|
3496
|
+
this._posthogBrowserClient.identify(userId, properties);
|
|
3497
|
+
} catch (e) {
|
|
3498
|
+
logger.debug(`Failed to identify user: ${e}`);
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
|
+
}
|
|
3502
|
+
/**
|
|
3503
|
+
* Reset the user identity (useful for logout)
|
|
3504
|
+
* Browser only - no-op in Node.js
|
|
3505
|
+
*/
|
|
3506
|
+
reset() {
|
|
3507
|
+
if (this._posthogBrowserClient) {
|
|
3508
|
+
try {
|
|
3509
|
+
this._posthogBrowserClient.reset();
|
|
3510
|
+
} catch (e) {
|
|
3511
|
+
logger.debug(`Failed to reset user: ${e}`);
|
|
3512
|
+
}
|
|
3513
|
+
}
|
|
3514
|
+
this._currUserId = null;
|
|
3515
|
+
}
|
|
3516
|
+
// ============================================================================
|
|
3517
|
+
// Node.js-specific Methods
|
|
3518
|
+
// ============================================================================
|
|
3519
|
+
/**
|
|
3520
|
+
* Flush the telemetry queue (Node.js only)
|
|
3521
|
+
*/
|
|
3330
3522
|
flush() {
|
|
3331
|
-
if (this.
|
|
3523
|
+
if (this._posthogNodeClient) {
|
|
3332
3524
|
try {
|
|
3333
|
-
this.
|
|
3525
|
+
this._posthogNodeClient.flush();
|
|
3334
3526
|
logger.debug("PostHog client telemetry queue flushed");
|
|
3335
3527
|
} catch (e) {
|
|
3336
3528
|
logger.debug(`Failed to flush PostHog client: ${e}`);
|
|
3337
3529
|
}
|
|
3338
3530
|
}
|
|
3339
|
-
if (this._scarfClient) {
|
|
3340
|
-
logger.debug("Scarf telemetry events sent immediately (no flush needed)");
|
|
3341
|
-
}
|
|
3342
3531
|
}
|
|
3532
|
+
/**
|
|
3533
|
+
* Shutdown the telemetry client (Node.js only)
|
|
3534
|
+
*/
|
|
3343
3535
|
shutdown() {
|
|
3344
|
-
if (this.
|
|
3536
|
+
if (this._posthogNodeClient) {
|
|
3345
3537
|
try {
|
|
3346
|
-
this.
|
|
3538
|
+
this._posthogNodeClient.shutdown();
|
|
3347
3539
|
logger.debug("PostHog client shutdown successfully");
|
|
3348
3540
|
} catch (e) {
|
|
3349
3541
|
logger.debug(`Error shutting down PostHog client: ${e}`);
|
|
3350
3542
|
}
|
|
3351
3543
|
}
|
|
3352
|
-
if (this._scarfClient) {
|
|
3353
|
-
logger.debug("Scarf telemetry client shutdown (no action needed)");
|
|
3354
|
-
}
|
|
3355
3544
|
}
|
|
3356
3545
|
};
|
|
3357
|
-
|
|
3358
|
-
// src/telemetry/index.ts
|
|
3546
|
+
var Tel = Telemetry;
|
|
3359
3547
|
function setTelemetrySource(source) {
|
|
3360
|
-
|
|
3548
|
+
Tel.getInstance().setSource(source);
|
|
3361
3549
|
}
|
|
3362
3550
|
__name(setTelemetrySource, "setTelemetrySource");
|
|
3363
3551
|
|
|
@@ -5381,11 +5569,13 @@ var BaseMCPClient = class {
|
|
|
5381
5569
|
addServer(name, serverConfig) {
|
|
5382
5570
|
this.config.mcpServers = this.config.mcpServers || {};
|
|
5383
5571
|
this.config.mcpServers[name] = serverConfig;
|
|
5572
|
+
Tel.getInstance().trackClientAddServer(name, serverConfig);
|
|
5384
5573
|
}
|
|
5385
5574
|
removeServer(name) {
|
|
5386
5575
|
if (this.config.mcpServers?.[name]) {
|
|
5387
5576
|
delete this.config.mcpServers[name];
|
|
5388
5577
|
this.activeSessions = this.activeSessions.filter((n) => n !== name);
|
|
5578
|
+
Tel.getInstance().trackClientRemoveServer(name);
|
|
5389
5579
|
}
|
|
5390
5580
|
}
|
|
5391
5581
|
getServerNames() {
|
|
@@ -7738,7 +7928,7 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
|
|
|
7738
7928
|
const servers = Object.keys(this.config.mcpServers ?? {});
|
|
7739
7929
|
const hasSamplingCallback = !!this._samplingCallback;
|
|
7740
7930
|
const hasElicitationCallback = !!this._elicitationCallback;
|
|
7741
|
-
|
|
7931
|
+
Tel.getInstance().trackMCPClientInit({
|
|
7742
7932
|
codeMode: this.codeMode,
|
|
7743
7933
|
sandbox: false,
|
|
7744
7934
|
// Sandbox not supported in TS yet
|
|
@@ -7746,14 +7936,16 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
|
|
|
7746
7936
|
verify: false,
|
|
7747
7937
|
// No verify option in TS client
|
|
7748
7938
|
servers,
|
|
7749
|
-
numServers: servers.length
|
|
7939
|
+
numServers: servers.length,
|
|
7940
|
+
isBrowser: false
|
|
7941
|
+
// Node.js MCPClient
|
|
7750
7942
|
}).catch((e) => logger.debug(`Failed to track MCPClient init: ${e}`));
|
|
7751
7943
|
}
|
|
7752
7944
|
static fromDict(cfg, options) {
|
|
7753
7945
|
return new _MCPClient(cfg, options);
|
|
7754
7946
|
}
|
|
7755
|
-
static fromConfigFile(
|
|
7756
|
-
return new _MCPClient(loadConfigFile(
|
|
7947
|
+
static fromConfigFile(path2, options) {
|
|
7948
|
+
return new _MCPClient(loadConfigFile(path2), options);
|
|
7757
7949
|
}
|
|
7758
7950
|
/**
|
|
7759
7951
|
* Save configuration to a file (Node.js only)
|
|
@@ -8033,15 +8225,15 @@ var OAuthHelper = class {
|
|
|
8033
8225
|
// GitHub Copilot
|
|
8034
8226
|
/api\.github\.com/i,
|
|
8035
8227
|
// GitHub API
|
|
8036
|
-
/[a-z0-9-]
|
|
8037
|
-
// Google APIs
|
|
8228
|
+
/[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.googleapis\.com/i,
|
|
8229
|
+
// Google APIs (DNS-safe, max 63 chars per label)
|
|
8038
8230
|
/api\.openai\.com/i,
|
|
8039
8231
|
// OpenAI
|
|
8040
8232
|
/api\.anthropic\.com/i,
|
|
8041
8233
|
// Anthropic
|
|
8042
|
-
/[a-z0-9-]
|
|
8234
|
+
/[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.atlassian\.net/i,
|
|
8043
8235
|
// Atlassian (Jira, Confluence)
|
|
8044
|
-
/[a-z0-9-]
|
|
8236
|
+
/[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.slack\.com/i,
|
|
8045
8237
|
// Slack
|
|
8046
8238
|
/api\.notion\.com/i,
|
|
8047
8239
|
// Notion
|
|
@@ -8055,7 +8247,7 @@ var OAuthHelper = class {
|
|
|
8055
8247
|
// Local development
|
|
8056
8248
|
/\.local/i,
|
|
8057
8249
|
// Local development
|
|
8058
|
-
/mcp\.[a-z0-9-]
|
|
8250
|
+
/mcp\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.com/i
|
|
8059
8251
|
// Generic MCP server pattern (often public)
|
|
8060
8252
|
];
|
|
8061
8253
|
for (const pattern of noAuthPatterns) {
|
|
@@ -8772,6 +8964,7 @@ __name(onMcpAuthorization, "onMcpAuthorization");
|
|
|
8772
8964
|
var import_react = require("react");
|
|
8773
8965
|
|
|
8774
8966
|
// src/client/browser.ts
|
|
8967
|
+
init_logging();
|
|
8775
8968
|
var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
8776
8969
|
static {
|
|
8777
8970
|
__name(this, "BrowserMCPClient");
|
|
@@ -8785,6 +8978,25 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
|
8785
8978
|
}
|
|
8786
8979
|
constructor(config) {
|
|
8787
8980
|
super(config);
|
|
8981
|
+
this._trackClientInit();
|
|
8982
|
+
}
|
|
8983
|
+
_trackClientInit() {
|
|
8984
|
+
const servers = Object.keys(this.config.mcpServers ?? {});
|
|
8985
|
+
Tel.getInstance().trackMCPClientInit({
|
|
8986
|
+
codeMode: false,
|
|
8987
|
+
// Browser client doesn't support code mode
|
|
8988
|
+
sandbox: false,
|
|
8989
|
+
// Sandbox not supported in browser
|
|
8990
|
+
allCallbacks: false,
|
|
8991
|
+
// Will be set per-server
|
|
8992
|
+
verify: false,
|
|
8993
|
+
servers,
|
|
8994
|
+
numServers: servers.length,
|
|
8995
|
+
isBrowser: true
|
|
8996
|
+
// Browser MCPClient
|
|
8997
|
+
}).catch(
|
|
8998
|
+
(e) => logger.debug(`Failed to track BrowserMCPClient init: ${e}`)
|
|
8999
|
+
);
|
|
8788
9000
|
}
|
|
8789
9001
|
static fromDict(cfg) {
|
|
8790
9002
|
return new _BrowserMCPClient(cfg);
|
|
@@ -8963,8 +9175,20 @@ function useMcp(options) {
|
|
|
8963
9175
|
}
|
|
8964
9176
|
}
|
|
8965
9177
|
connectingRef.current = false;
|
|
9178
|
+
if (url) {
|
|
9179
|
+
Tel.getInstance().trackUseMcpConnection({
|
|
9180
|
+
url,
|
|
9181
|
+
transportType,
|
|
9182
|
+
success: false,
|
|
9183
|
+
errorType: connectionError?.name || "UnknownError",
|
|
9184
|
+
hasOAuth: !!authProviderRef.current,
|
|
9185
|
+
hasSampling: !!samplingCallback,
|
|
9186
|
+
hasElicitation: !!onElicitation
|
|
9187
|
+
}).catch(() => {
|
|
9188
|
+
});
|
|
9189
|
+
}
|
|
8966
9190
|
},
|
|
8967
|
-
[addLog]
|
|
9191
|
+
[addLog, url, transportType, samplingCallback, onElicitation]
|
|
8968
9192
|
);
|
|
8969
9193
|
const connect = (0, import_react.useCallback)(async () => {
|
|
8970
9194
|
if (!enabled || !url) {
|
|
@@ -9073,6 +9297,15 @@ function useMcp(options) {
|
|
|
9073
9297
|
);
|
|
9074
9298
|
setState("ready");
|
|
9075
9299
|
successfulTransportRef.current = transportTypeParam;
|
|
9300
|
+
Tel.getInstance().trackUseMcpConnection({
|
|
9301
|
+
url,
|
|
9302
|
+
transportType: transportTypeParam,
|
|
9303
|
+
success: true,
|
|
9304
|
+
hasOAuth: !!authProviderRef.current,
|
|
9305
|
+
hasSampling: !!samplingCallback,
|
|
9306
|
+
hasElicitation: !!onElicitation
|
|
9307
|
+
}).catch(() => {
|
|
9308
|
+
});
|
|
9076
9309
|
setTools(session.connector.tools || []);
|
|
9077
9310
|
const resourcesResult = await session.connector.listAllResources();
|
|
9078
9311
|
setResources(resourcesResult.resources || []);
|
|
@@ -9197,6 +9430,7 @@ function useMcp(options) {
|
|
|
9197
9430
|
);
|
|
9198
9431
|
}
|
|
9199
9432
|
addLog("info", `Calling tool: ${name}`, args);
|
|
9433
|
+
const startTime = Date.now();
|
|
9200
9434
|
try {
|
|
9201
9435
|
const serverName = "inspector-server";
|
|
9202
9436
|
const session = clientRef.current.getSession(serverName);
|
|
@@ -9209,9 +9443,22 @@ function useMcp(options) {
|
|
|
9209
9443
|
options2
|
|
9210
9444
|
);
|
|
9211
9445
|
addLog("info", `Tool "${name}" call successful:`, result);
|
|
9446
|
+
Tel.getInstance().trackUseMcpToolCall({
|
|
9447
|
+
toolName: name,
|
|
9448
|
+
success: true,
|
|
9449
|
+
executionTimeMs: Date.now() - startTime
|
|
9450
|
+
}).catch(() => {
|
|
9451
|
+
});
|
|
9212
9452
|
return result;
|
|
9213
9453
|
} catch (err) {
|
|
9214
9454
|
addLog("error", `Tool "${name}" call failed:`, err);
|
|
9455
|
+
Tel.getInstance().trackUseMcpToolCall({
|
|
9456
|
+
toolName: name,
|
|
9457
|
+
success: false,
|
|
9458
|
+
errorType: err instanceof Error ? err.name : "UnknownError",
|
|
9459
|
+
executionTimeMs: Date.now() - startTime
|
|
9460
|
+
}).catch(() => {
|
|
9461
|
+
});
|
|
9215
9462
|
throw err;
|
|
9216
9463
|
}
|
|
9217
9464
|
},
|
|
@@ -9361,9 +9608,20 @@ function useMcp(options) {
|
|
|
9361
9608
|
}
|
|
9362
9609
|
const result = await session.connector.readResource(uri);
|
|
9363
9610
|
addLog("info", "Resource read successful:", result);
|
|
9611
|
+
Tel.getInstance().trackUseMcpResourceRead({
|
|
9612
|
+
resourceUri: uri,
|
|
9613
|
+
success: true
|
|
9614
|
+
}).catch(() => {
|
|
9615
|
+
});
|
|
9364
9616
|
return result;
|
|
9365
9617
|
} catch (err) {
|
|
9366
9618
|
addLog("error", "Resource read failed:", err);
|
|
9619
|
+
Tel.getInstance().trackUseMcpResourceRead({
|
|
9620
|
+
resourceUri: uri,
|
|
9621
|
+
success: false,
|
|
9622
|
+
errorType: err instanceof Error ? err.name : "UnknownError"
|
|
9623
|
+
}).catch(() => {
|
|
9624
|
+
});
|
|
9367
9625
|
throw err;
|
|
9368
9626
|
}
|
|
9369
9627
|
},
|
|
@@ -10329,8 +10587,8 @@ __name(WidgetControls, "WidgetControls");
|
|
|
10329
10587
|
var import_react7 = __toESM(require("react"), 1);
|
|
10330
10588
|
function getBasename() {
|
|
10331
10589
|
if (typeof window === "undefined") return "/";
|
|
10332
|
-
const
|
|
10333
|
-
const match =
|
|
10590
|
+
const path2 = window.location.pathname;
|
|
10591
|
+
const match = path2.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);
|
|
10334
10592
|
if (match) {
|
|
10335
10593
|
return match[1];
|
|
10336
10594
|
}
|