@kontent-ai/mcp-server 0.30.0 → 0.31.0
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.
|
@@ -10,6 +10,18 @@ class OperationResultIncompleteError extends Error {
|
|
|
10
10
|
this.name = "OperationResultIncompleteError";
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
+
const isSearchResponseWrapper = (value) => typeof value === "object" && value !== null && "searchResults" in value;
|
|
14
|
+
const extractSearchResults = (response) => {
|
|
15
|
+
const value = response.result?.value;
|
|
16
|
+
if (!value) {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
const parsed = JSON.parse(value);
|
|
20
|
+
if (isSearchResponseWrapper(parsed)) {
|
|
21
|
+
return JSON.parse(parsed.searchResults);
|
|
22
|
+
}
|
|
23
|
+
return parsed;
|
|
24
|
+
};
|
|
13
25
|
export const registerTool = (server) => {
|
|
14
26
|
server.tool("search-variants-mapi", "AI semantic search for Kontent.ai content by topic/theme (max 50 results). Use filter-variants-mapi for exact keywords. May be unavailable.", searchOperationSchema.shape, async ({ searchPhrase, filter }, { authInfo: { token, clientId } = {} }) => {
|
|
15
27
|
try {
|
|
@@ -84,8 +96,9 @@ export const registerTool = (server) => {
|
|
|
84
96
|
maxTimeout: 10000,
|
|
85
97
|
factor: 1.5,
|
|
86
98
|
});
|
|
99
|
+
const searchResults = extractSearchResults(resultData);
|
|
87
100
|
return createMcpToolSuccessResponse({
|
|
88
|
-
result:
|
|
101
|
+
result: searchResults,
|
|
89
102
|
});
|
|
90
103
|
}
|
|
91
104
|
catch (error) {
|