mcp-use 1.10.0-canary.6 → 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-XU3C6BYJ.js → chunk-3BBYQXEN.js} +14 -0
- package/dist/{chunk-464BT6EX.js → chunk-5TGZJKUB.js} +1 -1
- package/dist/{chunk-7AZ4YFTN.js → chunk-EVWXZWIJ.js} +1 -1
- package/dist/{chunk-FWN7BKNM.js → chunk-GPJDNLPU.js} +14 -1
- package/dist/{chunk-YMJL66MY.js → chunk-J77Z4CRV.js} +12 -402
- package/dist/chunk-PP653GKW.js +942 -0
- package/dist/{chunk-T4B7QDPT.js → chunk-QZCF4NHP.js} +20 -4
- package/dist/index.cjs +575 -72
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -13
- package/dist/src/agents/index.cjs +2050 -1603
- 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/browser.cjs +3189 -2710
- package/dist/src/browser.d.ts +1 -0
- package/dist/src/browser.d.ts.map +1 -1
- package/dist/src/browser.js +9 -4
- package/dist/src/client/browser.d.ts +5 -0
- package/dist/src/client/browser.d.ts.map +1 -1
- package/dist/src/client/prompts.cjs +12 -3
- package/dist/src/client/prompts.js +3 -2
- package/dist/src/client.d.ts +6 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/connectors/base.d.ts +20 -10
- 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/react/index.cjs +839 -12
- package/dist/src/react/index.js +4 -4
- package/dist/src/server/endpoints/mount-mcp.d.ts.map +1 -1
- package/dist/src/server/index.cjs +1352 -78
- 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 +199 -53
- package/dist/src/server/mcp-server.d.ts +31 -6
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/dist/src/server/tools/tool-execution-helpers.d.ts.map +1 -1
- package/dist/src/server/widgets/mount-widgets-dev.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-M5RO4YO2.js → tool-execution-helpers-PU3NN3NL.js} +3 -2
- package/package.json +5 -4
- package/dist/chunk-MTHLLDCX.js +0 -97
package/dist/src/react/index.cjs
CHANGED
|
@@ -82,9 +82,9 @@ var import_streamableHttp = require("@mcp-use/modelcontextprotocol-sdk/client/st
|
|
|
82
82
|
async function getNodeModules() {
|
|
83
83
|
if (typeof process !== "undefined" && process.platform) {
|
|
84
84
|
try {
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
return { fs:
|
|
85
|
+
const fs2 = await import("fs");
|
|
86
|
+
const path2 = await import("path");
|
|
87
|
+
return { fs: fs2.default, path: path2.default };
|
|
88
88
|
} catch {
|
|
89
89
|
return { fs: null, path: null };
|
|
90
90
|
}
|
|
@@ -514,6 +514,814 @@ var SseConnectionManager = class extends ConnectionManager {
|
|
|
514
514
|
|
|
515
515
|
// src/connectors/base.ts
|
|
516
516
|
var import_types = require("@mcp-use/modelcontextprotocol-sdk/types.js");
|
|
517
|
+
|
|
518
|
+
// src/telemetry/telemetry.ts
|
|
519
|
+
var fs = __toESM(require("fs"), 1);
|
|
520
|
+
var os = __toESM(require("os"), 1);
|
|
521
|
+
var path = __toESM(require("path"), 1);
|
|
522
|
+
var import_posthog_node = require("posthog-node");
|
|
523
|
+
|
|
524
|
+
// src/server/utils/runtime.ts
|
|
525
|
+
var isDeno = typeof globalThis.Deno !== "undefined";
|
|
526
|
+
function generateUUID() {
|
|
527
|
+
return globalThis.crypto.randomUUID();
|
|
528
|
+
}
|
|
529
|
+
__name(generateUUID, "generateUUID");
|
|
530
|
+
|
|
531
|
+
// src/telemetry/events.ts
|
|
532
|
+
var BaseTelemetryEvent = class {
|
|
533
|
+
static {
|
|
534
|
+
__name(this, "BaseTelemetryEvent");
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
var MCPAgentExecutionEvent = class extends BaseTelemetryEvent {
|
|
538
|
+
constructor(data) {
|
|
539
|
+
super();
|
|
540
|
+
this.data = data;
|
|
541
|
+
}
|
|
542
|
+
static {
|
|
543
|
+
__name(this, "MCPAgentExecutionEvent");
|
|
544
|
+
}
|
|
545
|
+
get name() {
|
|
546
|
+
return "mcp_agent_execution";
|
|
547
|
+
}
|
|
548
|
+
get properties() {
|
|
549
|
+
return {
|
|
550
|
+
// Core execution info
|
|
551
|
+
execution_method: this.data.executionMethod,
|
|
552
|
+
query: this.data.query,
|
|
553
|
+
query_length: this.data.query.length,
|
|
554
|
+
success: this.data.success,
|
|
555
|
+
// Agent configuration
|
|
556
|
+
model_provider: this.data.modelProvider,
|
|
557
|
+
model_name: this.data.modelName,
|
|
558
|
+
server_count: this.data.serverCount,
|
|
559
|
+
server_identifiers: this.data.serverIdentifiers,
|
|
560
|
+
total_tools_available: this.data.totalToolsAvailable,
|
|
561
|
+
tools_available_names: this.data.toolsAvailableNames,
|
|
562
|
+
max_steps_configured: this.data.maxStepsConfigured,
|
|
563
|
+
memory_enabled: this.data.memoryEnabled,
|
|
564
|
+
use_server_manager: this.data.useServerManager,
|
|
565
|
+
// Execution parameters (always include, even if null)
|
|
566
|
+
max_steps_used: this.data.maxStepsUsed,
|
|
567
|
+
manage_connector: this.data.manageConnector,
|
|
568
|
+
external_history_used: this.data.externalHistoryUsed,
|
|
569
|
+
// Execution results (always include, even if null)
|
|
570
|
+
steps_taken: this.data.stepsTaken ?? null,
|
|
571
|
+
tools_used_count: this.data.toolsUsedCount ?? null,
|
|
572
|
+
tools_used_names: this.data.toolsUsedNames ?? null,
|
|
573
|
+
response: this.data.response ?? null,
|
|
574
|
+
response_length: this.data.response ? this.data.response.length : null,
|
|
575
|
+
execution_time_ms: this.data.executionTimeMs ?? null,
|
|
576
|
+
error_type: this.data.errorType ?? null,
|
|
577
|
+
conversation_history_length: this.data.conversationHistoryLength ?? null
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
function createServerRunEventData(server, transport) {
|
|
582
|
+
const toolRegistrations = Array.from(server.registrations.tools.values());
|
|
583
|
+
const promptRegistrations = Array.from(server.registrations.prompts.values());
|
|
584
|
+
const resourceRegistrations = Array.from(
|
|
585
|
+
server.registrations.resources.values()
|
|
586
|
+
);
|
|
587
|
+
const templateRegistrations = Array.from(
|
|
588
|
+
server.registrations.resourceTemplates.values()
|
|
589
|
+
);
|
|
590
|
+
const allResources = resourceRegistrations.map((r) => ({
|
|
591
|
+
name: r.config.name,
|
|
592
|
+
title: r.config.title ?? null,
|
|
593
|
+
description: r.config.description ?? null,
|
|
594
|
+
uri: r.config.uri ?? null,
|
|
595
|
+
mime_type: r.config.mimeType ?? null
|
|
596
|
+
}));
|
|
597
|
+
const appsSdkResources = allResources.filter(
|
|
598
|
+
(r) => r.mime_type === "text/html+skybridge"
|
|
599
|
+
);
|
|
600
|
+
const mcpUiResources = allResources.filter(
|
|
601
|
+
(r) => r.mime_type === "text/uri-list" || r.mime_type === "text/html"
|
|
602
|
+
);
|
|
603
|
+
const mcpAppsResources = allResources.filter(
|
|
604
|
+
(r) => r.mime_type === "text/html+mcp"
|
|
605
|
+
);
|
|
606
|
+
return {
|
|
607
|
+
transport,
|
|
608
|
+
toolsNumber: server.registeredTools.length,
|
|
609
|
+
resourcesNumber: server.registeredResources.length,
|
|
610
|
+
promptsNumber: server.registeredPrompts.length,
|
|
611
|
+
auth: !!server.oauthProvider,
|
|
612
|
+
name: server.config.name,
|
|
613
|
+
description: server.config.description ?? null,
|
|
614
|
+
baseUrl: server.serverBaseUrl ?? null,
|
|
615
|
+
toolNames: server.registeredTools.length > 0 ? server.registeredTools : null,
|
|
616
|
+
resourceNames: server.registeredResources.length > 0 ? server.registeredResources : null,
|
|
617
|
+
promptNames: server.registeredPrompts.length > 0 ? server.registeredPrompts : null,
|
|
618
|
+
tools: toolRegistrations.length > 0 ? toolRegistrations.map((r) => ({
|
|
619
|
+
name: r.config.name,
|
|
620
|
+
title: r.config.title ?? null,
|
|
621
|
+
description: r.config.description ?? null,
|
|
622
|
+
input_schema: r.config.schema ? JSON.stringify(r.config.schema) : null,
|
|
623
|
+
output_schema: r.config.outputSchema ? JSON.stringify(r.config.outputSchema) : null
|
|
624
|
+
})) : null,
|
|
625
|
+
resources: allResources.length > 0 ? allResources : null,
|
|
626
|
+
prompts: promptRegistrations.length > 0 ? promptRegistrations.map((r) => ({
|
|
627
|
+
name: r.config.name,
|
|
628
|
+
title: r.config.title ?? null,
|
|
629
|
+
description: r.config.description ?? null,
|
|
630
|
+
args: r.config.args ? JSON.stringify(r.config.args) : null
|
|
631
|
+
})) : null,
|
|
632
|
+
templates: templateRegistrations.length > 0 ? templateRegistrations.map((r) => ({
|
|
633
|
+
name: r.config.name,
|
|
634
|
+
title: r.config.title ?? null,
|
|
635
|
+
description: r.config.description ?? null
|
|
636
|
+
})) : null,
|
|
637
|
+
capabilities: {
|
|
638
|
+
logging: true,
|
|
639
|
+
resources: { subscribe: true, listChanged: true }
|
|
640
|
+
},
|
|
641
|
+
appsSdkResources: appsSdkResources.length > 0 ? appsSdkResources : null,
|
|
642
|
+
appsSdkResourcesNumber: appsSdkResources.length,
|
|
643
|
+
mcpUiResources: mcpUiResources.length > 0 ? mcpUiResources : null,
|
|
644
|
+
mcpUiResourcesNumber: mcpUiResources.length,
|
|
645
|
+
mcpAppsResources: mcpAppsResources.length > 0 ? mcpAppsResources : null,
|
|
646
|
+
mcpAppsResourcesNumber: mcpAppsResources.length
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
__name(createServerRunEventData, "createServerRunEventData");
|
|
650
|
+
var ServerRunEvent = class extends BaseTelemetryEvent {
|
|
651
|
+
constructor(data) {
|
|
652
|
+
super();
|
|
653
|
+
this.data = data;
|
|
654
|
+
}
|
|
655
|
+
static {
|
|
656
|
+
__name(this, "ServerRunEvent");
|
|
657
|
+
}
|
|
658
|
+
get name() {
|
|
659
|
+
return "server_run";
|
|
660
|
+
}
|
|
661
|
+
get properties() {
|
|
662
|
+
return {
|
|
663
|
+
transport: this.data.transport,
|
|
664
|
+
tools_number: this.data.toolsNumber,
|
|
665
|
+
resources_number: this.data.resourcesNumber,
|
|
666
|
+
prompts_number: this.data.promptsNumber,
|
|
667
|
+
auth: this.data.auth,
|
|
668
|
+
name: this.data.name,
|
|
669
|
+
description: this.data.description ?? null,
|
|
670
|
+
base_url: this.data.baseUrl ?? null,
|
|
671
|
+
tool_names: this.data.toolNames ?? null,
|
|
672
|
+
resource_names: this.data.resourceNames ?? null,
|
|
673
|
+
prompt_names: this.data.promptNames ?? null,
|
|
674
|
+
tools: this.data.tools ?? null,
|
|
675
|
+
resources: this.data.resources ?? null,
|
|
676
|
+
prompts: this.data.prompts ?? null,
|
|
677
|
+
templates: this.data.templates ?? null,
|
|
678
|
+
capabilities: this.data.capabilities ? JSON.stringify(this.data.capabilities) : null,
|
|
679
|
+
apps_sdk_resources: this.data.appsSdkResources ? JSON.stringify(this.data.appsSdkResources) : null,
|
|
680
|
+
apps_sdk_resources_number: this.data.appsSdkResourcesNumber ?? 0,
|
|
681
|
+
mcp_ui_resources: this.data.mcpUiResources ? JSON.stringify(this.data.mcpUiResources) : null,
|
|
682
|
+
mcp_ui_resources_number: this.data.mcpUiResourcesNumber ?? 0,
|
|
683
|
+
mcp_apps_resources: this.data.mcpAppsResources ? JSON.stringify(this.data.mcpAppsResources) : null,
|
|
684
|
+
mcp_apps_resources_number: this.data.mcpAppsResourcesNumber ?? 0
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
var ServerInitializeEvent = class extends BaseTelemetryEvent {
|
|
689
|
+
constructor(data) {
|
|
690
|
+
super();
|
|
691
|
+
this.data = data;
|
|
692
|
+
}
|
|
693
|
+
static {
|
|
694
|
+
__name(this, "ServerInitializeEvent");
|
|
695
|
+
}
|
|
696
|
+
get name() {
|
|
697
|
+
return "server_initialize_call";
|
|
698
|
+
}
|
|
699
|
+
get properties() {
|
|
700
|
+
return {
|
|
701
|
+
protocol_version: this.data.protocolVersion,
|
|
702
|
+
client_info: JSON.stringify(this.data.clientInfo),
|
|
703
|
+
client_capabilities: JSON.stringify(this.data.clientCapabilities),
|
|
704
|
+
session_id: this.data.sessionId ?? null
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
var ServerToolCallEvent = class extends BaseTelemetryEvent {
|
|
709
|
+
constructor(data) {
|
|
710
|
+
super();
|
|
711
|
+
this.data = data;
|
|
712
|
+
}
|
|
713
|
+
static {
|
|
714
|
+
__name(this, "ServerToolCallEvent");
|
|
715
|
+
}
|
|
716
|
+
get name() {
|
|
717
|
+
return "server_tool_call";
|
|
718
|
+
}
|
|
719
|
+
get properties() {
|
|
720
|
+
return {
|
|
721
|
+
tool_name: this.data.toolName,
|
|
722
|
+
length_input_argument: this.data.lengthInputArgument,
|
|
723
|
+
success: this.data.success,
|
|
724
|
+
error_type: this.data.errorType ?? null,
|
|
725
|
+
execution_time_ms: this.data.executionTimeMs ?? null
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
var ServerResourceCallEvent = class extends BaseTelemetryEvent {
|
|
730
|
+
constructor(data) {
|
|
731
|
+
super();
|
|
732
|
+
this.data = data;
|
|
733
|
+
}
|
|
734
|
+
static {
|
|
735
|
+
__name(this, "ServerResourceCallEvent");
|
|
736
|
+
}
|
|
737
|
+
get name() {
|
|
738
|
+
return "server_resource_call";
|
|
739
|
+
}
|
|
740
|
+
get properties() {
|
|
741
|
+
return {
|
|
742
|
+
name: this.data.name,
|
|
743
|
+
description: this.data.description,
|
|
744
|
+
contents: this.data.contents,
|
|
745
|
+
success: this.data.success,
|
|
746
|
+
error_type: this.data.errorType ?? null
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
var ServerPromptCallEvent = class extends BaseTelemetryEvent {
|
|
751
|
+
constructor(data) {
|
|
752
|
+
super();
|
|
753
|
+
this.data = data;
|
|
754
|
+
}
|
|
755
|
+
static {
|
|
756
|
+
__name(this, "ServerPromptCallEvent");
|
|
757
|
+
}
|
|
758
|
+
get name() {
|
|
759
|
+
return "server_prompt_call";
|
|
760
|
+
}
|
|
761
|
+
get properties() {
|
|
762
|
+
return {
|
|
763
|
+
name: this.data.name,
|
|
764
|
+
description: this.data.description,
|
|
765
|
+
success: this.data.success,
|
|
766
|
+
error_type: this.data.errorType ?? null
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
var ServerContextEvent = class extends BaseTelemetryEvent {
|
|
771
|
+
constructor(data) {
|
|
772
|
+
super();
|
|
773
|
+
this.data = data;
|
|
774
|
+
}
|
|
775
|
+
static {
|
|
776
|
+
__name(this, "ServerContextEvent");
|
|
777
|
+
}
|
|
778
|
+
get name() {
|
|
779
|
+
return `server_context_${this.data.contextType}`;
|
|
780
|
+
}
|
|
781
|
+
get properties() {
|
|
782
|
+
return {
|
|
783
|
+
context_type: this.data.contextType,
|
|
784
|
+
notification_type: this.data.notificationType ?? null
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
var MCPClientInitEvent = class extends BaseTelemetryEvent {
|
|
789
|
+
constructor(data) {
|
|
790
|
+
super();
|
|
791
|
+
this.data = data;
|
|
792
|
+
}
|
|
793
|
+
static {
|
|
794
|
+
__name(this, "MCPClientInitEvent");
|
|
795
|
+
}
|
|
796
|
+
get name() {
|
|
797
|
+
return "mcpclient_init";
|
|
798
|
+
}
|
|
799
|
+
get properties() {
|
|
800
|
+
return {
|
|
801
|
+
code_mode: this.data.codeMode,
|
|
802
|
+
sandbox: this.data.sandbox,
|
|
803
|
+
all_callbacks: this.data.allCallbacks,
|
|
804
|
+
verify: this.data.verify,
|
|
805
|
+
servers: this.data.servers,
|
|
806
|
+
num_servers: this.data.numServers
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
var ConnectorInitEvent = class extends BaseTelemetryEvent {
|
|
811
|
+
constructor(data) {
|
|
812
|
+
super();
|
|
813
|
+
this.data = data;
|
|
814
|
+
}
|
|
815
|
+
static {
|
|
816
|
+
__name(this, "ConnectorInitEvent");
|
|
817
|
+
}
|
|
818
|
+
get name() {
|
|
819
|
+
return "connector_init";
|
|
820
|
+
}
|
|
821
|
+
get properties() {
|
|
822
|
+
return {
|
|
823
|
+
connector_type: this.data.connectorType,
|
|
824
|
+
server_command: this.data.serverCommand ?? null,
|
|
825
|
+
server_args: this.data.serverArgs ?? null,
|
|
826
|
+
server_url: this.data.serverUrl ?? null,
|
|
827
|
+
public_identifier: this.data.publicIdentifier ?? null
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
// src/version.ts
|
|
833
|
+
var VERSION = "1.10.0-canary.7";
|
|
834
|
+
function getPackageVersion() {
|
|
835
|
+
return VERSION;
|
|
836
|
+
}
|
|
837
|
+
__name(getPackageVersion, "getPackageVersion");
|
|
838
|
+
|
|
839
|
+
// src/telemetry/telemetry.ts
|
|
840
|
+
var USER_ID_STORAGE_KEY = "mcp_use_user_id";
|
|
841
|
+
function detectRuntimeEnvironment() {
|
|
842
|
+
try {
|
|
843
|
+
if (typeof globalThis.Bun !== "undefined") {
|
|
844
|
+
return "bun";
|
|
845
|
+
}
|
|
846
|
+
if (typeof globalThis.Deno !== "undefined") {
|
|
847
|
+
return "deno";
|
|
848
|
+
}
|
|
849
|
+
if (typeof navigator !== "undefined" && navigator.userAgent?.includes("Cloudflare-Workers")) {
|
|
850
|
+
return "cloudflare-workers";
|
|
851
|
+
}
|
|
852
|
+
if (typeof globalThis.EdgeRuntime !== "undefined") {
|
|
853
|
+
return "edge";
|
|
854
|
+
}
|
|
855
|
+
if (typeof process !== "undefined" && typeof process.versions?.node !== "undefined" && typeof fs !== "undefined" && typeof fs.existsSync === "function") {
|
|
856
|
+
return "node";
|
|
857
|
+
}
|
|
858
|
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
859
|
+
return "browser";
|
|
860
|
+
}
|
|
861
|
+
return "unknown";
|
|
862
|
+
} catch {
|
|
863
|
+
return "unknown";
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
__name(detectRuntimeEnvironment, "detectRuntimeEnvironment");
|
|
867
|
+
function getStorageCapability(env) {
|
|
868
|
+
switch (env) {
|
|
869
|
+
case "node":
|
|
870
|
+
case "bun":
|
|
871
|
+
return "filesystem";
|
|
872
|
+
case "browser":
|
|
873
|
+
try {
|
|
874
|
+
if (typeof localStorage !== "undefined") {
|
|
875
|
+
localStorage.setItem("__mcp_use_test__", "1");
|
|
876
|
+
localStorage.removeItem("__mcp_use_test__");
|
|
877
|
+
return "localStorage";
|
|
878
|
+
}
|
|
879
|
+
} catch {
|
|
880
|
+
}
|
|
881
|
+
return "session-only";
|
|
882
|
+
case "deno":
|
|
883
|
+
return "session-only";
|
|
884
|
+
default:
|
|
885
|
+
return "session-only";
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
__name(getStorageCapability, "getStorageCapability");
|
|
889
|
+
var cachedEnvironment = null;
|
|
890
|
+
function getRuntimeEnvironment() {
|
|
891
|
+
if (cachedEnvironment === null) {
|
|
892
|
+
cachedEnvironment = detectRuntimeEnvironment();
|
|
893
|
+
}
|
|
894
|
+
return cachedEnvironment;
|
|
895
|
+
}
|
|
896
|
+
__name(getRuntimeEnvironment, "getRuntimeEnvironment");
|
|
897
|
+
function isNodeJSEnvironment2() {
|
|
898
|
+
const env = getRuntimeEnvironment();
|
|
899
|
+
return env === "node" || env === "bun";
|
|
900
|
+
}
|
|
901
|
+
__name(isNodeJSEnvironment2, "isNodeJSEnvironment");
|
|
902
|
+
var ScarfEventLogger = class {
|
|
903
|
+
static {
|
|
904
|
+
__name(this, "ScarfEventLogger");
|
|
905
|
+
}
|
|
906
|
+
endpoint;
|
|
907
|
+
timeout;
|
|
908
|
+
constructor(endpoint, timeout = 3e3) {
|
|
909
|
+
this.endpoint = endpoint;
|
|
910
|
+
this.timeout = timeout;
|
|
911
|
+
}
|
|
912
|
+
async logEvent(properties) {
|
|
913
|
+
try {
|
|
914
|
+
const controller = new AbortController();
|
|
915
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
916
|
+
const response = await fetch(this.endpoint, {
|
|
917
|
+
method: "POST",
|
|
918
|
+
headers: {
|
|
919
|
+
"Content-Type": "application/json"
|
|
920
|
+
},
|
|
921
|
+
body: JSON.stringify(properties),
|
|
922
|
+
signal: controller.signal
|
|
923
|
+
});
|
|
924
|
+
clearTimeout(timeoutId);
|
|
925
|
+
if (!response.ok) {
|
|
926
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
927
|
+
}
|
|
928
|
+
} catch (error) {
|
|
929
|
+
logger.debug(`Failed to send Scarf event: ${error}`);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
};
|
|
933
|
+
function getCacheHome() {
|
|
934
|
+
if (!isNodeJSEnvironment2()) {
|
|
935
|
+
return "/tmp/mcp_use_cache";
|
|
936
|
+
}
|
|
937
|
+
const envVar = process.env.XDG_CACHE_HOME;
|
|
938
|
+
if (envVar && path.isAbsolute(envVar)) {
|
|
939
|
+
return envVar;
|
|
940
|
+
}
|
|
941
|
+
const platform = process.platform;
|
|
942
|
+
const homeDir = os.homedir();
|
|
943
|
+
if (platform === "win32") {
|
|
944
|
+
const appdata = process.env.LOCALAPPDATA || process.env.APPDATA;
|
|
945
|
+
if (appdata) {
|
|
946
|
+
return appdata;
|
|
947
|
+
}
|
|
948
|
+
return path.join(homeDir, "AppData", "Local");
|
|
949
|
+
} else if (platform === "darwin") {
|
|
950
|
+
return path.join(homeDir, "Library", "Caches");
|
|
951
|
+
} else {
|
|
952
|
+
return path.join(homeDir, ".cache");
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
__name(getCacheHome, "getCacheHome");
|
|
956
|
+
var Telemetry = class _Telemetry {
|
|
957
|
+
static {
|
|
958
|
+
__name(this, "Telemetry");
|
|
959
|
+
}
|
|
960
|
+
static instance = null;
|
|
961
|
+
USER_ID_PATH = path.join(
|
|
962
|
+
getCacheHome(),
|
|
963
|
+
"mcp_use_3",
|
|
964
|
+
"telemetry_user_id"
|
|
965
|
+
);
|
|
966
|
+
VERSION_DOWNLOAD_PATH = path.join(
|
|
967
|
+
getCacheHome(),
|
|
968
|
+
"mcp_use",
|
|
969
|
+
"download_version"
|
|
970
|
+
);
|
|
971
|
+
PROJECT_API_KEY = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";
|
|
972
|
+
HOST = "https://eu.i.posthog.com";
|
|
973
|
+
SCARF_GATEWAY_URL = "https://mcpuse.gateway.scarf.sh/events-ts";
|
|
974
|
+
UNKNOWN_USER_ID = "UNKNOWN_USER_ID";
|
|
975
|
+
_currUserId = null;
|
|
976
|
+
_posthogClient = null;
|
|
977
|
+
_scarfClient = null;
|
|
978
|
+
_runtimeEnvironment;
|
|
979
|
+
_storageCapability;
|
|
980
|
+
_source;
|
|
981
|
+
constructor() {
|
|
982
|
+
this._runtimeEnvironment = getRuntimeEnvironment();
|
|
983
|
+
this._storageCapability = getStorageCapability(this._runtimeEnvironment);
|
|
984
|
+
this._source = typeof process !== "undefined" && process.env?.MCP_USE_TELEMETRY_SOURCE || this._runtimeEnvironment;
|
|
985
|
+
const telemetryDisabled = typeof process !== "undefined" && process.env?.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase() === "false" || false;
|
|
986
|
+
const canSupportTelemetry = this._runtimeEnvironment !== "unknown";
|
|
987
|
+
const isServerlessEnvironment = [
|
|
988
|
+
"cloudflare-workers",
|
|
989
|
+
"edge",
|
|
990
|
+
"deno"
|
|
991
|
+
].includes(this._runtimeEnvironment);
|
|
992
|
+
if (telemetryDisabled) {
|
|
993
|
+
this._posthogClient = null;
|
|
994
|
+
this._scarfClient = null;
|
|
995
|
+
logger.debug("Telemetry disabled via environment variable");
|
|
996
|
+
} else if (!canSupportTelemetry) {
|
|
997
|
+
this._posthogClient = null;
|
|
998
|
+
this._scarfClient = null;
|
|
999
|
+
logger.debug(
|
|
1000
|
+
`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`
|
|
1001
|
+
);
|
|
1002
|
+
} else {
|
|
1003
|
+
logger.info(
|
|
1004
|
+
"Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."
|
|
1005
|
+
);
|
|
1006
|
+
if (this._runtimeEnvironment !== "browser") {
|
|
1007
|
+
try {
|
|
1008
|
+
const posthogOptions = {
|
|
1009
|
+
host: this.HOST,
|
|
1010
|
+
disableGeoip: false
|
|
1011
|
+
};
|
|
1012
|
+
if (isServerlessEnvironment) {
|
|
1013
|
+
posthogOptions.flushAt = 1;
|
|
1014
|
+
posthogOptions.flushInterval = 0;
|
|
1015
|
+
}
|
|
1016
|
+
this._posthogClient = new import_posthog_node.PostHog(
|
|
1017
|
+
this.PROJECT_API_KEY,
|
|
1018
|
+
posthogOptions
|
|
1019
|
+
);
|
|
1020
|
+
} catch (e) {
|
|
1021
|
+
logger.warn(`Failed to initialize PostHog telemetry: ${e}`);
|
|
1022
|
+
this._posthogClient = null;
|
|
1023
|
+
}
|
|
1024
|
+
} else {
|
|
1025
|
+
this._posthogClient = null;
|
|
1026
|
+
}
|
|
1027
|
+
try {
|
|
1028
|
+
this._scarfClient = new ScarfEventLogger(this.SCARF_GATEWAY_URL, 3e3);
|
|
1029
|
+
} catch (e) {
|
|
1030
|
+
logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
|
|
1031
|
+
this._scarfClient = null;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Get the detected runtime environment
|
|
1037
|
+
*/
|
|
1038
|
+
get runtimeEnvironment() {
|
|
1039
|
+
return this._runtimeEnvironment;
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* Get the storage capability for this environment
|
|
1043
|
+
*/
|
|
1044
|
+
get storageCapability() {
|
|
1045
|
+
return this._storageCapability;
|
|
1046
|
+
}
|
|
1047
|
+
static getInstance() {
|
|
1048
|
+
if (!_Telemetry.instance) {
|
|
1049
|
+
_Telemetry.instance = new _Telemetry();
|
|
1050
|
+
}
|
|
1051
|
+
return _Telemetry.instance;
|
|
1052
|
+
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Set the source identifier for telemetry events.
|
|
1055
|
+
* This allows tracking usage from different applications.
|
|
1056
|
+
* @param source - The source identifier (e.g., "my-app", "cli", "vs-code-extension")
|
|
1057
|
+
*/
|
|
1058
|
+
setSource(source) {
|
|
1059
|
+
this._source = source;
|
|
1060
|
+
logger.debug(`Telemetry source set to: ${source}`);
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
* Get the current source identifier.
|
|
1064
|
+
*/
|
|
1065
|
+
getSource() {
|
|
1066
|
+
return this._source;
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Check if telemetry is enabled.
|
|
1070
|
+
* Returns false if telemetry was disabled via environment variable or if not in Node.js environment.
|
|
1071
|
+
*/
|
|
1072
|
+
get isEnabled() {
|
|
1073
|
+
return this._posthogClient !== null || this._scarfClient !== null;
|
|
1074
|
+
}
|
|
1075
|
+
get userId() {
|
|
1076
|
+
if (this._currUserId) {
|
|
1077
|
+
return this._currUserId;
|
|
1078
|
+
}
|
|
1079
|
+
try {
|
|
1080
|
+
switch (this._storageCapability) {
|
|
1081
|
+
case "filesystem":
|
|
1082
|
+
this._currUserId = this.getUserIdFromFilesystem();
|
|
1083
|
+
break;
|
|
1084
|
+
case "localStorage":
|
|
1085
|
+
this._currUserId = this.getUserIdFromLocalStorage();
|
|
1086
|
+
break;
|
|
1087
|
+
case "session-only":
|
|
1088
|
+
default:
|
|
1089
|
+
this._currUserId = `session-${generateUUID()}`;
|
|
1090
|
+
logger.debug(
|
|
1091
|
+
`Using session-based user ID (${this._runtimeEnvironment} environment)`
|
|
1092
|
+
);
|
|
1093
|
+
break;
|
|
1094
|
+
}
|
|
1095
|
+
if (this._storageCapability === "filesystem" && this._currUserId) {
|
|
1096
|
+
this.trackPackageDownloadInternal(this._currUserId, {
|
|
1097
|
+
triggered_by: "user_id_property"
|
|
1098
|
+
}).catch((e) => logger.debug(`Failed to track package download: ${e}`));
|
|
1099
|
+
}
|
|
1100
|
+
} catch (e) {
|
|
1101
|
+
logger.debug(`Failed to get/create user ID: ${e}`);
|
|
1102
|
+
this._currUserId = this.UNKNOWN_USER_ID;
|
|
1103
|
+
}
|
|
1104
|
+
return this._currUserId;
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Get or create user ID from filesystem (Node.js/Bun)
|
|
1108
|
+
*/
|
|
1109
|
+
getUserIdFromFilesystem() {
|
|
1110
|
+
const isFirstTime = !fs.existsSync(this.USER_ID_PATH);
|
|
1111
|
+
if (isFirstTime) {
|
|
1112
|
+
logger.debug(`Creating user ID path: ${this.USER_ID_PATH}`);
|
|
1113
|
+
fs.mkdirSync(path.dirname(this.USER_ID_PATH), { recursive: true });
|
|
1114
|
+
const newUserId = generateUUID();
|
|
1115
|
+
fs.writeFileSync(this.USER_ID_PATH, newUserId);
|
|
1116
|
+
logger.debug(`User ID path created: ${this.USER_ID_PATH}`);
|
|
1117
|
+
return newUserId;
|
|
1118
|
+
}
|
|
1119
|
+
return fs.readFileSync(this.USER_ID_PATH, "utf-8").trim();
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Get or create user ID from localStorage (Browser)
|
|
1123
|
+
*/
|
|
1124
|
+
getUserIdFromLocalStorage() {
|
|
1125
|
+
try {
|
|
1126
|
+
let userId = localStorage.getItem(USER_ID_STORAGE_KEY);
|
|
1127
|
+
if (!userId) {
|
|
1128
|
+
userId = generateUUID();
|
|
1129
|
+
localStorage.setItem(USER_ID_STORAGE_KEY, userId);
|
|
1130
|
+
logger.debug(`Created new browser user ID`);
|
|
1131
|
+
}
|
|
1132
|
+
return userId;
|
|
1133
|
+
} catch (e) {
|
|
1134
|
+
logger.debug(`localStorage access failed: ${e}`);
|
|
1135
|
+
return `session-${generateUUID()}`;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
async capture(event) {
|
|
1139
|
+
logger.debug(
|
|
1140
|
+
`CAPTURE: posthog: ${this._posthogClient !== null}, scarf: ${this._scarfClient !== null}`
|
|
1141
|
+
);
|
|
1142
|
+
if (!this._posthogClient && !this._scarfClient) {
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
if (this._posthogClient) {
|
|
1146
|
+
try {
|
|
1147
|
+
const properties = { ...event.properties };
|
|
1148
|
+
properties.mcp_use_version = getPackageVersion();
|
|
1149
|
+
properties.language = "typescript";
|
|
1150
|
+
properties.source = this._source;
|
|
1151
|
+
properties.runtime = this._runtimeEnvironment;
|
|
1152
|
+
logger.debug(`CAPTURE: PostHog Event ${event.name}`);
|
|
1153
|
+
logger.debug(
|
|
1154
|
+
`CAPTURE: PostHog Properties ${JSON.stringify(properties)}`
|
|
1155
|
+
);
|
|
1156
|
+
this._posthogClient.capture({
|
|
1157
|
+
distinctId: this.userId,
|
|
1158
|
+
event: event.name,
|
|
1159
|
+
properties
|
|
1160
|
+
});
|
|
1161
|
+
} catch (e) {
|
|
1162
|
+
logger.debug(`Failed to track PostHog event ${event.name}: ${e}`);
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
if (this._scarfClient) {
|
|
1166
|
+
try {
|
|
1167
|
+
const properties = {};
|
|
1168
|
+
properties.mcp_use_version = getPackageVersion();
|
|
1169
|
+
properties.user_id = this.userId;
|
|
1170
|
+
properties.event = event.name;
|
|
1171
|
+
properties.language = "typescript";
|
|
1172
|
+
properties.source = this._source;
|
|
1173
|
+
properties.runtime = this._runtimeEnvironment;
|
|
1174
|
+
await this._scarfClient.logEvent(properties);
|
|
1175
|
+
} catch (e) {
|
|
1176
|
+
logger.debug(`Failed to track Scarf event ${event.name}: ${e}`);
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* Track package download event.
|
|
1182
|
+
* This is a public wrapper that safely accesses userId.
|
|
1183
|
+
*/
|
|
1184
|
+
async trackPackageDownload(properties) {
|
|
1185
|
+
return this.trackPackageDownloadInternal(this.userId, properties);
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Internal method to track package download with explicit userId.
|
|
1189
|
+
* This avoids circular dependency when called from the userId getter.
|
|
1190
|
+
*/
|
|
1191
|
+
async trackPackageDownloadInternal(userId, properties) {
|
|
1192
|
+
if (!this._scarfClient) {
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
if (this._storageCapability !== "filesystem") {
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
try {
|
|
1199
|
+
const currentVersion = getPackageVersion();
|
|
1200
|
+
let shouldTrack = false;
|
|
1201
|
+
let firstDownload = false;
|
|
1202
|
+
if (!fs.existsSync(this.VERSION_DOWNLOAD_PATH)) {
|
|
1203
|
+
shouldTrack = true;
|
|
1204
|
+
firstDownload = true;
|
|
1205
|
+
fs.mkdirSync(path.dirname(this.VERSION_DOWNLOAD_PATH), {
|
|
1206
|
+
recursive: true
|
|
1207
|
+
});
|
|
1208
|
+
fs.writeFileSync(this.VERSION_DOWNLOAD_PATH, currentVersion);
|
|
1209
|
+
} else {
|
|
1210
|
+
const savedVersion = fs.readFileSync(this.VERSION_DOWNLOAD_PATH, "utf-8").trim();
|
|
1211
|
+
if (currentVersion > savedVersion) {
|
|
1212
|
+
shouldTrack = true;
|
|
1213
|
+
firstDownload = false;
|
|
1214
|
+
fs.writeFileSync(this.VERSION_DOWNLOAD_PATH, currentVersion);
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
if (shouldTrack) {
|
|
1218
|
+
logger.debug(
|
|
1219
|
+
`Tracking package download event with properties: ${JSON.stringify(properties)}`
|
|
1220
|
+
);
|
|
1221
|
+
const eventProperties = { ...properties || {} };
|
|
1222
|
+
eventProperties.mcp_use_version = currentVersion;
|
|
1223
|
+
eventProperties.user_id = userId;
|
|
1224
|
+
eventProperties.event = "package_download";
|
|
1225
|
+
eventProperties.first_download = firstDownload;
|
|
1226
|
+
eventProperties.language = "typescript";
|
|
1227
|
+
eventProperties.source = this._source;
|
|
1228
|
+
eventProperties.runtime = this._runtimeEnvironment;
|
|
1229
|
+
await this._scarfClient.logEvent(eventProperties);
|
|
1230
|
+
}
|
|
1231
|
+
} catch (e) {
|
|
1232
|
+
logger.debug(`Failed to track Scarf package_download event: ${e}`);
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
// ============================================================================
|
|
1236
|
+
// Agent Events
|
|
1237
|
+
// ============================================================================
|
|
1238
|
+
async trackAgentExecution(data) {
|
|
1239
|
+
if (!this.isEnabled) return;
|
|
1240
|
+
const event = new MCPAgentExecutionEvent(data);
|
|
1241
|
+
await this.capture(event);
|
|
1242
|
+
}
|
|
1243
|
+
// ============================================================================
|
|
1244
|
+
// Server Events
|
|
1245
|
+
// ============================================================================
|
|
1246
|
+
/**
|
|
1247
|
+
* Track server run event directly from an MCPServer instance.
|
|
1248
|
+
* This extracts the necessary data from the server and creates the event.
|
|
1249
|
+
* @param server - The MCPServer instance (or any object conforming to MCPServerTelemetryInfo)
|
|
1250
|
+
* @param transport - The transport type (e.g., "http", "stdio", "supabase")
|
|
1251
|
+
*/
|
|
1252
|
+
async trackServerRunFromServer(server, transport) {
|
|
1253
|
+
if (!this.isEnabled) return;
|
|
1254
|
+
const data = createServerRunEventData(server, transport);
|
|
1255
|
+
const event = new ServerRunEvent(data);
|
|
1256
|
+
await this.capture(event);
|
|
1257
|
+
}
|
|
1258
|
+
async trackServerInitialize(data) {
|
|
1259
|
+
if (!this.isEnabled) return;
|
|
1260
|
+
const event = new ServerInitializeEvent(data);
|
|
1261
|
+
await this.capture(event);
|
|
1262
|
+
}
|
|
1263
|
+
async trackServerToolCall(data) {
|
|
1264
|
+
if (!this.isEnabled) return;
|
|
1265
|
+
const event = new ServerToolCallEvent(data);
|
|
1266
|
+
await this.capture(event);
|
|
1267
|
+
}
|
|
1268
|
+
async trackServerResourceCall(data) {
|
|
1269
|
+
if (!this.isEnabled) return;
|
|
1270
|
+
const event = new ServerResourceCallEvent(data);
|
|
1271
|
+
await this.capture(event);
|
|
1272
|
+
}
|
|
1273
|
+
async trackServerPromptCall(data) {
|
|
1274
|
+
if (!this.isEnabled) return;
|
|
1275
|
+
const event = new ServerPromptCallEvent(data);
|
|
1276
|
+
await this.capture(event);
|
|
1277
|
+
}
|
|
1278
|
+
async trackServerContext(data) {
|
|
1279
|
+
if (!this.isEnabled) return;
|
|
1280
|
+
const event = new ServerContextEvent(data);
|
|
1281
|
+
await this.capture(event);
|
|
1282
|
+
}
|
|
1283
|
+
// ============================================================================
|
|
1284
|
+
// Client Events
|
|
1285
|
+
// ============================================================================
|
|
1286
|
+
async trackMCPClientInit(data) {
|
|
1287
|
+
if (!this.isEnabled) return;
|
|
1288
|
+
const event = new MCPClientInitEvent(data);
|
|
1289
|
+
await this.capture(event);
|
|
1290
|
+
}
|
|
1291
|
+
async trackConnectorInit(data) {
|
|
1292
|
+
if (!this.isEnabled) return;
|
|
1293
|
+
const event = new ConnectorInitEvent(data);
|
|
1294
|
+
await this.capture(event);
|
|
1295
|
+
}
|
|
1296
|
+
flush() {
|
|
1297
|
+
if (this._posthogClient) {
|
|
1298
|
+
try {
|
|
1299
|
+
this._posthogClient.flush();
|
|
1300
|
+
logger.debug("PostHog client telemetry queue flushed");
|
|
1301
|
+
} catch (e) {
|
|
1302
|
+
logger.debug(`Failed to flush PostHog client: ${e}`);
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
if (this._scarfClient) {
|
|
1306
|
+
logger.debug("Scarf telemetry events sent immediately (no flush needed)");
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
shutdown() {
|
|
1310
|
+
if (this._posthogClient) {
|
|
1311
|
+
try {
|
|
1312
|
+
this._posthogClient.shutdown();
|
|
1313
|
+
logger.debug("PostHog client shutdown successfully");
|
|
1314
|
+
} catch (e) {
|
|
1315
|
+
logger.debug(`Error shutting down PostHog client: ${e}`);
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
if (this._scarfClient) {
|
|
1319
|
+
logger.debug("Scarf telemetry client shutdown (no action needed)");
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
};
|
|
1323
|
+
|
|
1324
|
+
// src/connectors/base.ts
|
|
517
1325
|
var BaseConnector = class {
|
|
518
1326
|
static {
|
|
519
1327
|
__name(this, "BaseConnector");
|
|
@@ -533,6 +1341,17 @@ var BaseConnector = class {
|
|
|
533
1341
|
this.rootsCache = [...opts.roots];
|
|
534
1342
|
}
|
|
535
1343
|
}
|
|
1344
|
+
/**
|
|
1345
|
+
* Track connector initialization event
|
|
1346
|
+
* Should be called by subclasses after successful connection
|
|
1347
|
+
*/
|
|
1348
|
+
trackConnectorInit(data) {
|
|
1349
|
+
const connectorType = this.constructor.name;
|
|
1350
|
+
Telemetry.getInstance().trackConnectorInit({
|
|
1351
|
+
connectorType,
|
|
1352
|
+
...data
|
|
1353
|
+
}).catch((e) => logger.debug(`Failed to track connector init: ${e}`));
|
|
1354
|
+
}
|
|
536
1355
|
/**
|
|
537
1356
|
* Register a handler for server notifications
|
|
538
1357
|
*
|
|
@@ -1159,6 +1978,10 @@ var HttpConnector = class extends BaseConnector {
|
|
|
1159
1978
|
logger.debug(
|
|
1160
1979
|
`Successfully connected to MCP implementation via streamable HTTP: ${baseUrl}`
|
|
1161
1980
|
);
|
|
1981
|
+
this.trackConnectorInit({
|
|
1982
|
+
serverUrl: this.baseUrl,
|
|
1983
|
+
publicIdentifier: `${this.baseUrl} (streamable-http)`
|
|
1984
|
+
});
|
|
1162
1985
|
} catch (err) {
|
|
1163
1986
|
await this.cleanupResources();
|
|
1164
1987
|
throw err;
|
|
@@ -1206,6 +2029,10 @@ var HttpConnector = class extends BaseConnector {
|
|
|
1206
2029
|
logger.debug(
|
|
1207
2030
|
`Successfully connected to MCP implementation via HTTP/SSE: ${baseUrl}`
|
|
1208
2031
|
);
|
|
2032
|
+
this.trackConnectorInit({
|
|
2033
|
+
serverUrl: this.baseUrl,
|
|
2034
|
+
publicIdentifier: `${this.baseUrl} (sse)`
|
|
2035
|
+
});
|
|
1209
2036
|
} catch (err) {
|
|
1210
2037
|
await this.cleanupResources();
|
|
1211
2038
|
throw err;
|
|
@@ -1226,13 +2053,6 @@ var HttpConnector = class extends BaseConnector {
|
|
|
1226
2053
|
}
|
|
1227
2054
|
};
|
|
1228
2055
|
|
|
1229
|
-
// src/server/utils/runtime.ts
|
|
1230
|
-
var isDeno = typeof globalThis.Deno !== "undefined";
|
|
1231
|
-
function generateUUID() {
|
|
1232
|
-
return globalThis.crypto.randomUUID();
|
|
1233
|
-
}
|
|
1234
|
-
__name(generateUUID, "generateUUID");
|
|
1235
|
-
|
|
1236
2056
|
// src/task_managers/websocket.ts
|
|
1237
2057
|
var import_ws = __toESM(require("ws"), 1);
|
|
1238
2058
|
var WebSocketConnectionManager = class extends ConnectionManager {
|
|
@@ -1885,6 +2705,13 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
|
1885
2705
|
static {
|
|
1886
2706
|
__name(this, "BrowserMCPClient");
|
|
1887
2707
|
}
|
|
2708
|
+
/**
|
|
2709
|
+
* Get the mcp-use package version.
|
|
2710
|
+
* Works in all environments (Node.js, browser, Cloudflare Workers, Deno, etc.)
|
|
2711
|
+
*/
|
|
2712
|
+
static getPackageVersion() {
|
|
2713
|
+
return getPackageVersion();
|
|
2714
|
+
}
|
|
1888
2715
|
constructor(config) {
|
|
1889
2716
|
super(config);
|
|
1890
2717
|
}
|
|
@@ -3799,8 +4626,8 @@ __name(WidgetControls, "WidgetControls");
|
|
|
3799
4626
|
var import_react7 = __toESM(require("react"), 1);
|
|
3800
4627
|
function getBasename() {
|
|
3801
4628
|
if (typeof window === "undefined") return "/";
|
|
3802
|
-
const
|
|
3803
|
-
const match =
|
|
4629
|
+
const path2 = window.location.pathname;
|
|
4630
|
+
const match = path2.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);
|
|
3804
4631
|
if (match) {
|
|
3805
4632
|
return match[1];
|
|
3806
4633
|
}
|