modality-kit 0.14.12 → 0.14.13
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.js +10 -5
- package/dist/types/util_response.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36,10 +36,11 @@ var ContentType = [
|
|
|
36
36
|
"resource_link",
|
|
37
37
|
"resource"
|
|
38
38
|
];
|
|
39
|
-
function mergeResponsesContent(
|
|
39
|
+
function mergeResponsesContent(content) {
|
|
40
40
|
const contentData = content ? structuredClone(content) : null;
|
|
41
|
+
const contentBlock = new Array;
|
|
41
42
|
if (Array.isArray(contentData)) {
|
|
42
|
-
|
|
43
|
+
contentBlock.push(...contentData.map((item) => {
|
|
43
44
|
if (typeof item === "string") {
|
|
44
45
|
return { type: "text", text: item };
|
|
45
46
|
} else if (item.type && ContentType.includes(item.type)) {
|
|
@@ -49,12 +50,12 @@ function mergeResponsesContent(result, content) {
|
|
|
49
50
|
}
|
|
50
51
|
}));
|
|
51
52
|
} else if (contentData != null) {
|
|
52
|
-
|
|
53
|
+
contentBlock.push({
|
|
53
54
|
type: "text",
|
|
54
55
|
text: typeof contentData === "string" ? contentData : JSON.stringify(contentData)
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
|
-
return
|
|
58
|
+
return contentBlock;
|
|
58
59
|
}
|
|
59
60
|
function formatSuccessResponse(successData, content) {
|
|
60
61
|
const data = structuredClone(successData);
|
|
@@ -67,7 +68,11 @@ function formatSuccessResponse(successData, content) {
|
|
|
67
68
|
}
|
|
68
69
|
]
|
|
69
70
|
};
|
|
70
|
-
|
|
71
|
+
const contetnBlock = mergeResponsesContent(content);
|
|
72
|
+
if (contetnBlock.length > 0) {
|
|
73
|
+
result.content.push(...contetnBlock);
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
71
76
|
}
|
|
72
77
|
function formatErrorResponse(errorData, operation, meta) {
|
|
73
78
|
let errorResponse;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
1
|
+
import type { CallToolResult, ContentBlock } from "@modelcontextprotocol/sdk/types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Utility functions for formatting MCP responses
|
|
4
4
|
*
|
|
@@ -25,7 +25,7 @@ interface ErrorData extends Record<string, any> {
|
|
|
25
25
|
message: string;
|
|
26
26
|
operation?: string;
|
|
27
27
|
}
|
|
28
|
-
export declare function mergeResponsesContent(
|
|
28
|
+
export declare function mergeResponsesContent(content: any): ContentBlock[];
|
|
29
29
|
export declare function formatSuccessResponse(successData: SuccessData, content?: any): CallToolResult;
|
|
30
30
|
/**
|
|
31
31
|
* Format an error response for MCP tools using generic error data
|
package/package.json
CHANGED