@mcp-elements/vue 0.1.0 → 0.1.1
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/index.d.ts +356 -2
- package/dist/index.js +761 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -497,6 +497,755 @@ var McpeTabs = defineComponent10({
|
|
|
497
497
|
};
|
|
498
498
|
}
|
|
499
499
|
});
|
|
500
|
+
|
|
501
|
+
// src/mcp/mcp-server-status.ts
|
|
502
|
+
import { defineComponent as defineComponent11, h as h11, computed as computed9 } from "vue";
|
|
503
|
+
import { cn as cn11 } from "@mcp-elements/core";
|
|
504
|
+
var STATUS_LABELS = {
|
|
505
|
+
connected: "Connected",
|
|
506
|
+
connecting: "Connecting",
|
|
507
|
+
disconnected: "Disconnected",
|
|
508
|
+
error: "Error"
|
|
509
|
+
};
|
|
510
|
+
var McpeMcpServerStatus = defineComponent11({
|
|
511
|
+
name: "McpeMcpServerStatus",
|
|
512
|
+
props: {
|
|
513
|
+
status: { type: String, required: true },
|
|
514
|
+
serverName: { type: String, default: "" },
|
|
515
|
+
class: { type: String, default: "" }
|
|
516
|
+
},
|
|
517
|
+
setup(props) {
|
|
518
|
+
const label = computed9(
|
|
519
|
+
() => (props.serverName ? `${props.serverName} \xB7 ` : "") + STATUS_LABELS[props.status]
|
|
520
|
+
);
|
|
521
|
+
const ariaLabel = computed9(
|
|
522
|
+
() => (props.serverName ? `${props.serverName}: ` : "") + STATUS_LABELS[props.status]
|
|
523
|
+
);
|
|
524
|
+
return () => h11(
|
|
525
|
+
"span",
|
|
526
|
+
{
|
|
527
|
+
class: cn11(
|
|
528
|
+
"mcpe-mcp-server-status",
|
|
529
|
+
`mcpe-mcp-server-status-${props.status}`,
|
|
530
|
+
props.class
|
|
531
|
+
),
|
|
532
|
+
role: "status",
|
|
533
|
+
"aria-live": "polite",
|
|
534
|
+
"aria-label": ariaLabel.value
|
|
535
|
+
},
|
|
536
|
+
[h11("span", { class: "mcpe-mcp-server-status-dot", "aria-hidden": "true" }), label.value]
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
// src/mcp/mcp-tool-call.ts
|
|
542
|
+
import { defineComponent as defineComponent12, h as h12, ref, computed as computed10, watch as watch2, onUnmounted as onUnmounted2 } from "vue";
|
|
543
|
+
import { cn as cn12 } from "@mcp-elements/core";
|
|
544
|
+
var STATUS_LABELS2 = {
|
|
545
|
+
idle: "idle",
|
|
546
|
+
pending: "pending",
|
|
547
|
+
running: "running",
|
|
548
|
+
done: "done",
|
|
549
|
+
error: "error",
|
|
550
|
+
cancelled: "cancelled"
|
|
551
|
+
};
|
|
552
|
+
var McpeMcpToolCall = defineComponent12({
|
|
553
|
+
name: "McpeMcpToolCall",
|
|
554
|
+
props: {
|
|
555
|
+
state: { type: Object, required: true },
|
|
556
|
+
toolName: { type: String, default: "" },
|
|
557
|
+
args: { type: Object, default: void 0 },
|
|
558
|
+
class: { type: String, default: "" }
|
|
559
|
+
},
|
|
560
|
+
emits: ["retry"],
|
|
561
|
+
setup(props, { emit }) {
|
|
562
|
+
const snap = ref({ status: "idle" });
|
|
563
|
+
let unsub;
|
|
564
|
+
watch2(
|
|
565
|
+
() => props.state,
|
|
566
|
+
(state) => {
|
|
567
|
+
unsub?.();
|
|
568
|
+
snap.value = {
|
|
569
|
+
status: state.status,
|
|
570
|
+
tool: state.tool,
|
|
571
|
+
args: state.args,
|
|
572
|
+
result: state.result,
|
|
573
|
+
error: state.error,
|
|
574
|
+
startedAt: state.startedAt,
|
|
575
|
+
endedAt: state.endedAt
|
|
576
|
+
};
|
|
577
|
+
unsub = state.subscribe((s) => {
|
|
578
|
+
snap.value = { ...s };
|
|
579
|
+
});
|
|
580
|
+
},
|
|
581
|
+
{ immediate: true }
|
|
582
|
+
);
|
|
583
|
+
onUnmounted2(() => unsub?.());
|
|
584
|
+
const displayName = computed10(() => snap.value.tool ?? props.toolName ?? "unknown");
|
|
585
|
+
const displayArgs = computed10(() => snap.value.args ?? props.args);
|
|
586
|
+
const textBlocks = computed10(
|
|
587
|
+
() => (snap.value.result?.content ?? []).filter((c) => c.type === "text")
|
|
588
|
+
);
|
|
589
|
+
return () => {
|
|
590
|
+
const status = snap.value.status;
|
|
591
|
+
const children = [];
|
|
592
|
+
children.push(
|
|
593
|
+
h12("div", { class: "mcpe-mcp-tool-call-header" }, [
|
|
594
|
+
h12("div", { class: "mcpe-mcp-tool-call-name" }, [
|
|
595
|
+
h12("span", { class: "mcpe-mcp-tool-call-icon", "aria-hidden": "true" }, "fn"),
|
|
596
|
+
h12("span", { class: "mcpe-mcp-tool-call-title" }, displayName.value)
|
|
597
|
+
]),
|
|
598
|
+
h12(
|
|
599
|
+
"span",
|
|
600
|
+
{ class: cn12("mcpe-mcp-tool-call-badge", `mcpe-mcp-tool-call-badge-${status}`) },
|
|
601
|
+
[
|
|
602
|
+
status === "running" ? h12(
|
|
603
|
+
"svg",
|
|
604
|
+
{
|
|
605
|
+
class: "animate-spin h-3 w-3",
|
|
606
|
+
fill: "none",
|
|
607
|
+
viewBox: "0 0 24 24",
|
|
608
|
+
"aria-hidden": "true"
|
|
609
|
+
},
|
|
610
|
+
[
|
|
611
|
+
h12("circle", {
|
|
612
|
+
class: "opacity-25",
|
|
613
|
+
cx: "12",
|
|
614
|
+
cy: "12",
|
|
615
|
+
r: "10",
|
|
616
|
+
stroke: "currentColor",
|
|
617
|
+
"stroke-width": "4"
|
|
618
|
+
}),
|
|
619
|
+
h12("path", {
|
|
620
|
+
class: "opacity-75",
|
|
621
|
+
fill: "currentColor",
|
|
622
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
|
|
623
|
+
})
|
|
624
|
+
]
|
|
625
|
+
) : null,
|
|
626
|
+
STATUS_LABELS2[status]
|
|
627
|
+
]
|
|
628
|
+
)
|
|
629
|
+
])
|
|
630
|
+
);
|
|
631
|
+
if (displayArgs.value) {
|
|
632
|
+
children.push(
|
|
633
|
+
h12("pre", { class: "mcpe-mcp-tool-call-args" }, JSON.stringify(displayArgs.value, null, 2))
|
|
634
|
+
);
|
|
635
|
+
}
|
|
636
|
+
if (status === "running") {
|
|
637
|
+
children.push(
|
|
638
|
+
h12(
|
|
639
|
+
"div",
|
|
640
|
+
{
|
|
641
|
+
class: "mcpe-mcp-tool-call-progress",
|
|
642
|
+
role: "progressbar",
|
|
643
|
+
"aria-label": "Tool running"
|
|
644
|
+
},
|
|
645
|
+
[h12("div", { class: "mcpe-mcp-tool-call-progress-bar", style: "width: 60%" })]
|
|
646
|
+
)
|
|
647
|
+
);
|
|
648
|
+
}
|
|
649
|
+
if (status === "done" && snap.value.result) {
|
|
650
|
+
children.push(
|
|
651
|
+
h12(
|
|
652
|
+
"div",
|
|
653
|
+
{ class: "mcpe-mcp-tool-call-result mcpe-mcp-tool-call-result-done" },
|
|
654
|
+
textBlocks.value.map((b) => h12("p", { class: "whitespace-pre-wrap text-sm" }, b.text))
|
|
655
|
+
)
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
if (status === "error" && snap.value.error) {
|
|
659
|
+
children.push(
|
|
660
|
+
h12("div", { class: "mcpe-mcp-tool-call-result mcpe-mcp-tool-call-result-error" }, [
|
|
661
|
+
h12("p", { class: "text-sm" }, snap.value.error.message),
|
|
662
|
+
h12(
|
|
663
|
+
"button",
|
|
664
|
+
{
|
|
665
|
+
class: "text-xs underline underline-offset-2",
|
|
666
|
+
type: "button",
|
|
667
|
+
onClick: () => emit("retry")
|
|
668
|
+
},
|
|
669
|
+
"Retry"
|
|
670
|
+
)
|
|
671
|
+
])
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
return h12("div", { class: cn12("mcpe-mcp-tool-call", props.class) }, children);
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
// src/mcp/mcp-tool-form.ts
|
|
680
|
+
import { defineComponent as defineComponent13, h as h13, reactive, computed as computed11, watch as watch3 } from "vue";
|
|
681
|
+
import { cn as cn13, schemaToFields } from "@mcp-elements/core";
|
|
682
|
+
var McpeMcpToolForm = defineComponent13({
|
|
683
|
+
name: "McpeMcpToolForm",
|
|
684
|
+
props: {
|
|
685
|
+
schema: { type: Object, required: true },
|
|
686
|
+
loading: { type: Boolean, default: false },
|
|
687
|
+
submitLabel: { type: String, default: "Run" },
|
|
688
|
+
class: { type: String, default: "" }
|
|
689
|
+
},
|
|
690
|
+
emits: ["submit"],
|
|
691
|
+
setup(props, { emit }) {
|
|
692
|
+
const fields = computed11(() => schemaToFields(props.schema));
|
|
693
|
+
const values = reactive({});
|
|
694
|
+
watch3(
|
|
695
|
+
fields,
|
|
696
|
+
(fs) => {
|
|
697
|
+
for (const k of Object.keys(values)) delete values[k];
|
|
698
|
+
for (const f of fs) {
|
|
699
|
+
if (f.defaultValue !== void 0) values[f.key] = f.defaultValue;
|
|
700
|
+
}
|
|
701
|
+
},
|
|
702
|
+
{ immediate: true }
|
|
703
|
+
);
|
|
704
|
+
const getStr = (key) => {
|
|
705
|
+
const v = values[key];
|
|
706
|
+
return v == null ? "" : String(v);
|
|
707
|
+
};
|
|
708
|
+
const getBool = (key) => Boolean(values[key]);
|
|
709
|
+
const inputType = (f) => f.kind === "email" ? "email" : f.kind === "url" ? "url" : f.kind === "date" ? "date" : "text";
|
|
710
|
+
const handleSubmit = (e) => {
|
|
711
|
+
e.preventDefault();
|
|
712
|
+
emit("submit", { ...values });
|
|
713
|
+
};
|
|
714
|
+
const submitButton = () => h13("div", { class: "mcpe-mcp-tool-form-submit" }, [
|
|
715
|
+
h13(
|
|
716
|
+
"button",
|
|
717
|
+
{
|
|
718
|
+
type: "submit",
|
|
719
|
+
class: "mcpe-btn mcpe-btn-primary mcpe-btn-sm",
|
|
720
|
+
disabled: props.loading
|
|
721
|
+
},
|
|
722
|
+
props.loading ? "Running\u2026" : props.submitLabel
|
|
723
|
+
)
|
|
724
|
+
]);
|
|
725
|
+
const fieldInput = (field) => {
|
|
726
|
+
switch (field.kind) {
|
|
727
|
+
case "switch":
|
|
728
|
+
return h13("input", {
|
|
729
|
+
type: "checkbox",
|
|
730
|
+
id: field.key,
|
|
731
|
+
class: "mcpe-switch",
|
|
732
|
+
checked: getBool(field.key),
|
|
733
|
+
onChange: (e) => {
|
|
734
|
+
values[field.key] = e.target.checked;
|
|
735
|
+
}
|
|
736
|
+
});
|
|
737
|
+
case "select":
|
|
738
|
+
return h13(
|
|
739
|
+
"select",
|
|
740
|
+
{
|
|
741
|
+
id: field.key,
|
|
742
|
+
class: "mcpe-select",
|
|
743
|
+
value: getStr(field.key),
|
|
744
|
+
onChange: (e) => {
|
|
745
|
+
values[field.key] = e.target.value;
|
|
746
|
+
}
|
|
747
|
+
},
|
|
748
|
+
[
|
|
749
|
+
h13("option", { value: "" }, "Select\u2026"),
|
|
750
|
+
...(field.options ?? []).map(
|
|
751
|
+
(opt) => h13("option", { value: opt.value }, opt.label)
|
|
752
|
+
)
|
|
753
|
+
]
|
|
754
|
+
);
|
|
755
|
+
case "textarea":
|
|
756
|
+
return h13("textarea", {
|
|
757
|
+
id: field.key,
|
|
758
|
+
class: "mcpe-textarea",
|
|
759
|
+
rows: 4,
|
|
760
|
+
value: getStr(field.key),
|
|
761
|
+
onInput: (e) => {
|
|
762
|
+
values[field.key] = e.target.value;
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
case "number":
|
|
766
|
+
return h13("input", {
|
|
767
|
+
type: "number",
|
|
768
|
+
id: field.key,
|
|
769
|
+
class: "mcpe-input",
|
|
770
|
+
value: getStr(field.key),
|
|
771
|
+
onInput: (e) => {
|
|
772
|
+
const raw = e.target.value;
|
|
773
|
+
values[field.key] = raw === "" ? void 0 : Number(raw);
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
default:
|
|
777
|
+
return h13("input", {
|
|
778
|
+
type: inputType(field),
|
|
779
|
+
id: field.key,
|
|
780
|
+
class: "mcpe-input",
|
|
781
|
+
value: getStr(field.key),
|
|
782
|
+
onInput: (e) => {
|
|
783
|
+
values[field.key] = e.target.value;
|
|
784
|
+
}
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
return () => {
|
|
789
|
+
if (fields.value.length === 0) {
|
|
790
|
+
return h13("form", { class: cn13("mcpe-mcp-tool-form", props.class), onSubmit: handleSubmit }, [
|
|
791
|
+
h13("p", { class: "text-sm text-muted-foreground" }, "This tool takes no inputs."),
|
|
792
|
+
submitButton()
|
|
793
|
+
]);
|
|
794
|
+
}
|
|
795
|
+
const fieldNodes = fields.value.map((field) => {
|
|
796
|
+
const children = [
|
|
797
|
+
h13(
|
|
798
|
+
"label",
|
|
799
|
+
{
|
|
800
|
+
for: field.key,
|
|
801
|
+
class: cn13(
|
|
802
|
+
"mcpe-mcp-tool-form-label",
|
|
803
|
+
field.required ? "mcpe-mcp-tool-form-label-required" : ""
|
|
804
|
+
)
|
|
805
|
+
},
|
|
806
|
+
field.label
|
|
807
|
+
),
|
|
808
|
+
fieldInput(field)
|
|
809
|
+
];
|
|
810
|
+
if (field.help) {
|
|
811
|
+
children.push(h13("p", { class: "mcpe-mcp-tool-form-help" }, field.help));
|
|
812
|
+
}
|
|
813
|
+
return h13("div", { class: "mcpe-mcp-tool-form-field" }, children);
|
|
814
|
+
});
|
|
815
|
+
return h13("form", { class: cn13("mcpe-mcp-tool-form", props.class), onSubmit: handleSubmit }, [
|
|
816
|
+
...fieldNodes,
|
|
817
|
+
submitButton()
|
|
818
|
+
]);
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
// src/mcp/mcp-consent-dialog.ts
|
|
824
|
+
import {
|
|
825
|
+
defineComponent as defineComponent14,
|
|
826
|
+
h as h14,
|
|
827
|
+
computed as computed12,
|
|
828
|
+
watch as watch4,
|
|
829
|
+
onMounted as onMounted2,
|
|
830
|
+
onUnmounted as onUnmounted3,
|
|
831
|
+
Teleport as Teleport2
|
|
832
|
+
} from "vue";
|
|
833
|
+
import { parseScopes } from "@mcp-elements/core";
|
|
834
|
+
var McpeMcpConsentDialog = defineComponent14({
|
|
835
|
+
name: "McpeMcpConsentDialog",
|
|
836
|
+
props: {
|
|
837
|
+
open: { type: Boolean, required: true },
|
|
838
|
+
serverName: { type: String, required: true },
|
|
839
|
+
serverIcon: { type: String, default: void 0 },
|
|
840
|
+
scopes: { type: Array, default: () => [] }
|
|
841
|
+
},
|
|
842
|
+
emits: ["approve", "deny"],
|
|
843
|
+
setup(props, { emit }) {
|
|
844
|
+
const parsedScopes = computed12(() => parseScopes(props.scopes.join(" ")));
|
|
845
|
+
const approve = () => emit("approve");
|
|
846
|
+
const deny = () => emit("deny");
|
|
847
|
+
let unlockScroll = null;
|
|
848
|
+
const lockScroll = () => {
|
|
849
|
+
const prev = document.body.style.overflow;
|
|
850
|
+
document.body.style.overflow = "hidden";
|
|
851
|
+
return () => {
|
|
852
|
+
document.body.style.overflow = prev;
|
|
853
|
+
};
|
|
854
|
+
};
|
|
855
|
+
watch4(
|
|
856
|
+
() => props.open,
|
|
857
|
+
(isOpen) => {
|
|
858
|
+
if (isOpen) {
|
|
859
|
+
unlockScroll = lockScroll();
|
|
860
|
+
} else if (unlockScroll) {
|
|
861
|
+
unlockScroll();
|
|
862
|
+
unlockScroll = null;
|
|
863
|
+
}
|
|
864
|
+
},
|
|
865
|
+
{ immediate: true }
|
|
866
|
+
);
|
|
867
|
+
const handleKeydown = (e) => {
|
|
868
|
+
if (e.key === "Escape" && props.open) deny();
|
|
869
|
+
};
|
|
870
|
+
onMounted2(() => document.addEventListener("keydown", handleKeydown));
|
|
871
|
+
onUnmounted3(() => {
|
|
872
|
+
document.removeEventListener("keydown", handleKeydown);
|
|
873
|
+
if (unlockScroll) unlockScroll();
|
|
874
|
+
});
|
|
875
|
+
return () => {
|
|
876
|
+
if (!props.open) return h14("span", { style: "display:none" });
|
|
877
|
+
const iconChild = props.serverIcon ? h14("img", { src: props.serverIcon, alt: "", class: "h-full w-full object-cover" }) : props.serverName[0]?.toUpperCase() ?? "?";
|
|
878
|
+
return h14(Teleport2, { to: "body" }, [
|
|
879
|
+
h14("div", { class: "mcpe-dialog-overlay", onClick: deny }),
|
|
880
|
+
h14(
|
|
881
|
+
"div",
|
|
882
|
+
{
|
|
883
|
+
class: "mcpe-dialog-content",
|
|
884
|
+
role: "dialog",
|
|
885
|
+
"aria-modal": "true",
|
|
886
|
+
"aria-label": `Allow ${props.serverName}?`,
|
|
887
|
+
onClick: (e) => e.stopPropagation()
|
|
888
|
+
},
|
|
889
|
+
[
|
|
890
|
+
h14("div", { class: "mcpe-mcp-consent-dialog-server" }, [
|
|
891
|
+
h14("div", { class: "mcpe-mcp-consent-dialog-icon", "aria-hidden": "true" }, [iconChild]),
|
|
892
|
+
h14("div", {}, [
|
|
893
|
+
h14("p", { class: "mcpe-mcp-consent-dialog-server-name" }, props.serverName),
|
|
894
|
+
h14("p", { class: "mcpe-mcp-consent-dialog-server-meta" }, "is requesting access to")
|
|
895
|
+
])
|
|
896
|
+
]),
|
|
897
|
+
h14(
|
|
898
|
+
"div",
|
|
899
|
+
{
|
|
900
|
+
class: "mcpe-mcp-consent-dialog-scopes",
|
|
901
|
+
role: "list",
|
|
902
|
+
"aria-label": "Requested permissions"
|
|
903
|
+
},
|
|
904
|
+
parsedScopes.value.map(
|
|
905
|
+
(s) => h14("div", { class: "mcpe-mcp-consent-dialog-scope-item", role: "listitem" }, [
|
|
906
|
+
h14("div", { class: "flex-1 min-w-0" }, [
|
|
907
|
+
h14("p", { class: "mcpe-mcp-consent-dialog-scope-resource" }, s.resource),
|
|
908
|
+
h14(
|
|
909
|
+
"div",
|
|
910
|
+
{ class: "mcpe-mcp-consent-dialog-scope-perms" },
|
|
911
|
+
s.permissions.map(
|
|
912
|
+
(p) => h14("span", { class: "mcpe-mcp-consent-dialog-scope-perm" }, p)
|
|
913
|
+
)
|
|
914
|
+
)
|
|
915
|
+
])
|
|
916
|
+
])
|
|
917
|
+
)
|
|
918
|
+
),
|
|
919
|
+
h14("div", { class: "mcpe-mcp-consent-dialog-actions" }, [
|
|
920
|
+
h14(
|
|
921
|
+
"button",
|
|
922
|
+
{ type: "button", class: "mcpe-btn mcpe-btn-outline flex-1", onClick: deny },
|
|
923
|
+
"Deny"
|
|
924
|
+
),
|
|
925
|
+
h14(
|
|
926
|
+
"button",
|
|
927
|
+
{ type: "button", class: "mcpe-btn mcpe-btn-primary flex-1", onClick: approve },
|
|
928
|
+
"Allow"
|
|
929
|
+
)
|
|
930
|
+
])
|
|
931
|
+
]
|
|
932
|
+
)
|
|
933
|
+
]);
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
});
|
|
937
|
+
|
|
938
|
+
// src/mcp/mcp-scope-inspector.ts
|
|
939
|
+
import { defineComponent as defineComponent15, h as h15, ref as ref2, computed as computed13 } from "vue";
|
|
940
|
+
import { cn as cn14, parseScopes as parseScopes2 } from "@mcp-elements/core";
|
|
941
|
+
var McpeMcpScopeInspector = defineComponent15({
|
|
942
|
+
name: "McpeMcpScopeInspector",
|
|
943
|
+
props: {
|
|
944
|
+
scopes: {
|
|
945
|
+
type: [String, Array],
|
|
946
|
+
default: ""
|
|
947
|
+
},
|
|
948
|
+
descriptions: {
|
|
949
|
+
type: Object,
|
|
950
|
+
default: () => ({})
|
|
951
|
+
},
|
|
952
|
+
class: { type: String, default: "" }
|
|
953
|
+
},
|
|
954
|
+
setup(props) {
|
|
955
|
+
const parsed = computed13(
|
|
956
|
+
() => typeof props.scopes === "string" ? parseScopes2(props.scopes) : props.scopes
|
|
957
|
+
);
|
|
958
|
+
const openKeys = ref2(/* @__PURE__ */ new Set());
|
|
959
|
+
const isOpen = (key) => openKeys.value.has(key);
|
|
960
|
+
const toggle = (key) => {
|
|
961
|
+
const next = new Set(openKeys.value);
|
|
962
|
+
if (next.has(key)) next.delete(key);
|
|
963
|
+
else next.add(key);
|
|
964
|
+
openKeys.value = next;
|
|
965
|
+
};
|
|
966
|
+
const getDescription = (s) => props.descriptions[s.raw] ?? props.descriptions[s.resource] ?? s.description;
|
|
967
|
+
return () => h15(
|
|
968
|
+
"div",
|
|
969
|
+
{ class: cn14("mcpe-mcp-scope-inspector", props.class), role: "list" },
|
|
970
|
+
parsed.value.map((s) => {
|
|
971
|
+
const open = isOpen(s.raw);
|
|
972
|
+
const desc = getDescription(s);
|
|
973
|
+
const itemChildren = [
|
|
974
|
+
h15(
|
|
975
|
+
"button",
|
|
976
|
+
{
|
|
977
|
+
type: "button",
|
|
978
|
+
class: "mcpe-mcp-scope-inspector-trigger",
|
|
979
|
+
"aria-expanded": open,
|
|
980
|
+
onClick: () => toggle(s.raw)
|
|
981
|
+
},
|
|
982
|
+
[
|
|
983
|
+
h15("div", { class: "flex items-center gap-3" }, [
|
|
984
|
+
h15("span", { class: "mcpe-mcp-scope-inspector-resource" }, s.resource),
|
|
985
|
+
h15(
|
|
986
|
+
"div",
|
|
987
|
+
{ class: "mcpe-mcp-scope-inspector-perms" },
|
|
988
|
+
s.permissions.map(
|
|
989
|
+
(p) => h15("span", { class: "mcpe-mcp-scope-inspector-perm" }, p)
|
|
990
|
+
)
|
|
991
|
+
)
|
|
992
|
+
]),
|
|
993
|
+
h15(
|
|
994
|
+
"svg",
|
|
995
|
+
{
|
|
996
|
+
class: cn14(
|
|
997
|
+
"mcpe-mcp-scope-inspector-chevron",
|
|
998
|
+
open ? "mcpe-mcp-scope-inspector-chevron-open" : ""
|
|
999
|
+
),
|
|
1000
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1001
|
+
viewBox: "0 0 24 24",
|
|
1002
|
+
fill: "none",
|
|
1003
|
+
stroke: "currentColor",
|
|
1004
|
+
"stroke-width": "2",
|
|
1005
|
+
"stroke-linecap": "round",
|
|
1006
|
+
"stroke-linejoin": "round",
|
|
1007
|
+
"aria-hidden": "true"
|
|
1008
|
+
},
|
|
1009
|
+
[h15("path", { d: "m6 9 6 6 6-6" })]
|
|
1010
|
+
)
|
|
1011
|
+
]
|
|
1012
|
+
)
|
|
1013
|
+
];
|
|
1014
|
+
if (open && desc) {
|
|
1015
|
+
itemChildren.push(
|
|
1016
|
+
h15("div", { role: "region", class: "mcpe-mcp-scope-inspector-body" }, desc)
|
|
1017
|
+
);
|
|
1018
|
+
}
|
|
1019
|
+
return h15(
|
|
1020
|
+
"div",
|
|
1021
|
+
{ class: "mcpe-mcp-scope-inspector-item", role: "listitem" },
|
|
1022
|
+
itemChildren
|
|
1023
|
+
);
|
|
1024
|
+
})
|
|
1025
|
+
);
|
|
1026
|
+
}
|
|
1027
|
+
});
|
|
1028
|
+
|
|
1029
|
+
// src/mcp/mcp-resource-browser.ts
|
|
1030
|
+
import { defineComponent as defineComponent16, h as h16 } from "vue";
|
|
1031
|
+
import { cn as cn15 } from "@mcp-elements/core";
|
|
1032
|
+
function mimeTypeLabel(mimeType) {
|
|
1033
|
+
if (!mimeType) return "res";
|
|
1034
|
+
if (mimeType.includes("json")) return "json";
|
|
1035
|
+
if (mimeType.includes("text")) return "txt";
|
|
1036
|
+
if (mimeType.includes("image")) return "img";
|
|
1037
|
+
if (mimeType.includes("pdf")) return "pdf";
|
|
1038
|
+
return mimeType.split("/")[1]?.slice(0, 4) ?? "res";
|
|
1039
|
+
}
|
|
1040
|
+
var McpeMcpResourceBrowser = defineComponent16({
|
|
1041
|
+
name: "McpeMcpResourceBrowser",
|
|
1042
|
+
props: {
|
|
1043
|
+
resources: { type: Array, default: () => [] },
|
|
1044
|
+
selectedUri: { type: String, default: void 0 },
|
|
1045
|
+
loading: { type: Boolean, default: false },
|
|
1046
|
+
class: { type: String, default: "" }
|
|
1047
|
+
},
|
|
1048
|
+
emits: ["select"],
|
|
1049
|
+
setup(props, { emit }) {
|
|
1050
|
+
return () => {
|
|
1051
|
+
if (props.loading) {
|
|
1052
|
+
return h16(
|
|
1053
|
+
"div",
|
|
1054
|
+
{ class: cn15("mcpe-mcp-resource-browser", props.class) },
|
|
1055
|
+
[1, 2, 3, 4].map(
|
|
1056
|
+
() => h16("div", { class: "flex items-center gap-3 px-3 py-2.5" }, [
|
|
1057
|
+
h16("div", { class: "h-8 w-8 rounded-md animate-pulse bg-muted" }),
|
|
1058
|
+
h16("div", { class: "h-4 flex-1 rounded animate-pulse bg-muted" })
|
|
1059
|
+
])
|
|
1060
|
+
)
|
|
1061
|
+
);
|
|
1062
|
+
}
|
|
1063
|
+
if (props.resources.length === 0) {
|
|
1064
|
+
return h16("div", { class: cn15("mcpe-mcp-resource-browser", props.class) }, [
|
|
1065
|
+
h16("p", { class: "mcpe-mcp-resource-browser-empty" }, "No resources available")
|
|
1066
|
+
]);
|
|
1067
|
+
}
|
|
1068
|
+
return h16(
|
|
1069
|
+
"div",
|
|
1070
|
+
{ class: cn15("mcpe-mcp-resource-browser", props.class), role: "list" },
|
|
1071
|
+
props.resources.map((r) => {
|
|
1072
|
+
const selected = props.selectedUri === r.uri;
|
|
1073
|
+
const children = [
|
|
1074
|
+
h16(
|
|
1075
|
+
"span",
|
|
1076
|
+
{ class: "mcpe-mcp-resource-browser-icon", "aria-hidden": "true" },
|
|
1077
|
+
mimeTypeLabel(r.mimeType)
|
|
1078
|
+
),
|
|
1079
|
+
h16("span", { class: "mcpe-mcp-resource-browser-name" }, r.name)
|
|
1080
|
+
];
|
|
1081
|
+
if (r.mimeType) {
|
|
1082
|
+
children.push(
|
|
1083
|
+
h16("span", { class: "mcpe-mcp-resource-browser-type" }, r.mimeType.split("/")[0])
|
|
1084
|
+
);
|
|
1085
|
+
}
|
|
1086
|
+
return h16(
|
|
1087
|
+
"button",
|
|
1088
|
+
{
|
|
1089
|
+
type: "button",
|
|
1090
|
+
role: "listitem",
|
|
1091
|
+
class: cn15(
|
|
1092
|
+
"mcpe-mcp-resource-browser-item w-full text-left",
|
|
1093
|
+
selected ? "mcpe-mcp-resource-browser-item-selected" : ""
|
|
1094
|
+
),
|
|
1095
|
+
"aria-selected": selected,
|
|
1096
|
+
"aria-label": r.name,
|
|
1097
|
+
onClick: () => emit("select", r)
|
|
1098
|
+
},
|
|
1099
|
+
children
|
|
1100
|
+
);
|
|
1101
|
+
})
|
|
1102
|
+
);
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
});
|
|
1106
|
+
|
|
1107
|
+
// src/mcp/mcp-app-frame.ts
|
|
1108
|
+
import { defineComponent as defineComponent17, h as h17, ref as ref3, watch as watch5, onUnmounted as onUnmounted4 } from "vue";
|
|
1109
|
+
import { cn as cn16, createAppBridge } from "@mcp-elements/core";
|
|
1110
|
+
var McpeMcpAppFrame = defineComponent17({
|
|
1111
|
+
name: "McpeMcpAppFrame",
|
|
1112
|
+
props: {
|
|
1113
|
+
src: { type: String, required: true },
|
|
1114
|
+
height: { type: Number, default: 480 },
|
|
1115
|
+
sandbox: { type: String, default: "allow-scripts allow-same-origin" },
|
|
1116
|
+
class: { type: String, default: "" }
|
|
1117
|
+
},
|
|
1118
|
+
emits: ["message"],
|
|
1119
|
+
setup(props, { emit }) {
|
|
1120
|
+
const frameRef = ref3(null);
|
|
1121
|
+
let bridge = null;
|
|
1122
|
+
let unsub = null;
|
|
1123
|
+
let messageHandler = null;
|
|
1124
|
+
const cleanup = () => {
|
|
1125
|
+
if (unsub) unsub();
|
|
1126
|
+
if (messageHandler) window.removeEventListener("message", messageHandler);
|
|
1127
|
+
unsub = null;
|
|
1128
|
+
messageHandler = null;
|
|
1129
|
+
bridge = null;
|
|
1130
|
+
};
|
|
1131
|
+
const setup = () => {
|
|
1132
|
+
cleanup();
|
|
1133
|
+
bridge = createAppBridge({
|
|
1134
|
+
postMessage: (env) => frameRef.value?.contentWindow?.postMessage(env, "*")
|
|
1135
|
+
});
|
|
1136
|
+
unsub = bridge.onMessage((env) => emit("message", env));
|
|
1137
|
+
messageHandler = (e) => bridge?.receive(e.data);
|
|
1138
|
+
window.addEventListener("message", messageHandler);
|
|
1139
|
+
};
|
|
1140
|
+
watch5([frameRef, () => props.src], () => {
|
|
1141
|
+
if (frameRef.value) setup();
|
|
1142
|
+
});
|
|
1143
|
+
onUnmounted4(cleanup);
|
|
1144
|
+
return () => h17("div", { class: cn16("mcpe-mcp-app-frame", props.class) }, [
|
|
1145
|
+
h17("iframe", {
|
|
1146
|
+
ref: frameRef,
|
|
1147
|
+
src: props.src,
|
|
1148
|
+
sandbox: props.sandbox,
|
|
1149
|
+
height: `${props.height}px`,
|
|
1150
|
+
title: "MCP App",
|
|
1151
|
+
"aria-label": "MCP App frame",
|
|
1152
|
+
style: "display:block;width:100%;border:none"
|
|
1153
|
+
})
|
|
1154
|
+
]);
|
|
1155
|
+
}
|
|
1156
|
+
});
|
|
1157
|
+
|
|
1158
|
+
// src/composables/use-mcp-tool-state.ts
|
|
1159
|
+
import { ref as ref4, onUnmounted as onUnmounted5 } from "vue";
|
|
1160
|
+
import { createToolState } from "@mcp-elements/core";
|
|
1161
|
+
function useMcpToolState() {
|
|
1162
|
+
const api = createToolState();
|
|
1163
|
+
const snapshot = ref4({
|
|
1164
|
+
status: api.status,
|
|
1165
|
+
tool: api.tool,
|
|
1166
|
+
args: api.args,
|
|
1167
|
+
result: api.result,
|
|
1168
|
+
error: api.error,
|
|
1169
|
+
startedAt: api.startedAt,
|
|
1170
|
+
endedAt: api.endedAt
|
|
1171
|
+
});
|
|
1172
|
+
const unsub = api.subscribe((s) => {
|
|
1173
|
+
snapshot.value = { ...s };
|
|
1174
|
+
});
|
|
1175
|
+
onUnmounted5(unsub);
|
|
1176
|
+
return { api, snapshot };
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
// src/composables/use-mcp-oauth.ts
|
|
1180
|
+
import { ref as ref5, onUnmounted as onUnmounted6 } from "vue";
|
|
1181
|
+
import { createOAuthFlow } from "@mcp-elements/core";
|
|
1182
|
+
function useMcpOAuth() {
|
|
1183
|
+
const api = createOAuthFlow();
|
|
1184
|
+
const snapshot = ref5({
|
|
1185
|
+
status: api.status,
|
|
1186
|
+
verifier: api.verifier,
|
|
1187
|
+
state: api.state,
|
|
1188
|
+
tokens: api.tokens,
|
|
1189
|
+
error: api.error
|
|
1190
|
+
});
|
|
1191
|
+
const unsub = api.subscribe((s) => {
|
|
1192
|
+
snapshot.value = { ...s };
|
|
1193
|
+
});
|
|
1194
|
+
onUnmounted6(unsub);
|
|
1195
|
+
return { api, snapshot };
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
// src/composables/use-mcp-app-bridge.ts
|
|
1199
|
+
import { ref as ref6, watch as watch6, onUnmounted as onUnmounted7 } from "vue";
|
|
1200
|
+
import { createAppBridge as createAppBridge2 } from "@mcp-elements/core";
|
|
1201
|
+
function useMcpAppBridge(options = {}) {
|
|
1202
|
+
const frameRef = ref6(null);
|
|
1203
|
+
let bridge = null;
|
|
1204
|
+
let unsub = null;
|
|
1205
|
+
let messageHandler = null;
|
|
1206
|
+
const cleanup = () => {
|
|
1207
|
+
if (unsub) unsub();
|
|
1208
|
+
if (messageHandler) window.removeEventListener("message", messageHandler);
|
|
1209
|
+
unsub = null;
|
|
1210
|
+
messageHandler = null;
|
|
1211
|
+
bridge = null;
|
|
1212
|
+
};
|
|
1213
|
+
const establish = () => {
|
|
1214
|
+
cleanup();
|
|
1215
|
+
bridge = createAppBridge2({
|
|
1216
|
+
postMessage: (env) => frameRef.value?.contentWindow?.postMessage(env, "*")
|
|
1217
|
+
});
|
|
1218
|
+
if (options.onMessage) unsub = bridge.onMessage(options.onMessage);
|
|
1219
|
+
messageHandler = (e) => bridge?.receive(e.data);
|
|
1220
|
+
window.addEventListener("message", messageHandler);
|
|
1221
|
+
};
|
|
1222
|
+
watch6(frameRef, (el) => {
|
|
1223
|
+
if (el) establish();
|
|
1224
|
+
});
|
|
1225
|
+
onUnmounted7(cleanup);
|
|
1226
|
+
const send = (env) => bridge?.send(env);
|
|
1227
|
+
return { frameRef, send };
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
// src/composables/use-mcp-schema-form.ts
|
|
1231
|
+
import { reactive as reactive2, computed as computed14, watch as watch7 } from "vue";
|
|
1232
|
+
import { schemaToFields as schemaToFields2 } from "@mcp-elements/core";
|
|
1233
|
+
function useMcpSchemaForm(schema) {
|
|
1234
|
+
const getSchema = typeof schema === "function" ? schema : () => schema;
|
|
1235
|
+
const fields = computed14(() => schemaToFields2(getSchema()));
|
|
1236
|
+
const values = reactive2({});
|
|
1237
|
+
const reset = () => {
|
|
1238
|
+
for (const k of Object.keys(values)) delete values[k];
|
|
1239
|
+
for (const f of fields.value) {
|
|
1240
|
+
if (f.defaultValue !== void 0) values[f.key] = f.defaultValue;
|
|
1241
|
+
}
|
|
1242
|
+
};
|
|
1243
|
+
watch7(fields, reset, { immediate: true });
|
|
1244
|
+
const setValue = (key, value) => {
|
|
1245
|
+
values[key] = value;
|
|
1246
|
+
};
|
|
1247
|
+
return { fields, values, setValue, reset };
|
|
1248
|
+
}
|
|
500
1249
|
export {
|
|
501
1250
|
McpeAlert,
|
|
502
1251
|
McpeBadge,
|
|
@@ -509,9 +1258,20 @@ export {
|
|
|
509
1258
|
McpeCardTitle,
|
|
510
1259
|
McpeDialog,
|
|
511
1260
|
McpeInput,
|
|
1261
|
+
McpeMcpAppFrame,
|
|
1262
|
+
McpeMcpConsentDialog,
|
|
1263
|
+
McpeMcpResourceBrowser,
|
|
1264
|
+
McpeMcpScopeInspector,
|
|
1265
|
+
McpeMcpServerStatus,
|
|
1266
|
+
McpeMcpToolCall,
|
|
1267
|
+
McpeMcpToolForm,
|
|
512
1268
|
McpeSelect,
|
|
513
1269
|
McpeSwitch,
|
|
514
1270
|
McpeTabs,
|
|
515
|
-
McpeTextarea
|
|
1271
|
+
McpeTextarea,
|
|
1272
|
+
useMcpAppBridge,
|
|
1273
|
+
useMcpOAuth,
|
|
1274
|
+
useMcpSchemaForm,
|
|
1275
|
+
useMcpToolState
|
|
516
1276
|
};
|
|
517
1277
|
//# sourceMappingURL=index.js.map
|