mcp-use 1.10.0-canary.5 → 1.10.0-canary.7
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-LTA4LQTH.js → chunk-3BBYQXEN.js} +15 -1
- package/dist/{chunk-YTIDS5CQ.js → chunk-5TGZJKUB.js} +5 -5
- package/dist/{chunk-3R5PDYIN.js → chunk-7RUUAWVB.js} +1 -1
- package/dist/{chunk-F5MMLHUR.js → chunk-EVWXZWIJ.js} +1 -1
- package/dist/{chunk-L6P6GBCW.js → chunk-GPJDNLPU.js} +15 -2
- package/dist/{chunk-OTYPVJTH.js → chunk-J77Z4CRV.js} +11 -401
- package/dist/chunk-PP653GKW.js +942 -0
- package/dist/{chunk-RWH7VLXH.js → chunk-QZCF4NHP.js} +29 -12
- package/dist/index.cjs +591 -87
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -16
- package/dist/src/adapters/langchain_adapter.d.ts +1 -1
- package/dist/src/adapters/langchain_adapter.d.ts.map +1 -1
- package/dist/src/agents/index.cjs +2051 -1604
- package/dist/src/agents/index.js +4 -4
- package/dist/src/agents/mcp_agent.d.ts +5 -0
- package/dist/src/agents/mcp_agent.d.ts.map +1 -1
- package/dist/src/auth/browser-provider.d.ts +2 -2
- package/dist/src/auth/browser-provider.d.ts.map +1 -1
- package/dist/src/auth/index.cjs +1 -1
- package/dist/src/auth/index.js +1 -1
- package/dist/src/auth/types.d.ts +1 -1
- package/dist/src/auth/types.d.ts.map +1 -1
- package/dist/src/browser.cjs +3197 -2717
- package/dist/src/browser.d.ts +2 -1
- package/dist/src/browser.d.ts.map +1 -1
- package/dist/src/browser.js +10 -5
- package/dist/src/client/browser.d.ts +5 -0
- package/dist/src/client/browser.d.ts.map +1 -1
- package/dist/src/client/connectors/codeMode.d.ts +1 -1
- package/dist/src/client/connectors/codeMode.d.ts.map +1 -1
- package/dist/src/client/executors/base.d.ts +1 -1
- package/dist/src/client/executors/base.d.ts.map +1 -1
- package/dist/src/client/prompts.cjs +13 -4
- package/dist/src/client/prompts.js +3 -2
- package/dist/src/client.d.ts +7 -1
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/connectors/base.d.ts +22 -13
- package/dist/src/connectors/base.d.ts.map +1 -1
- package/dist/src/connectors/http.d.ts.map +1 -1
- package/dist/src/connectors/stdio.d.ts.map +1 -1
- package/dist/src/connectors/websocket.d.ts +1 -1
- package/dist/src/connectors/websocket.d.ts.map +1 -1
- package/dist/src/react/index.cjs +853 -25
- package/dist/src/react/index.d.ts +1 -1
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/react/index.js +5 -5
- package/dist/src/react/types.d.ts +1 -1
- package/dist/src/react/types.d.ts.map +1 -1
- package/dist/src/server/endpoints/mount-mcp.d.ts +1 -1
- package/dist/src/server/endpoints/mount-mcp.d.ts.map +1 -1
- package/dist/src/server/index.cjs +1357 -83
- package/dist/src/server/index.d.ts +1 -0
- package/dist/src/server/index.d.ts.map +1 -1
- package/dist/src/server/index.js +206 -57
- package/dist/src/server/mcp-server.d.ts +32 -7
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/dist/src/server/prompts/conversion.d.ts +1 -1
- package/dist/src/server/prompts/conversion.d.ts.map +1 -1
- package/dist/src/server/prompts/index.d.ts +1 -1
- package/dist/src/server/prompts/index.d.ts.map +1 -1
- package/dist/src/server/resources/conversion.d.ts +1 -1
- package/dist/src/server/resources/conversion.d.ts.map +1 -1
- package/dist/src/server/resources/index.d.ts +2 -2
- package/dist/src/server/resources/index.d.ts.map +1 -1
- package/dist/src/server/resources/subscriptions.d.ts +1 -1
- package/dist/src/server/resources/subscriptions.d.ts.map +1 -1
- package/dist/src/server/sessions/session-manager.d.ts +2 -2
- package/dist/src/server/sessions/session-manager.d.ts.map +1 -1
- package/dist/src/server/tools/tool-execution-helpers.d.ts +1 -1
- package/dist/src/server/tools/tool-execution-helpers.d.ts.map +1 -1
- package/dist/src/server/tools/tool-registration.d.ts +1 -1
- package/dist/src/server/tools/tool-registration.d.ts.map +1 -1
- package/dist/src/server/types/prompt.d.ts +1 -1
- package/dist/src/server/types/prompt.d.ts.map +1 -1
- package/dist/src/server/types/resource.d.ts +1 -1
- package/dist/src/server/types/resource.d.ts.map +1 -1
- package/dist/src/server/types/tool-context.d.ts +1 -1
- package/dist/src/server/types/tool-context.d.ts.map +1 -1
- package/dist/src/server/types/tool.d.ts +1 -1
- package/dist/src/server/types/tool.d.ts.map +1 -1
- package/dist/src/server/utils/response-helpers.d.ts +1 -1
- 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/session.d.ts +2 -2
- package/dist/src/session.d.ts.map +1 -1
- package/dist/src/task_managers/sse.d.ts +2 -2
- package/dist/src/task_managers/sse.d.ts.map +1 -1
- package/dist/src/task_managers/stdio.d.ts +2 -2
- package/dist/src/task_managers/stdio.d.ts.map +1 -1
- package/dist/src/task_managers/streamable_http.d.ts +2 -2
- package/dist/src/task_managers/streamable_http.d.ts.map +1 -1
- package/dist/src/telemetry/events.d.ts +219 -0
- package/dist/src/telemetry/events.d.ts.map +1 -1
- package/dist/src/telemetry/index.d.ts +2 -2
- package/dist/src/telemetry/index.d.ts.map +1 -1
- package/dist/src/telemetry/telemetry.d.ts +56 -1
- package/dist/src/telemetry/telemetry.d.ts.map +1 -1
- package/dist/src/telemetry/utils.d.ts +1 -1
- package/dist/src/telemetry/utils.d.ts.map +1 -1
- package/dist/src/version.d.ts +8 -0
- package/dist/src/version.d.ts.map +1 -0
- package/dist/{tool-execution-helpers-2LGVSS7L.js → tool-execution-helpers-PU3NN3NL.js} +3 -2
- package/dist/tsup.config.d.ts.map +1 -1
- package/package.json +6 -5
- package/dist/chunk-MTHLLDCX.js +0 -97
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 fs3 = await import("fs");
|
|
39
|
+
const path3 = await import("path");
|
|
40
|
+
return { fs: fs3.default, path: path3.default };
|
|
41
41
|
} catch {
|
|
42
42
|
return { fs: null, path: null };
|
|
43
43
|
}
|
|
@@ -1078,11 +1078,13 @@ __export(index_exports, {
|
|
|
1078
1078
|
StdioConnector: () => StdioConnector,
|
|
1079
1079
|
Telemetry: () => Telemetry,
|
|
1080
1080
|
ThemeProvider: () => ThemeProvider,
|
|
1081
|
+
VERSION: () => VERSION,
|
|
1081
1082
|
VMCodeExecutor: () => VMCodeExecutor,
|
|
1082
1083
|
WebSocketConnector: () => WebSocketConnector,
|
|
1083
1084
|
WidgetControls: () => WidgetControls,
|
|
1084
1085
|
createOAuthMCPConfig: () => createOAuthMCPConfig,
|
|
1085
1086
|
createReadableStreamFromGenerator: () => createReadableStreamFromGenerator,
|
|
1087
|
+
getPackageVersion: () => getPackageVersion,
|
|
1086
1088
|
isVMAvailable: () => isVMAvailable,
|
|
1087
1089
|
loadConfigFile: () => loadConfigFile,
|
|
1088
1090
|
logger: () => logger,
|
|
@@ -2513,9 +2515,9 @@ var ObservabilityManager = class {
|
|
|
2513
2515
|
};
|
|
2514
2516
|
|
|
2515
2517
|
// src/telemetry/telemetry.ts
|
|
2516
|
-
var
|
|
2518
|
+
var fs = __toESM(require("fs"), 1);
|
|
2517
2519
|
var os = __toESM(require("os"), 1);
|
|
2518
|
-
var
|
|
2520
|
+
var path = __toESM(require("path"), 1);
|
|
2519
2521
|
var import_posthog_node = require("posthog-node");
|
|
2520
2522
|
|
|
2521
2523
|
// src/server/utils/runtime.ts
|
|
@@ -2578,23 +2580,265 @@ var MCPAgentExecutionEvent = class extends BaseTelemetryEvent {
|
|
|
2578
2580
|
};
|
|
2579
2581
|
}
|
|
2580
2582
|
};
|
|
2583
|
+
function createServerRunEventData(server, transport) {
|
|
2584
|
+
const toolRegistrations = Array.from(server.registrations.tools.values());
|
|
2585
|
+
const promptRegistrations = Array.from(server.registrations.prompts.values());
|
|
2586
|
+
const resourceRegistrations = Array.from(
|
|
2587
|
+
server.registrations.resources.values()
|
|
2588
|
+
);
|
|
2589
|
+
const templateRegistrations = Array.from(
|
|
2590
|
+
server.registrations.resourceTemplates.values()
|
|
2591
|
+
);
|
|
2592
|
+
const allResources = resourceRegistrations.map((r) => ({
|
|
2593
|
+
name: r.config.name,
|
|
2594
|
+
title: r.config.title ?? null,
|
|
2595
|
+
description: r.config.description ?? null,
|
|
2596
|
+
uri: r.config.uri ?? null,
|
|
2597
|
+
mime_type: r.config.mimeType ?? null
|
|
2598
|
+
}));
|
|
2599
|
+
const appsSdkResources = allResources.filter(
|
|
2600
|
+
(r) => r.mime_type === "text/html+skybridge"
|
|
2601
|
+
);
|
|
2602
|
+
const mcpUiResources = allResources.filter(
|
|
2603
|
+
(r) => r.mime_type === "text/uri-list" || r.mime_type === "text/html"
|
|
2604
|
+
);
|
|
2605
|
+
const mcpAppsResources = allResources.filter(
|
|
2606
|
+
(r) => r.mime_type === "text/html+mcp"
|
|
2607
|
+
);
|
|
2608
|
+
return {
|
|
2609
|
+
transport,
|
|
2610
|
+
toolsNumber: server.registeredTools.length,
|
|
2611
|
+
resourcesNumber: server.registeredResources.length,
|
|
2612
|
+
promptsNumber: server.registeredPrompts.length,
|
|
2613
|
+
auth: !!server.oauthProvider,
|
|
2614
|
+
name: server.config.name,
|
|
2615
|
+
description: server.config.description ?? null,
|
|
2616
|
+
baseUrl: server.serverBaseUrl ?? null,
|
|
2617
|
+
toolNames: server.registeredTools.length > 0 ? server.registeredTools : null,
|
|
2618
|
+
resourceNames: server.registeredResources.length > 0 ? server.registeredResources : null,
|
|
2619
|
+
promptNames: server.registeredPrompts.length > 0 ? server.registeredPrompts : null,
|
|
2620
|
+
tools: toolRegistrations.length > 0 ? toolRegistrations.map((r) => ({
|
|
2621
|
+
name: r.config.name,
|
|
2622
|
+
title: r.config.title ?? null,
|
|
2623
|
+
description: r.config.description ?? null,
|
|
2624
|
+
input_schema: r.config.schema ? JSON.stringify(r.config.schema) : null,
|
|
2625
|
+
output_schema: r.config.outputSchema ? JSON.stringify(r.config.outputSchema) : null
|
|
2626
|
+
})) : null,
|
|
2627
|
+
resources: allResources.length > 0 ? allResources : null,
|
|
2628
|
+
prompts: promptRegistrations.length > 0 ? promptRegistrations.map((r) => ({
|
|
2629
|
+
name: r.config.name,
|
|
2630
|
+
title: r.config.title ?? null,
|
|
2631
|
+
description: r.config.description ?? null,
|
|
2632
|
+
args: r.config.args ? JSON.stringify(r.config.args) : null
|
|
2633
|
+
})) : null,
|
|
2634
|
+
templates: templateRegistrations.length > 0 ? templateRegistrations.map((r) => ({
|
|
2635
|
+
name: r.config.name,
|
|
2636
|
+
title: r.config.title ?? null,
|
|
2637
|
+
description: r.config.description ?? null
|
|
2638
|
+
})) : null,
|
|
2639
|
+
capabilities: {
|
|
2640
|
+
logging: true,
|
|
2641
|
+
resources: { subscribe: true, listChanged: true }
|
|
2642
|
+
},
|
|
2643
|
+
appsSdkResources: appsSdkResources.length > 0 ? appsSdkResources : null,
|
|
2644
|
+
appsSdkResourcesNumber: appsSdkResources.length,
|
|
2645
|
+
mcpUiResources: mcpUiResources.length > 0 ? mcpUiResources : null,
|
|
2646
|
+
mcpUiResourcesNumber: mcpUiResources.length,
|
|
2647
|
+
mcpAppsResources: mcpAppsResources.length > 0 ? mcpAppsResources : null,
|
|
2648
|
+
mcpAppsResourcesNumber: mcpAppsResources.length
|
|
2649
|
+
};
|
|
2650
|
+
}
|
|
2651
|
+
__name(createServerRunEventData, "createServerRunEventData");
|
|
2652
|
+
var ServerRunEvent = class extends BaseTelemetryEvent {
|
|
2653
|
+
constructor(data) {
|
|
2654
|
+
super();
|
|
2655
|
+
this.data = data;
|
|
2656
|
+
}
|
|
2657
|
+
static {
|
|
2658
|
+
__name(this, "ServerRunEvent");
|
|
2659
|
+
}
|
|
2660
|
+
get name() {
|
|
2661
|
+
return "server_run";
|
|
2662
|
+
}
|
|
2663
|
+
get properties() {
|
|
2664
|
+
return {
|
|
2665
|
+
transport: this.data.transport,
|
|
2666
|
+
tools_number: this.data.toolsNumber,
|
|
2667
|
+
resources_number: this.data.resourcesNumber,
|
|
2668
|
+
prompts_number: this.data.promptsNumber,
|
|
2669
|
+
auth: this.data.auth,
|
|
2670
|
+
name: this.data.name,
|
|
2671
|
+
description: this.data.description ?? null,
|
|
2672
|
+
base_url: this.data.baseUrl ?? null,
|
|
2673
|
+
tool_names: this.data.toolNames ?? null,
|
|
2674
|
+
resource_names: this.data.resourceNames ?? null,
|
|
2675
|
+
prompt_names: this.data.promptNames ?? null,
|
|
2676
|
+
tools: this.data.tools ?? null,
|
|
2677
|
+
resources: this.data.resources ?? null,
|
|
2678
|
+
prompts: this.data.prompts ?? null,
|
|
2679
|
+
templates: this.data.templates ?? null,
|
|
2680
|
+
capabilities: this.data.capabilities ? JSON.stringify(this.data.capabilities) : null,
|
|
2681
|
+
apps_sdk_resources: this.data.appsSdkResources ? JSON.stringify(this.data.appsSdkResources) : null,
|
|
2682
|
+
apps_sdk_resources_number: this.data.appsSdkResourcesNumber ?? 0,
|
|
2683
|
+
mcp_ui_resources: this.data.mcpUiResources ? JSON.stringify(this.data.mcpUiResources) : null,
|
|
2684
|
+
mcp_ui_resources_number: this.data.mcpUiResourcesNumber ?? 0,
|
|
2685
|
+
mcp_apps_resources: this.data.mcpAppsResources ? JSON.stringify(this.data.mcpAppsResources) : null,
|
|
2686
|
+
mcp_apps_resources_number: this.data.mcpAppsResourcesNumber ?? 0
|
|
2687
|
+
};
|
|
2688
|
+
}
|
|
2689
|
+
};
|
|
2690
|
+
var ServerInitializeEvent = class extends BaseTelemetryEvent {
|
|
2691
|
+
constructor(data) {
|
|
2692
|
+
super();
|
|
2693
|
+
this.data = data;
|
|
2694
|
+
}
|
|
2695
|
+
static {
|
|
2696
|
+
__name(this, "ServerInitializeEvent");
|
|
2697
|
+
}
|
|
2698
|
+
get name() {
|
|
2699
|
+
return "server_initialize_call";
|
|
2700
|
+
}
|
|
2701
|
+
get properties() {
|
|
2702
|
+
return {
|
|
2703
|
+
protocol_version: this.data.protocolVersion,
|
|
2704
|
+
client_info: JSON.stringify(this.data.clientInfo),
|
|
2705
|
+
client_capabilities: JSON.stringify(this.data.clientCapabilities),
|
|
2706
|
+
session_id: this.data.sessionId ?? null
|
|
2707
|
+
};
|
|
2708
|
+
}
|
|
2709
|
+
};
|
|
2710
|
+
var ServerToolCallEvent = class extends BaseTelemetryEvent {
|
|
2711
|
+
constructor(data) {
|
|
2712
|
+
super();
|
|
2713
|
+
this.data = data;
|
|
2714
|
+
}
|
|
2715
|
+
static {
|
|
2716
|
+
__name(this, "ServerToolCallEvent");
|
|
2717
|
+
}
|
|
2718
|
+
get name() {
|
|
2719
|
+
return "server_tool_call";
|
|
2720
|
+
}
|
|
2721
|
+
get properties() {
|
|
2722
|
+
return {
|
|
2723
|
+
tool_name: this.data.toolName,
|
|
2724
|
+
length_input_argument: this.data.lengthInputArgument,
|
|
2725
|
+
success: this.data.success,
|
|
2726
|
+
error_type: this.data.errorType ?? null,
|
|
2727
|
+
execution_time_ms: this.data.executionTimeMs ?? null
|
|
2728
|
+
};
|
|
2729
|
+
}
|
|
2730
|
+
};
|
|
2731
|
+
var ServerResourceCallEvent = class extends BaseTelemetryEvent {
|
|
2732
|
+
constructor(data) {
|
|
2733
|
+
super();
|
|
2734
|
+
this.data = data;
|
|
2735
|
+
}
|
|
2736
|
+
static {
|
|
2737
|
+
__name(this, "ServerResourceCallEvent");
|
|
2738
|
+
}
|
|
2739
|
+
get name() {
|
|
2740
|
+
return "server_resource_call";
|
|
2741
|
+
}
|
|
2742
|
+
get properties() {
|
|
2743
|
+
return {
|
|
2744
|
+
name: this.data.name,
|
|
2745
|
+
description: this.data.description,
|
|
2746
|
+
contents: this.data.contents,
|
|
2747
|
+
success: this.data.success,
|
|
2748
|
+
error_type: this.data.errorType ?? null
|
|
2749
|
+
};
|
|
2750
|
+
}
|
|
2751
|
+
};
|
|
2752
|
+
var ServerPromptCallEvent = class extends BaseTelemetryEvent {
|
|
2753
|
+
constructor(data) {
|
|
2754
|
+
super();
|
|
2755
|
+
this.data = data;
|
|
2756
|
+
}
|
|
2757
|
+
static {
|
|
2758
|
+
__name(this, "ServerPromptCallEvent");
|
|
2759
|
+
}
|
|
2760
|
+
get name() {
|
|
2761
|
+
return "server_prompt_call";
|
|
2762
|
+
}
|
|
2763
|
+
get properties() {
|
|
2764
|
+
return {
|
|
2765
|
+
name: this.data.name,
|
|
2766
|
+
description: this.data.description,
|
|
2767
|
+
success: this.data.success,
|
|
2768
|
+
error_type: this.data.errorType ?? null
|
|
2769
|
+
};
|
|
2770
|
+
}
|
|
2771
|
+
};
|
|
2772
|
+
var ServerContextEvent = class extends BaseTelemetryEvent {
|
|
2773
|
+
constructor(data) {
|
|
2774
|
+
super();
|
|
2775
|
+
this.data = data;
|
|
2776
|
+
}
|
|
2777
|
+
static {
|
|
2778
|
+
__name(this, "ServerContextEvent");
|
|
2779
|
+
}
|
|
2780
|
+
get name() {
|
|
2781
|
+
return `server_context_${this.data.contextType}`;
|
|
2782
|
+
}
|
|
2783
|
+
get properties() {
|
|
2784
|
+
return {
|
|
2785
|
+
context_type: this.data.contextType,
|
|
2786
|
+
notification_type: this.data.notificationType ?? null
|
|
2787
|
+
};
|
|
2788
|
+
}
|
|
2789
|
+
};
|
|
2790
|
+
var MCPClientInitEvent = class extends BaseTelemetryEvent {
|
|
2791
|
+
constructor(data) {
|
|
2792
|
+
super();
|
|
2793
|
+
this.data = data;
|
|
2794
|
+
}
|
|
2795
|
+
static {
|
|
2796
|
+
__name(this, "MCPClientInitEvent");
|
|
2797
|
+
}
|
|
2798
|
+
get name() {
|
|
2799
|
+
return "mcpclient_init";
|
|
2800
|
+
}
|
|
2801
|
+
get properties() {
|
|
2802
|
+
return {
|
|
2803
|
+
code_mode: this.data.codeMode,
|
|
2804
|
+
sandbox: this.data.sandbox,
|
|
2805
|
+
all_callbacks: this.data.allCallbacks,
|
|
2806
|
+
verify: this.data.verify,
|
|
2807
|
+
servers: this.data.servers,
|
|
2808
|
+
num_servers: this.data.numServers
|
|
2809
|
+
};
|
|
2810
|
+
}
|
|
2811
|
+
};
|
|
2812
|
+
var ConnectorInitEvent = class extends BaseTelemetryEvent {
|
|
2813
|
+
constructor(data) {
|
|
2814
|
+
super();
|
|
2815
|
+
this.data = data;
|
|
2816
|
+
}
|
|
2817
|
+
static {
|
|
2818
|
+
__name(this, "ConnectorInitEvent");
|
|
2819
|
+
}
|
|
2820
|
+
get name() {
|
|
2821
|
+
return "connector_init";
|
|
2822
|
+
}
|
|
2823
|
+
get properties() {
|
|
2824
|
+
return {
|
|
2825
|
+
connector_type: this.data.connectorType,
|
|
2826
|
+
server_command: this.data.serverCommand ?? null,
|
|
2827
|
+
server_args: this.data.serverArgs ?? null,
|
|
2828
|
+
server_url: this.data.serverUrl ?? null,
|
|
2829
|
+
public_identifier: this.data.publicIdentifier ?? null
|
|
2830
|
+
};
|
|
2831
|
+
}
|
|
2832
|
+
};
|
|
2581
2833
|
|
|
2582
|
-
// src/
|
|
2583
|
-
var
|
|
2584
|
-
var path = __toESM(require("path"), 1);
|
|
2834
|
+
// src/version.ts
|
|
2835
|
+
var VERSION = "1.10.0-canary.7";
|
|
2585
2836
|
function getPackageVersion() {
|
|
2586
|
-
|
|
2587
|
-
if (typeof __dirname === "undefined" || typeof fs === "undefined") {
|
|
2588
|
-
return "unknown";
|
|
2589
|
-
}
|
|
2590
|
-
const packagePath = path.join(__dirname, "../../package.json");
|
|
2591
|
-
const packageJson = JSON.parse(fs.readFileSync(packagePath, "utf-8"));
|
|
2592
|
-
return packageJson.version || "unknown";
|
|
2593
|
-
} catch {
|
|
2594
|
-
return "unknown";
|
|
2595
|
-
}
|
|
2837
|
+
return VERSION;
|
|
2596
2838
|
}
|
|
2597
2839
|
__name(getPackageVersion, "getPackageVersion");
|
|
2840
|
+
|
|
2841
|
+
// src/telemetry/utils.ts
|
|
2598
2842
|
function getModelProvider(llm) {
|
|
2599
2843
|
return llm._llm_type || llm.constructor.name.toLowerCase();
|
|
2600
2844
|
}
|
|
@@ -2627,21 +2871,67 @@ function extractModelInfo(llm) {
|
|
|
2627
2871
|
__name(extractModelInfo, "extractModelInfo");
|
|
2628
2872
|
|
|
2629
2873
|
// src/telemetry/telemetry.ts
|
|
2630
|
-
|
|
2874
|
+
var USER_ID_STORAGE_KEY = "mcp_use_user_id";
|
|
2875
|
+
function detectRuntimeEnvironment() {
|
|
2631
2876
|
try {
|
|
2877
|
+
if (typeof globalThis.Bun !== "undefined") {
|
|
2878
|
+
return "bun";
|
|
2879
|
+
}
|
|
2880
|
+
if (typeof globalThis.Deno !== "undefined") {
|
|
2881
|
+
return "deno";
|
|
2882
|
+
}
|
|
2632
2883
|
if (typeof navigator !== "undefined" && navigator.userAgent?.includes("Cloudflare-Workers")) {
|
|
2633
|
-
return
|
|
2884
|
+
return "cloudflare-workers";
|
|
2634
2885
|
}
|
|
2635
|
-
if (typeof globalThis.EdgeRuntime !== "undefined"
|
|
2636
|
-
return
|
|
2886
|
+
if (typeof globalThis.EdgeRuntime !== "undefined") {
|
|
2887
|
+
return "edge";
|
|
2637
2888
|
}
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2889
|
+
if (typeof process !== "undefined" && typeof process.versions?.node !== "undefined" && typeof fs !== "undefined" && typeof fs.existsSync === "function") {
|
|
2890
|
+
return "node";
|
|
2891
|
+
}
|
|
2892
|
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
2893
|
+
return "browser";
|
|
2894
|
+
}
|
|
2895
|
+
return "unknown";
|
|
2641
2896
|
} catch {
|
|
2642
|
-
return
|
|
2897
|
+
return "unknown";
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
__name(detectRuntimeEnvironment, "detectRuntimeEnvironment");
|
|
2901
|
+
function getStorageCapability(env) {
|
|
2902
|
+
switch (env) {
|
|
2903
|
+
case "node":
|
|
2904
|
+
case "bun":
|
|
2905
|
+
return "filesystem";
|
|
2906
|
+
case "browser":
|
|
2907
|
+
try {
|
|
2908
|
+
if (typeof localStorage !== "undefined") {
|
|
2909
|
+
localStorage.setItem("__mcp_use_test__", "1");
|
|
2910
|
+
localStorage.removeItem("__mcp_use_test__");
|
|
2911
|
+
return "localStorage";
|
|
2912
|
+
}
|
|
2913
|
+
} catch {
|
|
2914
|
+
}
|
|
2915
|
+
return "session-only";
|
|
2916
|
+
case "deno":
|
|
2917
|
+
return "session-only";
|
|
2918
|
+
default:
|
|
2919
|
+
return "session-only";
|
|
2643
2920
|
}
|
|
2644
2921
|
}
|
|
2922
|
+
__name(getStorageCapability, "getStorageCapability");
|
|
2923
|
+
var cachedEnvironment = null;
|
|
2924
|
+
function getRuntimeEnvironment() {
|
|
2925
|
+
if (cachedEnvironment === null) {
|
|
2926
|
+
cachedEnvironment = detectRuntimeEnvironment();
|
|
2927
|
+
}
|
|
2928
|
+
return cachedEnvironment;
|
|
2929
|
+
}
|
|
2930
|
+
__name(getRuntimeEnvironment, "getRuntimeEnvironment");
|
|
2931
|
+
function isNodeJSEnvironment2() {
|
|
2932
|
+
const env = getRuntimeEnvironment();
|
|
2933
|
+
return env === "node" || env === "bun";
|
|
2934
|
+
}
|
|
2645
2935
|
__name(isNodeJSEnvironment2, "isNodeJSEnvironment");
|
|
2646
2936
|
var ScarfEventLogger = class {
|
|
2647
2937
|
static {
|
|
@@ -2679,7 +2969,7 @@ function getCacheHome() {
|
|
|
2679
2969
|
return "/tmp/mcp_use_cache";
|
|
2680
2970
|
}
|
|
2681
2971
|
const envVar = process.env.XDG_CACHE_HOME;
|
|
2682
|
-
if (envVar &&
|
|
2972
|
+
if (envVar && path.isAbsolute(envVar)) {
|
|
2683
2973
|
return envVar;
|
|
2684
2974
|
}
|
|
2685
2975
|
const platform = process.platform;
|
|
@@ -2689,11 +2979,11 @@ function getCacheHome() {
|
|
|
2689
2979
|
if (appdata) {
|
|
2690
2980
|
return appdata;
|
|
2691
2981
|
}
|
|
2692
|
-
return
|
|
2982
|
+
return path.join(homeDir, "AppData", "Local");
|
|
2693
2983
|
} else if (platform === "darwin") {
|
|
2694
|
-
return
|
|
2984
|
+
return path.join(homeDir, "Library", "Caches");
|
|
2695
2985
|
} else {
|
|
2696
|
-
return
|
|
2986
|
+
return path.join(homeDir, ".cache");
|
|
2697
2987
|
}
|
|
2698
2988
|
}
|
|
2699
2989
|
__name(getCacheHome, "getCacheHome");
|
|
@@ -2702,12 +2992,12 @@ var Telemetry = class _Telemetry {
|
|
|
2702
2992
|
__name(this, "Telemetry");
|
|
2703
2993
|
}
|
|
2704
2994
|
static instance = null;
|
|
2705
|
-
USER_ID_PATH =
|
|
2995
|
+
USER_ID_PATH = path.join(
|
|
2706
2996
|
getCacheHome(),
|
|
2707
2997
|
"mcp_use_3",
|
|
2708
2998
|
"telemetry_user_id"
|
|
2709
2999
|
);
|
|
2710
|
-
VERSION_DOWNLOAD_PATH =
|
|
3000
|
+
VERSION_DOWNLOAD_PATH = path.join(
|
|
2711
3001
|
getCacheHome(),
|
|
2712
3002
|
"mcp_use",
|
|
2713
3003
|
"download_version"
|
|
@@ -2719,32 +3009,53 @@ var Telemetry = class _Telemetry {
|
|
|
2719
3009
|
_currUserId = null;
|
|
2720
3010
|
_posthogClient = null;
|
|
2721
3011
|
_scarfClient = null;
|
|
2722
|
-
|
|
3012
|
+
_runtimeEnvironment;
|
|
3013
|
+
_storageCapability;
|
|
3014
|
+
_source;
|
|
2723
3015
|
constructor() {
|
|
2724
|
-
|
|
3016
|
+
this._runtimeEnvironment = getRuntimeEnvironment();
|
|
3017
|
+
this._storageCapability = getStorageCapability(this._runtimeEnvironment);
|
|
3018
|
+
this._source = typeof process !== "undefined" && process.env?.MCP_USE_TELEMETRY_SOURCE || this._runtimeEnvironment;
|
|
2725
3019
|
const telemetryDisabled = typeof process !== "undefined" && process.env?.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase() === "false" || false;
|
|
2726
|
-
|
|
3020
|
+
const canSupportTelemetry = this._runtimeEnvironment !== "unknown";
|
|
3021
|
+
const isServerlessEnvironment = [
|
|
3022
|
+
"cloudflare-workers",
|
|
3023
|
+
"edge",
|
|
3024
|
+
"deno"
|
|
3025
|
+
].includes(this._runtimeEnvironment);
|
|
2727
3026
|
if (telemetryDisabled) {
|
|
2728
3027
|
this._posthogClient = null;
|
|
2729
3028
|
this._scarfClient = null;
|
|
2730
3029
|
logger.debug("Telemetry disabled via environment variable");
|
|
2731
|
-
} else if (!
|
|
3030
|
+
} else if (!canSupportTelemetry) {
|
|
2732
3031
|
this._posthogClient = null;
|
|
2733
3032
|
this._scarfClient = null;
|
|
2734
3033
|
logger.debug(
|
|
2735
|
-
|
|
3034
|
+
`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`
|
|
2736
3035
|
);
|
|
2737
3036
|
} else {
|
|
2738
3037
|
logger.info(
|
|
2739
3038
|
"Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."
|
|
2740
3039
|
);
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
3040
|
+
if (this._runtimeEnvironment !== "browser") {
|
|
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 {
|
|
2748
3059
|
this._posthogClient = null;
|
|
2749
3060
|
}
|
|
2750
3061
|
try {
|
|
@@ -2755,6 +3066,18 @@ var Telemetry = class _Telemetry {
|
|
|
2755
3066
|
}
|
|
2756
3067
|
}
|
|
2757
3068
|
}
|
|
3069
|
+
/**
|
|
3070
|
+
* Get the detected runtime environment
|
|
3071
|
+
*/
|
|
3072
|
+
get runtimeEnvironment() {
|
|
3073
|
+
return this._runtimeEnvironment;
|
|
3074
|
+
}
|
|
3075
|
+
/**
|
|
3076
|
+
* Get the storage capability for this environment
|
|
3077
|
+
*/
|
|
3078
|
+
get storageCapability() {
|
|
3079
|
+
return this._storageCapability;
|
|
3080
|
+
}
|
|
2758
3081
|
static getInstance() {
|
|
2759
3082
|
if (!_Telemetry.instance) {
|
|
2760
3083
|
_Telemetry.instance = new _Telemetry();
|
|
@@ -2776,36 +3099,80 @@ var Telemetry = class _Telemetry {
|
|
|
2776
3099
|
getSource() {
|
|
2777
3100
|
return this._source;
|
|
2778
3101
|
}
|
|
3102
|
+
/**
|
|
3103
|
+
* Check if telemetry is enabled.
|
|
3104
|
+
* Returns false if telemetry was disabled via environment variable or if not in Node.js environment.
|
|
3105
|
+
*/
|
|
3106
|
+
get isEnabled() {
|
|
3107
|
+
return this._posthogClient !== null || this._scarfClient !== null;
|
|
3108
|
+
}
|
|
2779
3109
|
get userId() {
|
|
2780
3110
|
if (this._currUserId) {
|
|
2781
3111
|
return this._currUserId;
|
|
2782
3112
|
}
|
|
2783
|
-
if (!isNodeJSEnvironment2()) {
|
|
2784
|
-
this._currUserId = this.UNKNOWN_USER_ID;
|
|
2785
|
-
return this._currUserId;
|
|
2786
|
-
}
|
|
2787
3113
|
try {
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
3114
|
+
switch (this._storageCapability) {
|
|
3115
|
+
case "filesystem":
|
|
3116
|
+
this._currUserId = this.getUserIdFromFilesystem();
|
|
3117
|
+
break;
|
|
3118
|
+
case "localStorage":
|
|
3119
|
+
this._currUserId = this.getUserIdFromLocalStorage();
|
|
3120
|
+
break;
|
|
3121
|
+
case "session-only":
|
|
3122
|
+
default:
|
|
3123
|
+
this._currUserId = `session-${generateUUID()}`;
|
|
3124
|
+
logger.debug(
|
|
3125
|
+
`Using session-based user ID (${this._runtimeEnvironment} environment)`
|
|
3126
|
+
);
|
|
3127
|
+
break;
|
|
3128
|
+
}
|
|
3129
|
+
if (this._storageCapability === "filesystem" && this._currUserId) {
|
|
3130
|
+
this.trackPackageDownloadInternal(this._currUserId, {
|
|
3131
|
+
triggered_by: "user_id_property"
|
|
3132
|
+
}).catch((e) => logger.debug(`Failed to track package download: ${e}`));
|
|
2798
3133
|
}
|
|
2799
|
-
this.trackPackageDownload({
|
|
2800
|
-
triggered_by: "user_id_property"
|
|
2801
|
-
}).catch((e) => logger.debug(`Failed to track package download: ${e}`));
|
|
2802
3134
|
} catch (e) {
|
|
2803
3135
|
logger.debug(`Failed to get/create user ID: ${e}`);
|
|
2804
3136
|
this._currUserId = this.UNKNOWN_USER_ID;
|
|
2805
3137
|
}
|
|
2806
3138
|
return this._currUserId;
|
|
2807
3139
|
}
|
|
3140
|
+
/**
|
|
3141
|
+
* Get or create user ID from filesystem (Node.js/Bun)
|
|
3142
|
+
*/
|
|
3143
|
+
getUserIdFromFilesystem() {
|
|
3144
|
+
const isFirstTime = !fs.existsSync(this.USER_ID_PATH);
|
|
3145
|
+
if (isFirstTime) {
|
|
3146
|
+
logger.debug(`Creating user ID path: ${this.USER_ID_PATH}`);
|
|
3147
|
+
fs.mkdirSync(path.dirname(this.USER_ID_PATH), { recursive: true });
|
|
3148
|
+
const newUserId = generateUUID();
|
|
3149
|
+
fs.writeFileSync(this.USER_ID_PATH, newUserId);
|
|
3150
|
+
logger.debug(`User ID path created: ${this.USER_ID_PATH}`);
|
|
3151
|
+
return newUserId;
|
|
3152
|
+
}
|
|
3153
|
+
return fs.readFileSync(this.USER_ID_PATH, "utf-8").trim();
|
|
3154
|
+
}
|
|
3155
|
+
/**
|
|
3156
|
+
* Get or create user ID from localStorage (Browser)
|
|
3157
|
+
*/
|
|
3158
|
+
getUserIdFromLocalStorage() {
|
|
3159
|
+
try {
|
|
3160
|
+
let userId = localStorage.getItem(USER_ID_STORAGE_KEY);
|
|
3161
|
+
if (!userId) {
|
|
3162
|
+
userId = generateUUID();
|
|
3163
|
+
localStorage.setItem(USER_ID_STORAGE_KEY, userId);
|
|
3164
|
+
logger.debug(`Created new browser user ID`);
|
|
3165
|
+
}
|
|
3166
|
+
return userId;
|
|
3167
|
+
} catch (e) {
|
|
3168
|
+
logger.debug(`localStorage access failed: ${e}`);
|
|
3169
|
+
return `session-${generateUUID()}`;
|
|
3170
|
+
}
|
|
3171
|
+
}
|
|
2808
3172
|
async capture(event) {
|
|
3173
|
+
logger.debug(
|
|
3174
|
+
`CAPTURE: posthog: ${this._posthogClient !== null}, scarf: ${this._scarfClient !== null}`
|
|
3175
|
+
);
|
|
2809
3176
|
if (!this._posthogClient && !this._scarfClient) {
|
|
2810
3177
|
return;
|
|
2811
3178
|
}
|
|
@@ -2815,6 +3182,11 @@ var Telemetry = class _Telemetry {
|
|
|
2815
3182
|
properties.mcp_use_version = getPackageVersion();
|
|
2816
3183
|
properties.language = "typescript";
|
|
2817
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
|
+
);
|
|
2818
3190
|
this._posthogClient.capture({
|
|
2819
3191
|
distinctId: this.userId,
|
|
2820
3192
|
event: event.name,
|
|
@@ -2832,36 +3204,48 @@ var Telemetry = class _Telemetry {
|
|
|
2832
3204
|
properties.event = event.name;
|
|
2833
3205
|
properties.language = "typescript";
|
|
2834
3206
|
properties.source = this._source;
|
|
3207
|
+
properties.runtime = this._runtimeEnvironment;
|
|
2835
3208
|
await this._scarfClient.logEvent(properties);
|
|
2836
3209
|
} catch (e) {
|
|
2837
3210
|
logger.debug(`Failed to track Scarf event ${event.name}: ${e}`);
|
|
2838
3211
|
}
|
|
2839
3212
|
}
|
|
2840
3213
|
}
|
|
3214
|
+
/**
|
|
3215
|
+
* Track package download event.
|
|
3216
|
+
* This is a public wrapper that safely accesses userId.
|
|
3217
|
+
*/
|
|
2841
3218
|
async trackPackageDownload(properties) {
|
|
3219
|
+
return this.trackPackageDownloadInternal(this.userId, properties);
|
|
3220
|
+
}
|
|
3221
|
+
/**
|
|
3222
|
+
* Internal method to track package download with explicit userId.
|
|
3223
|
+
* This avoids circular dependency when called from the userId getter.
|
|
3224
|
+
*/
|
|
3225
|
+
async trackPackageDownloadInternal(userId, properties) {
|
|
2842
3226
|
if (!this._scarfClient) {
|
|
2843
3227
|
return;
|
|
2844
3228
|
}
|
|
2845
|
-
if (
|
|
3229
|
+
if (this._storageCapability !== "filesystem") {
|
|
2846
3230
|
return;
|
|
2847
3231
|
}
|
|
2848
3232
|
try {
|
|
2849
3233
|
const currentVersion = getPackageVersion();
|
|
2850
3234
|
let shouldTrack = false;
|
|
2851
3235
|
let firstDownload = false;
|
|
2852
|
-
if (!
|
|
3236
|
+
if (!fs.existsSync(this.VERSION_DOWNLOAD_PATH)) {
|
|
2853
3237
|
shouldTrack = true;
|
|
2854
3238
|
firstDownload = true;
|
|
2855
|
-
|
|
3239
|
+
fs.mkdirSync(path.dirname(this.VERSION_DOWNLOAD_PATH), {
|
|
2856
3240
|
recursive: true
|
|
2857
3241
|
});
|
|
2858
|
-
|
|
3242
|
+
fs.writeFileSync(this.VERSION_DOWNLOAD_PATH, currentVersion);
|
|
2859
3243
|
} else {
|
|
2860
|
-
const savedVersion =
|
|
3244
|
+
const savedVersion = fs.readFileSync(this.VERSION_DOWNLOAD_PATH, "utf-8").trim();
|
|
2861
3245
|
if (currentVersion > savedVersion) {
|
|
2862
3246
|
shouldTrack = true;
|
|
2863
3247
|
firstDownload = false;
|
|
2864
|
-
|
|
3248
|
+
fs.writeFileSync(this.VERSION_DOWNLOAD_PATH, currentVersion);
|
|
2865
3249
|
}
|
|
2866
3250
|
}
|
|
2867
3251
|
if (shouldTrack) {
|
|
@@ -2870,21 +3254,79 @@ var Telemetry = class _Telemetry {
|
|
|
2870
3254
|
);
|
|
2871
3255
|
const eventProperties = { ...properties || {} };
|
|
2872
3256
|
eventProperties.mcp_use_version = currentVersion;
|
|
2873
|
-
eventProperties.user_id =
|
|
3257
|
+
eventProperties.user_id = userId;
|
|
2874
3258
|
eventProperties.event = "package_download";
|
|
2875
3259
|
eventProperties.first_download = firstDownload;
|
|
2876
3260
|
eventProperties.language = "typescript";
|
|
2877
3261
|
eventProperties.source = this._source;
|
|
3262
|
+
eventProperties.runtime = this._runtimeEnvironment;
|
|
2878
3263
|
await this._scarfClient.logEvent(eventProperties);
|
|
2879
3264
|
}
|
|
2880
3265
|
} catch (e) {
|
|
2881
3266
|
logger.debug(`Failed to track Scarf package_download event: ${e}`);
|
|
2882
3267
|
}
|
|
2883
3268
|
}
|
|
3269
|
+
// ============================================================================
|
|
3270
|
+
// Agent Events
|
|
3271
|
+
// ============================================================================
|
|
2884
3272
|
async trackAgentExecution(data) {
|
|
3273
|
+
if (!this.isEnabled) return;
|
|
2885
3274
|
const event = new MCPAgentExecutionEvent(data);
|
|
2886
3275
|
await this.capture(event);
|
|
2887
3276
|
}
|
|
3277
|
+
// ============================================================================
|
|
3278
|
+
// Server Events
|
|
3279
|
+
// ============================================================================
|
|
3280
|
+
/**
|
|
3281
|
+
* 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
|
+
*/
|
|
3286
|
+
async trackServerRunFromServer(server, transport) {
|
|
3287
|
+
if (!this.isEnabled) return;
|
|
3288
|
+
const data = createServerRunEventData(server, transport);
|
|
3289
|
+
const event = new ServerRunEvent(data);
|
|
3290
|
+
await this.capture(event);
|
|
3291
|
+
}
|
|
3292
|
+
async trackServerInitialize(data) {
|
|
3293
|
+
if (!this.isEnabled) return;
|
|
3294
|
+
const event = new ServerInitializeEvent(data);
|
|
3295
|
+
await this.capture(event);
|
|
3296
|
+
}
|
|
3297
|
+
async trackServerToolCall(data) {
|
|
3298
|
+
if (!this.isEnabled) return;
|
|
3299
|
+
const event = new ServerToolCallEvent(data);
|
|
3300
|
+
await this.capture(event);
|
|
3301
|
+
}
|
|
3302
|
+
async trackServerResourceCall(data) {
|
|
3303
|
+
if (!this.isEnabled) return;
|
|
3304
|
+
const event = new ServerResourceCallEvent(data);
|
|
3305
|
+
await this.capture(event);
|
|
3306
|
+
}
|
|
3307
|
+
async trackServerPromptCall(data) {
|
|
3308
|
+
if (!this.isEnabled) return;
|
|
3309
|
+
const event = new ServerPromptCallEvent(data);
|
|
3310
|
+
await this.capture(event);
|
|
3311
|
+
}
|
|
3312
|
+
async trackServerContext(data) {
|
|
3313
|
+
if (!this.isEnabled) return;
|
|
3314
|
+
const event = new ServerContextEvent(data);
|
|
3315
|
+
await this.capture(event);
|
|
3316
|
+
}
|
|
3317
|
+
// ============================================================================
|
|
3318
|
+
// Client Events
|
|
3319
|
+
// ============================================================================
|
|
3320
|
+
async trackMCPClientInit(data) {
|
|
3321
|
+
if (!this.isEnabled) return;
|
|
3322
|
+
const event = new MCPClientInitEvent(data);
|
|
3323
|
+
await this.capture(event);
|
|
3324
|
+
}
|
|
3325
|
+
async trackConnectorInit(data) {
|
|
3326
|
+
if (!this.isEnabled) return;
|
|
3327
|
+
const event = new ConnectorInitEvent(data);
|
|
3328
|
+
await this.capture(event);
|
|
3329
|
+
}
|
|
2888
3330
|
flush() {
|
|
2889
3331
|
if (this._posthogClient) {
|
|
2890
3332
|
try {
|
|
@@ -3246,6 +3688,13 @@ var MCPAgent = class {
|
|
|
3246
3688
|
static {
|
|
3247
3689
|
__name(this, "MCPAgent");
|
|
3248
3690
|
}
|
|
3691
|
+
/**
|
|
3692
|
+
* Get the mcp-use package version.
|
|
3693
|
+
* Works in all environments (Node.js, browser, Cloudflare Workers, Deno, etc.)
|
|
3694
|
+
*/
|
|
3695
|
+
static getPackageVersion() {
|
|
3696
|
+
return getPackageVersion();
|
|
3697
|
+
}
|
|
3249
3698
|
llm;
|
|
3250
3699
|
client;
|
|
3251
3700
|
connectors;
|
|
@@ -5667,7 +6116,7 @@ var VMCodeExecutor = class extends BaseCodeExecutor {
|
|
|
5667
6116
|
};
|
|
5668
6117
|
|
|
5669
6118
|
// src/connectors/base.ts
|
|
5670
|
-
var import_types = require("@modelcontextprotocol
|
|
6119
|
+
var import_types = require("@mcp-use/modelcontextprotocol-sdk/types.js");
|
|
5671
6120
|
init_logging();
|
|
5672
6121
|
var BaseConnector = class {
|
|
5673
6122
|
static {
|
|
@@ -5688,6 +6137,17 @@ var BaseConnector = class {
|
|
|
5688
6137
|
this.rootsCache = [...opts.roots];
|
|
5689
6138
|
}
|
|
5690
6139
|
}
|
|
6140
|
+
/**
|
|
6141
|
+
* Track connector initialization event
|
|
6142
|
+
* Should be called by subclasses after successful connection
|
|
6143
|
+
*/
|
|
6144
|
+
trackConnectorInit(data) {
|
|
6145
|
+
const connectorType = this.constructor.name;
|
|
6146
|
+
Telemetry.getInstance().trackConnectorInit({
|
|
6147
|
+
connectorType,
|
|
6148
|
+
...data
|
|
6149
|
+
}).catch((e) => logger.debug(`Failed to track connector init: ${e}`));
|
|
6150
|
+
}
|
|
5691
6151
|
/**
|
|
5692
6152
|
* Register a handler for server notifications
|
|
5693
6153
|
*
|
|
@@ -6313,12 +6773,12 @@ var CodeModeConnector = class extends BaseConnector {
|
|
|
6313
6773
|
var import_node_fs = require("fs");
|
|
6314
6774
|
|
|
6315
6775
|
// src/connectors/http.ts
|
|
6316
|
-
var import_client = require("@modelcontextprotocol
|
|
6317
|
-
var import_streamableHttp = require("@modelcontextprotocol
|
|
6776
|
+
var import_client = require("@mcp-use/modelcontextprotocol-sdk/client/index.js");
|
|
6777
|
+
var import_streamableHttp = require("@mcp-use/modelcontextprotocol-sdk/client/streamableHttp.js");
|
|
6318
6778
|
init_logging();
|
|
6319
6779
|
|
|
6320
6780
|
// src/task_managers/sse.ts
|
|
6321
|
-
var import_sse = require("@modelcontextprotocol
|
|
6781
|
+
var import_sse = require("@mcp-use/modelcontextprotocol-sdk/client/sse.js");
|
|
6322
6782
|
init_logging();
|
|
6323
6783
|
|
|
6324
6784
|
// src/task_managers/base.ts
|
|
@@ -6531,15 +6991,16 @@ var HttpConnector = class extends BaseConnector {
|
|
|
6531
6991
|
let fallbackReason = "Unknown error";
|
|
6532
6992
|
let is401Error = false;
|
|
6533
6993
|
if (err instanceof import_streamableHttp.StreamableHTTPError) {
|
|
6534
|
-
|
|
6535
|
-
|
|
6994
|
+
const streamableErr = err;
|
|
6995
|
+
is401Error = streamableErr.code === 401;
|
|
6996
|
+
if (streamableErr.code === 400 && streamableErr.message.includes("Missing session ID")) {
|
|
6536
6997
|
fallbackReason = "Server requires session ID (FastMCP compatibility) - using SSE transport";
|
|
6537
6998
|
logger.warn(`\u26A0\uFE0F ${fallbackReason}`);
|
|
6538
|
-
} else if (
|
|
6539
|
-
fallbackReason = `Server returned ${
|
|
6999
|
+
} else if (streamableErr.code === 404 || streamableErr.code === 405) {
|
|
7000
|
+
fallbackReason = `Server returned ${streamableErr.code} - server likely doesn't support streamable HTTP`;
|
|
6540
7001
|
logger.debug(fallbackReason);
|
|
6541
7002
|
} else {
|
|
6542
|
-
fallbackReason = `Server returned ${
|
|
7003
|
+
fallbackReason = `Server returned ${streamableErr.code}: ${streamableErr.message}`;
|
|
6543
7004
|
logger.debug(fallbackReason);
|
|
6544
7005
|
}
|
|
6545
7006
|
} else if (err instanceof Error) {
|
|
@@ -6679,6 +7140,10 @@ var HttpConnector = class extends BaseConnector {
|
|
|
6679
7140
|
logger.debug(
|
|
6680
7141
|
`Successfully connected to MCP implementation via streamable HTTP: ${baseUrl}`
|
|
6681
7142
|
);
|
|
7143
|
+
this.trackConnectorInit({
|
|
7144
|
+
serverUrl: this.baseUrl,
|
|
7145
|
+
publicIdentifier: `${this.baseUrl} (streamable-http)`
|
|
7146
|
+
});
|
|
6682
7147
|
} catch (err) {
|
|
6683
7148
|
await this.cleanupResources();
|
|
6684
7149
|
throw err;
|
|
@@ -6726,6 +7191,10 @@ var HttpConnector = class extends BaseConnector {
|
|
|
6726
7191
|
logger.debug(
|
|
6727
7192
|
`Successfully connected to MCP implementation via HTTP/SSE: ${baseUrl}`
|
|
6728
7193
|
);
|
|
7194
|
+
this.trackConnectorInit({
|
|
7195
|
+
serverUrl: this.baseUrl,
|
|
7196
|
+
publicIdentifier: `${this.baseUrl} (sse)`
|
|
7197
|
+
});
|
|
6729
7198
|
} catch (err) {
|
|
6730
7199
|
await this.cleanupResources();
|
|
6731
7200
|
throw err;
|
|
@@ -6748,11 +7217,11 @@ var HttpConnector = class extends BaseConnector {
|
|
|
6748
7217
|
|
|
6749
7218
|
// src/connectors/stdio.ts
|
|
6750
7219
|
var import_node_process = __toESM(require("process"), 1);
|
|
6751
|
-
var import_client2 = require("@modelcontextprotocol
|
|
7220
|
+
var import_client2 = require("@mcp-use/modelcontextprotocol-sdk/client/index.js");
|
|
6752
7221
|
init_logging();
|
|
6753
7222
|
|
|
6754
7223
|
// src/task_managers/stdio.ts
|
|
6755
|
-
var import_stdio = require("@modelcontextprotocol
|
|
7224
|
+
var import_stdio = require("@mcp-use/modelcontextprotocol-sdk/client/stdio.js");
|
|
6756
7225
|
init_logging();
|
|
6757
7226
|
var StdioConnectionManager = class extends ConnectionManager {
|
|
6758
7227
|
static {
|
|
@@ -6881,6 +7350,11 @@ var StdioConnector = class extends BaseConnector {
|
|
|
6881
7350
|
logger.debug(
|
|
6882
7351
|
`Successfully connected to MCP implementation: ${this.command}`
|
|
6883
7352
|
);
|
|
7353
|
+
this.trackConnectorInit({
|
|
7354
|
+
serverCommand: this.command,
|
|
7355
|
+
serverArgs: this.args,
|
|
7356
|
+
publicIdentifier: `${this.command} ${this.args.join(" ")}`
|
|
7357
|
+
});
|
|
6884
7358
|
} catch (err) {
|
|
6885
7359
|
logger.error(`Failed to connect to MCP implementation: ${err}`);
|
|
6886
7360
|
await this.cleanupResources();
|
|
@@ -7214,6 +7688,13 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
|
|
|
7214
7688
|
static {
|
|
7215
7689
|
__name(this, "MCPClient");
|
|
7216
7690
|
}
|
|
7691
|
+
/**
|
|
7692
|
+
* Get the mcp-use package version.
|
|
7693
|
+
* Works in all environments (Node.js, browser, Cloudflare Workers, Deno, etc.)
|
|
7694
|
+
*/
|
|
7695
|
+
static getPackageVersion() {
|
|
7696
|
+
return getPackageVersion();
|
|
7697
|
+
}
|
|
7217
7698
|
codeMode = false;
|
|
7218
7699
|
_codeExecutor = null;
|
|
7219
7700
|
_customCodeExecutor = null;
|
|
@@ -7251,12 +7732,28 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
|
|
|
7251
7732
|
if (this.codeMode) {
|
|
7252
7733
|
this._setupCodeModeConnector();
|
|
7253
7734
|
}
|
|
7735
|
+
this._trackClientInit();
|
|
7736
|
+
}
|
|
7737
|
+
_trackClientInit() {
|
|
7738
|
+
const servers = Object.keys(this.config.mcpServers ?? {});
|
|
7739
|
+
const hasSamplingCallback = !!this._samplingCallback;
|
|
7740
|
+
const hasElicitationCallback = !!this._elicitationCallback;
|
|
7741
|
+
Telemetry.getInstance().trackMCPClientInit({
|
|
7742
|
+
codeMode: this.codeMode,
|
|
7743
|
+
sandbox: false,
|
|
7744
|
+
// Sandbox not supported in TS yet
|
|
7745
|
+
allCallbacks: hasSamplingCallback && hasElicitationCallback,
|
|
7746
|
+
verify: false,
|
|
7747
|
+
// No verify option in TS client
|
|
7748
|
+
servers,
|
|
7749
|
+
numServers: servers.length
|
|
7750
|
+
}).catch((e) => logger.debug(`Failed to track MCPClient init: ${e}`));
|
|
7254
7751
|
}
|
|
7255
7752
|
static fromDict(cfg, options) {
|
|
7256
7753
|
return new _MCPClient(cfg, options);
|
|
7257
7754
|
}
|
|
7258
|
-
static fromConfigFile(
|
|
7259
|
-
return new _MCPClient(loadConfigFile(
|
|
7755
|
+
static fromConfigFile(path3, options) {
|
|
7756
|
+
return new _MCPClient(loadConfigFile(path3), options);
|
|
7260
7757
|
}
|
|
7261
7758
|
/**
|
|
7262
7759
|
* Save configuration to a file (Node.js only)
|
|
@@ -8108,7 +8605,7 @@ var BrowserOAuthClientProvider = class {
|
|
|
8108
8605
|
};
|
|
8109
8606
|
|
|
8110
8607
|
// src/auth/callback.ts
|
|
8111
|
-
var import_auth = require("@modelcontextprotocol
|
|
8608
|
+
var import_auth = require("@mcp-use/modelcontextprotocol-sdk/client/auth.js");
|
|
8112
8609
|
async function onMcpAuthorization() {
|
|
8113
8610
|
const queryParams = new URLSearchParams(window.location.search);
|
|
8114
8611
|
const code = queryParams.get("code");
|
|
@@ -8251,6 +8748,13 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
|
8251
8748
|
static {
|
|
8252
8749
|
__name(this, "BrowserMCPClient");
|
|
8253
8750
|
}
|
|
8751
|
+
/**
|
|
8752
|
+
* Get the mcp-use package version.
|
|
8753
|
+
* Works in all environments (Node.js, browser, Cloudflare Workers, Deno, etc.)
|
|
8754
|
+
*/
|
|
8755
|
+
static getPackageVersion() {
|
|
8756
|
+
return getPackageVersion();
|
|
8757
|
+
}
|
|
8254
8758
|
constructor(config) {
|
|
8255
8759
|
super(config);
|
|
8256
8760
|
}
|
|
@@ -8567,7 +9071,7 @@ function useMcp(options) {
|
|
|
8567
9071
|
"Authentication required. OAuth provider available."
|
|
8568
9072
|
);
|
|
8569
9073
|
try {
|
|
8570
|
-
const { auth: auth2 } = await import("@modelcontextprotocol
|
|
9074
|
+
const { auth: auth2 } = await import("@mcp-use/modelcontextprotocol-sdk/client/auth.js");
|
|
8571
9075
|
const baseUrl = new URL(url).origin;
|
|
8572
9076
|
auth2(authProviderRef.current, { serverUrl: baseUrl }).catch(
|
|
8573
9077
|
() => {
|
|
@@ -8735,7 +9239,7 @@ function useMcp(options) {
|
|
|
8735
9239
|
});
|
|
8736
9240
|
authProviderRef.current = freshAuthProvider;
|
|
8737
9241
|
addLog("info", "Triggering fresh OAuth authorization...");
|
|
8738
|
-
const { auth: auth2 } = await import("@modelcontextprotocol
|
|
9242
|
+
const { auth: auth2 } = await import("@mcp-use/modelcontextprotocol-sdk/client/auth.js");
|
|
8739
9243
|
const baseUrl = new URL(url).origin;
|
|
8740
9244
|
auth2(freshAuthProvider, {
|
|
8741
9245
|
serverUrl: baseUrl
|
|
@@ -8743,7 +9247,7 @@ function useMcp(options) {
|
|
|
8743
9247
|
addLog(
|
|
8744
9248
|
"info",
|
|
8745
9249
|
"OAuth flow initiated:",
|
|
8746
|
-
err
|
|
9250
|
+
err instanceof Error ? err.message : "Redirecting..."
|
|
8747
9251
|
);
|
|
8748
9252
|
});
|
|
8749
9253
|
} catch (authError) {
|
|
@@ -9797,8 +10301,8 @@ __name(WidgetControls, "WidgetControls");
|
|
|
9797
10301
|
var import_react7 = __toESM(require("react"), 1);
|
|
9798
10302
|
function getBasename() {
|
|
9799
10303
|
if (typeof window === "undefined") return "/";
|
|
9800
|
-
const
|
|
9801
|
-
const match =
|
|
10304
|
+
const path3 = window.location.pathname;
|
|
10305
|
+
const match = path3.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);
|
|
9802
10306
|
if (match) {
|
|
9803
10307
|
return match[1];
|
|
9804
10308
|
}
|