tiny-stdio-mcp-server 0.1.3 → 0.1.4
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/content/convert.js +24 -5
- package/dist/server.js +32 -17
- package/package.json +1 -1
package/dist/content/convert.js
CHANGED
|
@@ -32,11 +32,30 @@ export function toContentBlocks(result) {
|
|
|
32
32
|
return [convertSingleValue(result)];
|
|
33
33
|
}
|
|
34
34
|
function isContentBlock(value) {
|
|
35
|
-
if (!("type"
|
|
35
|
+
if (!hasOwnProperty(value, "type") || typeof value.type !== "string") {
|
|
36
36
|
return false;
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
value.
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
if (value.type === "text") {
|
|
39
|
+
return hasOwnProperty(value, "text") && typeof value.text === "string";
|
|
40
|
+
}
|
|
41
|
+
if (value.type === "image" || value.type === "audio") {
|
|
42
|
+
return hasOwnProperty(value, "data")
|
|
43
|
+
&& typeof value.data === "string"
|
|
44
|
+
&& hasOwnProperty(value, "mimeType")
|
|
45
|
+
&& typeof value.mimeType === "string";
|
|
46
|
+
}
|
|
47
|
+
if (value.type !== "resource" || !hasOwnProperty(value, "resource")) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
const resource = value.resource;
|
|
51
|
+
return typeof resource === "object"
|
|
52
|
+
&& resource !== null
|
|
53
|
+
&& hasOwnProperty(resource, "uri")
|
|
54
|
+
&& typeof resource.uri === "string"
|
|
55
|
+
&& (!hasOwnProperty(resource, "mimeType") || typeof resource.mimeType === "string")
|
|
56
|
+
&& ((hasOwnProperty(resource, "text") && typeof resource.text === "string")
|
|
57
|
+
|| (hasOwnProperty(resource, "blob") && typeof resource.blob === "string"));
|
|
58
|
+
}
|
|
59
|
+
function hasOwnProperty(value, name) {
|
|
60
|
+
return Object.prototype.hasOwnProperty.call(value, name);
|
|
42
61
|
}
|
package/dist/server.js
CHANGED
|
@@ -574,55 +574,67 @@ function isCallToolResult(value) {
|
|
|
574
574
|
return hasContentArray(value) && value.content.every(isContentItem);
|
|
575
575
|
}
|
|
576
576
|
function isGetPromptResult(value) {
|
|
577
|
-
if (typeof value !== "object" || value === null || !("messages"
|
|
577
|
+
if (typeof value !== "object" || value === null || !hasOwnProperty(value, "messages")) {
|
|
578
578
|
return false;
|
|
579
579
|
}
|
|
580
580
|
return Array.isArray(value.messages)
|
|
581
581
|
&& value.messages.every((message) => typeof message === "object"
|
|
582
582
|
&& message !== null
|
|
583
|
-
&& "role"
|
|
583
|
+
&& hasOwnProperty(message, "role")
|
|
584
584
|
&& (message.role === "user" || message.role === "assistant")
|
|
585
|
-
&& "content"
|
|
585
|
+
&& hasOwnProperty(message, "content")
|
|
586
586
|
&& isPromptContentItem(message.content));
|
|
587
587
|
}
|
|
588
588
|
function isReadResourceResult(value) {
|
|
589
|
-
if (typeof value !== "object" || value === null || !("contents"
|
|
589
|
+
if (typeof value !== "object" || value === null || !hasOwnProperty(value, "contents")) {
|
|
590
590
|
return false;
|
|
591
591
|
}
|
|
592
592
|
return Array.isArray(value.contents)
|
|
593
593
|
&& value.contents.every((content) => typeof content === "object"
|
|
594
594
|
&& content !== null
|
|
595
|
-
&& "uri"
|
|
595
|
+
&& hasOwnProperty(content, "uri")
|
|
596
596
|
&& typeof content.uri === "string"
|
|
597
597
|
&& isValidUri(content.uri)
|
|
598
|
-
&& (("text"
|
|
599
|
-
|| ("blob"
|
|
598
|
+
&& ((hasOwnProperty(content, "text") && typeof content.text === "string")
|
|
599
|
+
|| (hasOwnProperty(content, "blob") && typeof content.blob === "string" && isBase64(content.blob))));
|
|
600
600
|
}
|
|
601
601
|
function hasContentArray(value) {
|
|
602
|
-
return typeof value === "object" && value !== null && "content"
|
|
602
|
+
return typeof value === "object" && value !== null && hasOwnProperty(value, "content")
|
|
603
603
|
&& Array.isArray(value.content);
|
|
604
604
|
}
|
|
605
605
|
function isContentItem(value) {
|
|
606
|
-
if (typeof value !== "object" || value === null || !("type"
|
|
606
|
+
if (typeof value !== "object" || value === null || !hasOwnProperty(value, "type")) {
|
|
607
607
|
return false;
|
|
608
608
|
}
|
|
609
609
|
const block = value;
|
|
610
610
|
if (block.type === "text") {
|
|
611
|
-
return typeof block.text === "string";
|
|
611
|
+
return hasOwnProperty(block, "text") && typeof block.text === "string";
|
|
612
612
|
}
|
|
613
613
|
if (block.type === "image" || block.type === "audio") {
|
|
614
|
-
return
|
|
614
|
+
return hasOwnProperty(block, "data")
|
|
615
|
+
&& typeof block.data === "string"
|
|
616
|
+
&& isBase64(block.data)
|
|
617
|
+
&& hasOwnProperty(block, "mimeType")
|
|
618
|
+
&& typeof block.mimeType === "string";
|
|
615
619
|
}
|
|
616
620
|
if (block.type === "resource_link") {
|
|
617
|
-
return
|
|
621
|
+
return hasOwnProperty(block, "uri")
|
|
622
|
+
&& typeof block.uri === "string"
|
|
623
|
+
&& hasOwnProperty(block, "name")
|
|
624
|
+
&& typeof block.name === "string";
|
|
618
625
|
}
|
|
619
|
-
if (block.type !== "resource"
|
|
626
|
+
if (block.type !== "resource"
|
|
627
|
+
|| !hasOwnProperty(block, "resource")
|
|
628
|
+
|| typeof block.resource !== "object"
|
|
629
|
+
|| block.resource === null) {
|
|
620
630
|
return false;
|
|
621
631
|
}
|
|
622
632
|
const resource = block.resource;
|
|
623
|
-
return
|
|
624
|
-
&&
|
|
625
|
-
&& (
|
|
633
|
+
return hasOwnProperty(resource, "uri")
|
|
634
|
+
&& typeof resource.uri === "string"
|
|
635
|
+
&& (!hasOwnProperty(resource, "mimeType") || typeof resource.mimeType === "string")
|
|
636
|
+
&& ((hasOwnProperty(resource, "text") && typeof resource.text === "string")
|
|
637
|
+
|| (hasOwnProperty(resource, "blob") && typeof resource.blob === "string" && isBase64(resource.blob)));
|
|
626
638
|
}
|
|
627
639
|
function isBase64(value) {
|
|
628
640
|
if (value.length === 0) {
|
|
@@ -647,5 +659,8 @@ function isPromptContentItem(value) {
|
|
|
647
659
|
if (!isContentItem(value)) {
|
|
648
660
|
return false;
|
|
649
661
|
}
|
|
650
|
-
return !(typeof value === "object" && value !== null && "type"
|
|
662
|
+
return !(typeof value === "object" && value !== null && hasOwnProperty(value, "type") && value.type === "resource_link");
|
|
663
|
+
}
|
|
664
|
+
function hasOwnProperty(value, name) {
|
|
665
|
+
return Object.prototype.hasOwnProperty.call(value, name);
|
|
651
666
|
}
|