@kontent-ai/mcp-server 0.8.2 → 0.9.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.
package/README.md
CHANGED
|
@@ -88,6 +88,7 @@ npx @kontent-ai/mcp-server@latest sse
|
|
|
88
88
|
* **delete-content-item-mapi** – Delete a content item by internal ID
|
|
89
89
|
* **upsert-language-variant-mapi** – Create or update a language variant with content using internal IDs
|
|
90
90
|
* **delete-language-variant-mapi** – Delete a language variant of a content item by internal IDs
|
|
91
|
+
* **filter-variants-mapi** – Search and filter language variants using filters and search phrases
|
|
91
92
|
|
|
92
93
|
### Asset Management
|
|
93
94
|
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
.object({
|
|
4
|
-
id: z.string().optional(),
|
|
5
|
-
codename: z.string().optional(),
|
|
6
|
-
external_id: z.string().optional(),
|
|
7
|
-
})
|
|
8
|
-
.describe("An object with an id, codename, or external_id property referencing another item. Using id is preferred for better performance.");
|
|
2
|
+
import { referenceObjectSchema } from "./referenceObjectSchema.js";
|
|
9
3
|
const languageVariantElementBaseSchema = z.object({
|
|
10
4
|
element: referenceObjectSchema,
|
|
11
5
|
value: z.any(),
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { referenceObjectSchema } from "./referenceObjectSchema.js";
|
|
3
|
+
const userReferenceSchema = z.object({
|
|
4
|
+
id: z.string().optional().describe("User identifier"),
|
|
5
|
+
email: z.string().email().optional().describe("User email address"),
|
|
6
|
+
});
|
|
7
|
+
// Search variants tool input schema
|
|
8
|
+
export const filterVariantsSchema = z.object({
|
|
9
|
+
search_phrase: z
|
|
10
|
+
.string()
|
|
11
|
+
.optional()
|
|
12
|
+
.describe("Search phrase to look for in content"),
|
|
13
|
+
content_types: z
|
|
14
|
+
.array(referenceObjectSchema)
|
|
15
|
+
.min(1)
|
|
16
|
+
.optional()
|
|
17
|
+
.describe("Array of references to content types by their id, codename, or external id"),
|
|
18
|
+
contributors: z
|
|
19
|
+
.array(userReferenceSchema)
|
|
20
|
+
.min(1)
|
|
21
|
+
.optional()
|
|
22
|
+
.describe("Array of references to users by their id or email"),
|
|
23
|
+
completion_statuses: z
|
|
24
|
+
.array(z.enum(["unfinished", "completed", "not_translated", "all_done"]))
|
|
25
|
+
.min(1)
|
|
26
|
+
.optional()
|
|
27
|
+
.describe("Array of completion statuses to filter by. It is not the same thing as workflow steps, it reflects e.g. not filled in required elements"),
|
|
28
|
+
language: referenceObjectSchema
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Reference to a language by its id, codename, or external id (defaults to default language)"),
|
|
31
|
+
workflow_steps: z
|
|
32
|
+
.array(z.object({
|
|
33
|
+
workflow_identifier: referenceObjectSchema.describe("Reference to a workflow by its id, codename, or external id"),
|
|
34
|
+
step_identifiers: z
|
|
35
|
+
.array(referenceObjectSchema)
|
|
36
|
+
.min(1)
|
|
37
|
+
.describe("Array of references to workflow steps by their id, codename, or external id"),
|
|
38
|
+
}))
|
|
39
|
+
.min(1)
|
|
40
|
+
.optional()
|
|
41
|
+
.describe("Array of workflows with workflow steps"),
|
|
42
|
+
order_by: z
|
|
43
|
+
.enum(["name", "due", "last_modified"])
|
|
44
|
+
.optional()
|
|
45
|
+
.describe("Field to order by"),
|
|
46
|
+
order_direction: z
|
|
47
|
+
.enum(["asc", "desc"])
|
|
48
|
+
.optional()
|
|
49
|
+
.describe("Order direction"),
|
|
50
|
+
continuation_token: z
|
|
51
|
+
.string()
|
|
52
|
+
.optional()
|
|
53
|
+
.describe("Continuation token for pagination"),
|
|
54
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
// Define a reusable reference object schema
|
|
3
|
+
export const referenceObjectSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
id: z.string().optional(),
|
|
6
|
+
codename: z.string().optional(),
|
|
7
|
+
external_id: z.string().optional(),
|
|
8
|
+
})
|
|
9
|
+
.describe("An object with an id, codename, or external_id property referencing another item. Using id is preferred for better performance.");
|
package/build/server.js
CHANGED
|
@@ -6,6 +6,7 @@ import { registerTool as registerAddContentTypeSnippetMapi } from "./tools/add-c
|
|
|
6
6
|
import { registerTool as registerAddTaxonomyGroupMapi } from "./tools/add-taxonomy-group-mapi.js";
|
|
7
7
|
import { registerTool as registerDeleteContentItemMapi } from "./tools/delete-content-item-mapi.js";
|
|
8
8
|
import { registerTool as registerDeleteLanguageVariantMapi } from "./tools/delete-language-variant-mapi.js";
|
|
9
|
+
import { registerTool as registerFilterVariantsMapi } from "./tools/filter-variants-mapi.js";
|
|
9
10
|
import { registerTool as registerGetAssetMapi } from "./tools/get-asset-mapi.js";
|
|
10
11
|
import { registerTool as registerGetInitialContext } from "./tools/get-initial-context.js";
|
|
11
12
|
import { registerTool as registerGetItemDapi } from "./tools/get-item-dapi.js";
|
|
@@ -53,5 +54,6 @@ export const createServer = () => {
|
|
|
53
54
|
registerDeleteContentItemMapi(server);
|
|
54
55
|
registerUpsertLanguageVariantMapi(server);
|
|
55
56
|
registerDeleteLanguageVariantMapi(server);
|
|
57
|
+
registerFilterVariantsMapi(server);
|
|
56
58
|
return { server };
|
|
57
59
|
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { filterVariantsSchema } from "../schemas/filterVariantSchemas.js";
|
|
2
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
3
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
4
|
+
import { throwError } from "../utils/throwError.js";
|
|
5
|
+
export const registerTool = (server) => {
|
|
6
|
+
server.tool("filter-variants-mapi", "Search and filter language variants of content items using the Management API.", filterVariantsSchema.shape, async ({ search_phrase, content_types, contributors, completion_statuses, language, workflow_steps, order_by, order_direction, continuation_token, }) => {
|
|
7
|
+
try {
|
|
8
|
+
const requestPayload = {
|
|
9
|
+
filters: {
|
|
10
|
+
search_phrase,
|
|
11
|
+
content_types,
|
|
12
|
+
contributors,
|
|
13
|
+
completion_statuses,
|
|
14
|
+
language,
|
|
15
|
+
workflow_steps,
|
|
16
|
+
},
|
|
17
|
+
order: order_by
|
|
18
|
+
? {
|
|
19
|
+
by: order_by,
|
|
20
|
+
direction: order_direction === "desc" ? "Descending" : "Ascending",
|
|
21
|
+
}
|
|
22
|
+
: null,
|
|
23
|
+
};
|
|
24
|
+
const environmentId = process.env.KONTENT_ENVIRONMENT_ID;
|
|
25
|
+
const apiKey = process.env.KONTENT_API_KEY;
|
|
26
|
+
if (!environmentId || !apiKey) {
|
|
27
|
+
throwError("Missing required environment variables");
|
|
28
|
+
}
|
|
29
|
+
const url = `https://manage.kontent.ai/v2/projects/${environmentId}/early-access/variants/filter`;
|
|
30
|
+
const headers = {
|
|
31
|
+
Authorization: `Bearer ${apiKey}`,
|
|
32
|
+
"Content-Type": "application/json",
|
|
33
|
+
};
|
|
34
|
+
if (continuation_token) {
|
|
35
|
+
headers["X-Continuation"] = continuation_token;
|
|
36
|
+
}
|
|
37
|
+
const response = await fetch(url, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers: headers,
|
|
40
|
+
body: JSON.stringify(requestPayload),
|
|
41
|
+
});
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
const responseText = await response.text();
|
|
44
|
+
let responseData;
|
|
45
|
+
try {
|
|
46
|
+
responseData = JSON.parse(responseText);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
responseData = responseText;
|
|
50
|
+
}
|
|
51
|
+
const error = new Error(`HTTP error! status: ${response.status}`);
|
|
52
|
+
error.response = {
|
|
53
|
+
status: response.status,
|
|
54
|
+
statusText: response.statusText,
|
|
55
|
+
data: responseData,
|
|
56
|
+
};
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
const responseData = await response.json();
|
|
60
|
+
return createMcpToolSuccessResponse(responseData);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
return handleMcpToolError(error, "Variant Search");
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
};
|