@kontent-ai/mcp-server 0.31.0 → 0.33.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 +57 -61
- package/build/schemas/bulkGetItemsWithVariantsSchemas.js +1 -1
- package/build/schemas/contentItemSchemas.js +1 -1
- package/build/schemas/filterVariantSchemas.js +8 -3
- package/build/schemas/searchOperationSchemas.js +2 -1
- package/build/server.js +4 -112
- package/build/test/bm25/bm25.js +47 -0
- package/build/test/bm25/toolSearchBm25.spec.js +874 -0
- package/build/tools/bulk-get-content-item-variants.js +31 -0
- package/build/tools/change-content-item-variant-workflow-step.js +35 -0
- package/build/tools/create-content-item-variant.js +44 -0
- package/build/tools/create-content-item.js +47 -0
- package/build/tools/create-content-type-snippet.js +34 -0
- package/build/tools/create-content-type.js +37 -0
- package/build/tools/create-language.js +24 -0
- package/build/tools/create-new-content-item-variant-version.js +27 -0
- package/build/tools/create-space.js +22 -0
- package/build/tools/create-taxonomy-group.js +18 -0
- package/build/tools/create-workflow.js +23 -0
- package/build/tools/delete-content-item-variant.js +25 -0
- package/build/tools/delete-content-item.js +23 -0
- package/build/tools/delete-content-type-snippet.js +19 -0
- package/build/tools/delete-content-type.js +23 -0
- package/build/tools/delete-space.js +19 -0
- package/build/tools/delete-taxonomy-group.js +19 -0
- package/build/tools/delete-workflow.js +19 -0
- package/build/tools/get-asset.js +17 -0
- package/build/tools/get-content-item-translations.js +20 -0
- package/build/tools/get-content-item-variant.js +22 -0
- package/build/tools/get-content-item.js +17 -0
- package/build/tools/get-content-type-snippet.js +20 -0
- package/build/tools/get-content-type.js +17 -0
- package/build/tools/get-patch-guide.js +12 -12
- package/build/tools/get-published-content-item-variant-version.js +23 -0
- package/build/tools/get-taxonomy-group.js +17 -0
- package/build/tools/index.js +106 -0
- package/build/tools/list-asset-folders.js +14 -0
- package/build/tools/list-assets.js +23 -0
- package/build/tools/list-collections.js +14 -0
- package/build/tools/list-content-item-variants.js +50 -0
- package/build/tools/list-content-type-snippets.js +23 -0
- package/build/tools/list-content-types.js +23 -0
- package/build/tools/list-languages.js +24 -0
- package/build/tools/list-roles.js +14 -0
- package/build/tools/list-spaces.js +14 -0
- package/build/tools/list-taxonomy-groups.js +23 -0
- package/build/tools/list-workflows.js +14 -0
- package/build/tools/patch-asset-folders.js +25 -0
- package/build/tools/patch-collections.js +25 -0
- package/build/tools/patch-content-type-snippet.js +30 -0
- package/build/tools/patch-content-type.js +33 -0
- package/build/tools/patch-language.js +24 -0
- package/build/tools/patch-space.js +28 -0
- package/build/tools/patch-taxonomy-group.js +28 -0
- package/build/tools/publish-content-item-variant.js +72 -0
- package/build/tools/referencedToolNames.js +10 -0
- package/build/tools/search-content-item-variants.js +108 -0
- package/build/tools/toolDefinition.js +1 -0
- package/build/tools/unpublish-content-item-variant.js +72 -0
- package/build/tools/update-asset.js +23 -0
- package/build/tools/update-content-item-variant.js +36 -0
- package/build/tools/update-content-item.js +74 -0
- package/build/tools/update-workflow.js +31 -0
- package/package.json +18 -17
- package/build/tools/add-content-item-mapi.js +0 -47
- package/build/tools/add-content-type-mapi.js +0 -38
- package/build/tools/add-content-type-snippet-mapi.js +0 -35
- package/build/tools/add-language-mapi.js +0 -25
- package/build/tools/add-space-mapi.js +0 -23
- package/build/tools/add-taxonomy-group-mapi.js +0 -19
- package/build/tools/add-workflow-mapi.js +0 -24
- package/build/tools/bulk-get-items-variants-mapi.js +0 -31
- package/build/tools/change-variant-workflow-step-mapi.js +0 -36
- package/build/tools/create-language-variant-mapi.js +0 -44
- package/build/tools/create-variant-version-mapi.js +0 -28
- package/build/tools/delete-content-item-mapi.js +0 -24
- package/build/tools/delete-content-type-mapi.js +0 -24
- package/build/tools/delete-language-variant-mapi.js +0 -26
- package/build/tools/delete-space-mapi.js +0 -20
- package/build/tools/delete-taxonomy-group-mapi.js +0 -20
- package/build/tools/delete-type-snippet-mapi.js +0 -23
- package/build/tools/delete-workflow-mapi.js +0 -20
- package/build/tools/filter-variants-mapi.js +0 -49
- package/build/tools/get-asset-mapi.js +0 -21
- package/build/tools/get-item-mapi.js +0 -21
- package/build/tools/get-latest-variant-mapi.js +0 -23
- package/build/tools/get-published-variant-mapi.js +0 -24
- package/build/tools/get-taxonomy-group-mapi.js +0 -21
- package/build/tools/get-type-mapi.js +0 -21
- package/build/tools/get-type-snippet-mapi.js +0 -21
- package/build/tools/list-asset-folders-mapi.js +0 -15
- package/build/tools/list-assets-mapi.js +0 -24
- package/build/tools/list-collections-mapi.js +0 -15
- package/build/tools/list-content-type-snippets-mapi.js +0 -24
- package/build/tools/list-content-types-mapi.js +0 -24
- package/build/tools/list-languages-mapi.js +0 -24
- package/build/tools/list-roles-mapi.js +0 -15
- package/build/tools/list-spaces-mapi.js +0 -15
- package/build/tools/list-taxonomy-groups-mapi.js +0 -24
- package/build/tools/list-variants-collection-mapi.js +0 -26
- package/build/tools/list-variants-components-type-mapi.js +0 -26
- package/build/tools/list-variants-item-mapi.js +0 -21
- package/build/tools/list-variants-space-mapi.js +0 -24
- package/build/tools/list-variants-type-mapi.js +0 -26
- package/build/tools/list-workflows-mapi.js +0 -15
- package/build/tools/patch-asset-folders-mapi.js +0 -25
- package/build/tools/patch-collections-mapi.js +0 -25
- package/build/tools/patch-content-type-mapi.js +0 -33
- package/build/tools/patch-language-mapi.js +0 -24
- package/build/tools/patch-space-mapi.js +0 -28
- package/build/tools/patch-taxonomy-group-mapi.js +0 -28
- package/build/tools/patch-type-snippet-mapi.js +0 -30
- package/build/tools/publish-variant-mapi.js +0 -73
- package/build/tools/search-variants-mapi.js +0 -108
- package/build/tools/unpublish-variant-mapi.js +0 -73
- package/build/tools/update-asset-mapi.js +0 -24
- package/build/tools/update-content-item-mapi.js +0 -74
- package/build/tools/update-language-variant-mapi.js +0 -37
- package/build/tools/update-workflow-mapi.js +0 -32
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
2
|
+
import { bulkGetItemsWithVariantsSchema } from "../schemas/bulkGetItemsWithVariantsSchemas.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { throwError } from "../utils/throwError.js";
|
|
6
|
+
import { bulkGetContentItemVariantsToolName } from "./referencedToolNames.js";
|
|
7
|
+
import { defineTool } from "./toolDefinition.js";
|
|
8
|
+
export const bulkGetContentItemVariants = defineTool(bulkGetContentItemVariantsToolName, "Bulk/batch retrieve multiple Kontent.ai content items with their content item variants (language versions/translations) by item and language reference pairs. Fetch full content for item and variant IDs found via other tools.", bulkGetItemsWithVariantsSchema.shape, async ({ variants, continuation_token }, { authInfo: { token, clientId } = {} }) => {
|
|
9
|
+
try {
|
|
10
|
+
const environmentId = clientId ?? process.env.KONTENT_ENVIRONMENT_ID;
|
|
11
|
+
if (!environmentId) {
|
|
12
|
+
throwError("Missing required environment ID");
|
|
13
|
+
}
|
|
14
|
+
const client = createMapiClient(environmentId, token);
|
|
15
|
+
const query = client.bulkGetItemsWithVariants().withData({
|
|
16
|
+
variants,
|
|
17
|
+
});
|
|
18
|
+
const response = await (continuation_token
|
|
19
|
+
? query.xContinuationToken(continuation_token)
|
|
20
|
+
: query).toPromise();
|
|
21
|
+
return createMcpToolSuccessResponse({
|
|
22
|
+
data: response.rawData.data,
|
|
23
|
+
pagination: {
|
|
24
|
+
continuation_token: response.data.pagination.continuationToken,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
return handleMcpToolError(error, "Bulk Get Items With Variants");
|
|
30
|
+
}
|
|
31
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const changeContentItemVariantWorkflowStep = defineTool("change-content-item-variant-workflow-step", "Move Kontent.ai content item variant (language version/translation) to a different workflow step. Transition content between lifecycle stages (e.g., draft to review, review to approved/published, or archive).", {
|
|
7
|
+
itemId: z.guid().describe("Content item ID"),
|
|
8
|
+
languageId: z.guid().describe("Language ID"),
|
|
9
|
+
workflowId: z.guid().describe("Workflow ID"),
|
|
10
|
+
workflowStepId: z.guid().describe("Target workflow step ID"),
|
|
11
|
+
}, async ({ itemId, languageId, workflowId, workflowStepId }, { authInfo: { token, clientId } = {} }) => {
|
|
12
|
+
const client = createMapiClient(clientId, token);
|
|
13
|
+
try {
|
|
14
|
+
const response = await client
|
|
15
|
+
.changeWorkflowOfLanguageVariant()
|
|
16
|
+
.byItemId(itemId)
|
|
17
|
+
.byLanguageId(languageId)
|
|
18
|
+
.withData({
|
|
19
|
+
workflow_identifier: {
|
|
20
|
+
id: workflowId,
|
|
21
|
+
},
|
|
22
|
+
step_identifier: {
|
|
23
|
+
id: workflowStepId,
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
.toPromise();
|
|
27
|
+
return createMcpToolSuccessResponse({
|
|
28
|
+
message: `Successfully changed workflow step of item variant '${languageId}' for content item '${itemId}' to workflow step '${workflowStepId}'`,
|
|
29
|
+
result: response.rawData,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return handleMcpToolError(error, "Workflow Step Change");
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { languageVariantElementSchema } from "../schemas/contentItemSchemas.js";
|
|
4
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
5
|
+
import { extractUserIdFromToken } from "../utils/extractUserIdFromToken.js";
|
|
6
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
7
|
+
import { createContentItemVariantToolName } from "./referencedToolNames.js";
|
|
8
|
+
import { defineTool } from "./toolDefinition.js";
|
|
9
|
+
export const createContentItemVariant = defineTool(createContentItemVariantToolName, "Create Kontent.ai content item variant — translate and localize content into a specific language. Adds a new language version (translation) for a content item. Element values must fulfill the content type definition.", {
|
|
10
|
+
itemId: z.string().describe("Content item ID"),
|
|
11
|
+
languageId: z
|
|
12
|
+
.string()
|
|
13
|
+
.describe("Language ID (default: 00000000-0000-0000-0000-000000000000)"),
|
|
14
|
+
elements: z
|
|
15
|
+
.array(languageVariantElementSchema)
|
|
16
|
+
.describe("Content elements array"),
|
|
17
|
+
workflow_step_id: z.string().optional().describe("Workflow step ID"),
|
|
18
|
+
}, async ({ itemId, languageId, elements, workflow_step_id }, { authInfo: { token, clientId } = {} }) => {
|
|
19
|
+
const client = createMapiClient(clientId, token);
|
|
20
|
+
const data = {
|
|
21
|
+
elements,
|
|
22
|
+
};
|
|
23
|
+
if (workflow_step_id) {
|
|
24
|
+
data.workflow_step = { id: workflow_step_id };
|
|
25
|
+
}
|
|
26
|
+
if (token) {
|
|
27
|
+
const userId = extractUserIdFromToken(token);
|
|
28
|
+
if (userId) {
|
|
29
|
+
data.contributors = [{ id: userId }];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const response = await client
|
|
34
|
+
.upsertLanguageVariant()
|
|
35
|
+
.byItemId(itemId)
|
|
36
|
+
.byLanguageId(languageId)
|
|
37
|
+
.withData(() => data)
|
|
38
|
+
.toPromise();
|
|
39
|
+
return createMcpToolSuccessResponse(response.rawData);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
return handleMcpToolError(error, "Language Variant Create");
|
|
43
|
+
}
|
|
44
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { createContentItemVariantToolName } from "./referencedToolNames.js";
|
|
6
|
+
import { defineTool } from "./toolDefinition.js";
|
|
7
|
+
export const createContentItem = defineTool("create-content-item", `Create (add) new Kontent.ai content item (creates the container only, use ${createContentItemVariantToolName} to add language versions/translations). Items are language-neutral and hold content item variants for each language.`, {
|
|
8
|
+
name: z.string().min(1).max(200).describe("Item name (1-200 chars)"),
|
|
9
|
+
type: z
|
|
10
|
+
.object({
|
|
11
|
+
id: z.string().optional(),
|
|
12
|
+
codename: z.string().optional(),
|
|
13
|
+
external_id: z.string().optional(),
|
|
14
|
+
})
|
|
15
|
+
.describe("Content type reference"),
|
|
16
|
+
codename: z
|
|
17
|
+
.string()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("Codename (auto-generated if omitted)"),
|
|
20
|
+
external_id: z.string().optional().describe("External ID"),
|
|
21
|
+
collection: z
|
|
22
|
+
.object({
|
|
23
|
+
id: z.string().optional(),
|
|
24
|
+
codename: z.string().optional(),
|
|
25
|
+
external_id: z.string().optional(),
|
|
26
|
+
})
|
|
27
|
+
.optional()
|
|
28
|
+
.describe("Collection reference"),
|
|
29
|
+
}, async ({ name, type, codename, external_id, collection }, { authInfo: { token, clientId } = {} }) => {
|
|
30
|
+
const client = createMapiClient(clientId, token);
|
|
31
|
+
try {
|
|
32
|
+
const response = await client
|
|
33
|
+
.addContentItem()
|
|
34
|
+
.withData({
|
|
35
|
+
name,
|
|
36
|
+
type,
|
|
37
|
+
codename,
|
|
38
|
+
external_id,
|
|
39
|
+
collection,
|
|
40
|
+
})
|
|
41
|
+
.toPromise();
|
|
42
|
+
return createMcpToolSuccessResponse(response.rawData);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
return handleMcpToolError(error, "Content Item Creation");
|
|
46
|
+
}
|
|
47
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { snippetElementSchema } from "../schemas/contentTypeAndSnippetSchemas.js";
|
|
4
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
5
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
6
|
+
import { defineTool } from "./toolDefinition.js";
|
|
7
|
+
export const createContentTypeSnippet = defineTool("create-content-type-snippet", "Create (add) new Kontent.ai content type snippet. Snippets are reusable, shared sets of elements that can be included in multiple content types.", {
|
|
8
|
+
name: z.string().describe("Snippet name"),
|
|
9
|
+
codename: z
|
|
10
|
+
.string()
|
|
11
|
+
.optional()
|
|
12
|
+
.describe("Codename (auto-generated if omitted)"),
|
|
13
|
+
external_id: z.string().optional().describe("External ID"),
|
|
14
|
+
elements: z
|
|
15
|
+
.array(snippetElementSchema)
|
|
16
|
+
.describe("Elements defining structure"),
|
|
17
|
+
}, async ({ name, codename, external_id, elements }, { authInfo: { token, clientId } = {} }) => {
|
|
18
|
+
const client = createMapiClient(clientId, token);
|
|
19
|
+
try {
|
|
20
|
+
const response = await client
|
|
21
|
+
.addContentTypeSnippet()
|
|
22
|
+
.withData(() => ({
|
|
23
|
+
name,
|
|
24
|
+
codename,
|
|
25
|
+
external_id,
|
|
26
|
+
elements,
|
|
27
|
+
}))
|
|
28
|
+
.toPromise();
|
|
29
|
+
return createMcpToolSuccessResponse(response.rawData);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
return handleMcpToolError(error, "Content Type Snippet Creation");
|
|
33
|
+
}
|
|
34
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { contentGroupSchema, elementSchema, } from "../schemas/contentTypeAndSnippetSchemas.js";
|
|
4
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
5
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
6
|
+
import { defineTool } from "./toolDefinition.js";
|
|
7
|
+
export const createContentType = defineTool("create-content-type", "Create (add) new Kontent.ai content type (schema/model). Define content structure with elements, validation rules, and content groups.", {
|
|
8
|
+
name: z.string().describe("Content type name"),
|
|
9
|
+
codename: z
|
|
10
|
+
.string()
|
|
11
|
+
.optional()
|
|
12
|
+
.describe("Codename (auto-generated if omitted)"),
|
|
13
|
+
external_id: z.string().optional().describe("External ID"),
|
|
14
|
+
elements: z.array(elementSchema).describe("Elements defining structure"),
|
|
15
|
+
content_groups: z
|
|
16
|
+
.array(contentGroupSchema)
|
|
17
|
+
.optional()
|
|
18
|
+
.describe("Content groups"),
|
|
19
|
+
}, async ({ name, codename, external_id, elements, content_groups }, { authInfo: { token, clientId } = {} }) => {
|
|
20
|
+
const client = createMapiClient(clientId, token);
|
|
21
|
+
try {
|
|
22
|
+
const response = await client
|
|
23
|
+
.addContentType()
|
|
24
|
+
.withData(() => ({
|
|
25
|
+
name,
|
|
26
|
+
codename,
|
|
27
|
+
external_id,
|
|
28
|
+
elements,
|
|
29
|
+
content_groups,
|
|
30
|
+
}))
|
|
31
|
+
.toPromise();
|
|
32
|
+
return createMcpToolSuccessResponse(response.rawData);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return handleMcpToolError(error, "Content Type Creation");
|
|
36
|
+
}
|
|
37
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
2
|
+
import { addLanguageSchema } from "../schemas/languageSchemas.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const createLanguage = defineTool("create-language", "Create (add) and configure new Kontent.ai language locale for translations and localization. Languages are always created as active.", addLanguageSchema.shape, async ({ name, codename, fallback_language, external_id }, { authInfo: { token, clientId } = {} }) => {
|
|
7
|
+
const client = createMapiClient(clientId, token);
|
|
8
|
+
try {
|
|
9
|
+
const response = await client
|
|
10
|
+
.addLanguage()
|
|
11
|
+
.withData({
|
|
12
|
+
name,
|
|
13
|
+
codename,
|
|
14
|
+
is_active: true,
|
|
15
|
+
fallback_language,
|
|
16
|
+
external_id,
|
|
17
|
+
})
|
|
18
|
+
.toPromise();
|
|
19
|
+
return createMcpToolSuccessResponse(response.rawData);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
return handleMcpToolError(error, "Language Creation");
|
|
23
|
+
}
|
|
24
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const createNewContentItemVariantVersion = defineTool("create-new-content-item-variant-version", "Create new draft version of a published Kontent.ai content item variant (language version/translation). Required before editing published content.", {
|
|
7
|
+
itemId: z.guid().describe("Content item ID"),
|
|
8
|
+
languageId: z
|
|
9
|
+
.guid()
|
|
10
|
+
.describe("Language ID (default: 00000000-0000-0000-0000-000000000000)"),
|
|
11
|
+
}, async ({ itemId, languageId }, { authInfo: { token, clientId } = {} }) => {
|
|
12
|
+
const client = createMapiClient(clientId, token);
|
|
13
|
+
try {
|
|
14
|
+
const response = await client
|
|
15
|
+
.createNewVersionOfLanguageVariant()
|
|
16
|
+
.byItemId(itemId)
|
|
17
|
+
.byLanguageId(languageId)
|
|
18
|
+
.toPromise();
|
|
19
|
+
return createMcpToolSuccessResponse({
|
|
20
|
+
message: `Successfully created new version of item variant '${languageId}' for content item '${itemId}'`,
|
|
21
|
+
result: response.rawData,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
return handleMcpToolError(error, "Variant Version Creation");
|
|
26
|
+
}
|
|
27
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
2
|
+
import { addSpaceSchema } from "../schemas/spaceSchemas.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const createSpace = defineTool("create-space", "Create (add) new Kontent.ai space for managing a website or channel. Spaces provide channel-specific context with their own domain and preview URLs.", addSpaceSchema.shape, async ({ name, codename, collections }, { authInfo: { token, clientId } = {} }) => {
|
|
7
|
+
const client = createMapiClient(clientId, token);
|
|
8
|
+
try {
|
|
9
|
+
const response = await client
|
|
10
|
+
.addSpace()
|
|
11
|
+
.withData({
|
|
12
|
+
name,
|
|
13
|
+
codename,
|
|
14
|
+
collections,
|
|
15
|
+
})
|
|
16
|
+
.toPromise();
|
|
17
|
+
return createMcpToolSuccessResponse(response.rawData);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
return handleMcpToolError(error, "Space Creation");
|
|
21
|
+
}
|
|
22
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
2
|
+
import { taxonomyGroupSchemas } from "../schemas/taxonomySchemas.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const createTaxonomyGroup = defineTool("create-taxonomy-group", "Create (add) new Kontent.ai taxonomy group for content categorization. Taxonomy groups contain hierarchical terms (categories/tags) for classifying content.", taxonomyGroupSchemas, async (taxonomyGroup, { authInfo: { token, clientId } = {} }) => {
|
|
7
|
+
const client = createMapiClient(clientId, token);
|
|
8
|
+
try {
|
|
9
|
+
const response = await client
|
|
10
|
+
.addTaxonomy()
|
|
11
|
+
.withData(taxonomyGroup)
|
|
12
|
+
.toPromise();
|
|
13
|
+
return createMcpToolSuccessResponse(response.rawData);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
return handleMcpToolError(error, "Taxonomy Group Creation");
|
|
17
|
+
}
|
|
18
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
2
|
+
import { workflowInputSchema } from "../schemas/workflowSchemas.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const createWorkflow = defineTool("create-workflow", "Create (add) new Kontent.ai workflow with custom steps. Workflows define content lifecycle stages for review and approval.", workflowInputSchema.shape, async ({ name, codename, scopes, steps, published_step, archived_step }, { authInfo: { token, clientId } = {} }) => {
|
|
7
|
+
const client = createMapiClient(clientId, token);
|
|
8
|
+
const data = {
|
|
9
|
+
name,
|
|
10
|
+
codename,
|
|
11
|
+
scopes,
|
|
12
|
+
steps,
|
|
13
|
+
published_step,
|
|
14
|
+
archived_step,
|
|
15
|
+
};
|
|
16
|
+
try {
|
|
17
|
+
const response = await client.addWorkflow().withData(data).toPromise();
|
|
18
|
+
return createMcpToolSuccessResponse(response.rawData);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return handleMcpToolError(error, "Workflow Creation");
|
|
22
|
+
}
|
|
23
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const deleteContentItemVariant = defineTool("delete-content-item-variant", "Delete (remove) Kontent.ai content item variant (language version/translation). Removes translated content for a specific language from an item.", {
|
|
7
|
+
itemId: z.string().describe("Content item ID"),
|
|
8
|
+
languageId: z.string().describe("Language ID"),
|
|
9
|
+
}, async ({ itemId, languageId }, { authInfo: { token, clientId } = {} }) => {
|
|
10
|
+
const client = createMapiClient(clientId, token);
|
|
11
|
+
try {
|
|
12
|
+
const response = await client
|
|
13
|
+
.deleteLanguageVariant()
|
|
14
|
+
.byItemId(itemId)
|
|
15
|
+
.byLanguageId(languageId)
|
|
16
|
+
.toPromise();
|
|
17
|
+
return createMcpToolSuccessResponse({
|
|
18
|
+
message: `Language variant '${languageId}' of content item '${itemId}' deleted successfully`,
|
|
19
|
+
deletedVariant: response.rawData,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
return handleMcpToolError(error, "Language Variant Deletion");
|
|
24
|
+
}
|
|
25
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const deleteContentItem = defineTool("delete-content-item", "Delete (remove) Kontent.ai content item and all its content item variants.", {
|
|
7
|
+
id: z.string().describe("Content item ID"),
|
|
8
|
+
}, async ({ id }, { authInfo: { token, clientId } = {} }) => {
|
|
9
|
+
const client = createMapiClient(clientId, token);
|
|
10
|
+
try {
|
|
11
|
+
const response = await client
|
|
12
|
+
.deleteContentItem()
|
|
13
|
+
.byItemId(id)
|
|
14
|
+
.toPromise();
|
|
15
|
+
return createMcpToolSuccessResponse({
|
|
16
|
+
message: `Content item '${id}' deleted successfully`,
|
|
17
|
+
deletedItem: response.rawData,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return handleMcpToolError(error, "Content Item Deletion");
|
|
22
|
+
}
|
|
23
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const deleteContentTypeSnippet = defineTool("delete-content-type-snippet", "Delete (remove) Kontent.ai content type snippet by ID. Removes the reusable shared element set definition.", {
|
|
7
|
+
id: z.string().describe("Content type snippet ID"),
|
|
8
|
+
}, async ({ id }, { authInfo: { token, clientId } = {} }) => {
|
|
9
|
+
const client = createMapiClient(clientId, token);
|
|
10
|
+
try {
|
|
11
|
+
await client.deleteContentTypeSnippet().byTypeId(id).toPromise();
|
|
12
|
+
return createMcpToolSuccessResponse({
|
|
13
|
+
message: `Content type snippet '${id}' deleted successfully`,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return handleMcpToolError(error, "Content Type Snippet Deletion");
|
|
18
|
+
}
|
|
19
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const deleteContentType = defineTool("delete-content-type", "Delete (remove) Kontent.ai content type by ID. Removes the schema/model definition.", {
|
|
7
|
+
id: z.string().describe("Content type ID"),
|
|
8
|
+
}, async ({ id }, { authInfo: { token, clientId } = {} }) => {
|
|
9
|
+
const client = createMapiClient(clientId, token);
|
|
10
|
+
try {
|
|
11
|
+
const response = await client
|
|
12
|
+
.deleteContentType()
|
|
13
|
+
.byTypeId(id)
|
|
14
|
+
.toPromise();
|
|
15
|
+
return createMcpToolSuccessResponse({
|
|
16
|
+
message: `Content type '${id}' deleted successfully`,
|
|
17
|
+
deletedType: response.rawData,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return handleMcpToolError(error, "Content Type Deletion");
|
|
22
|
+
}
|
|
23
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const deleteSpace = defineTool("delete-space", "Delete (remove) Kontent.ai space by ID. Removes the channel/website context.", {
|
|
7
|
+
id: z.guid().describe("Space ID"),
|
|
8
|
+
}, async ({ id }, { authInfo: { token, clientId } = {} }) => {
|
|
9
|
+
const client = createMapiClient(clientId, token);
|
|
10
|
+
try {
|
|
11
|
+
await client.deleteSpace().bySpaceId(id).toPromise();
|
|
12
|
+
return createMcpToolSuccessResponse({
|
|
13
|
+
message: `Space '${id}' deleted successfully`,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return handleMcpToolError(error, "Space Deletion");
|
|
18
|
+
}
|
|
19
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const deleteTaxonomyGroup = defineTool("delete-taxonomy-group", "Delete (remove) Kontent.ai taxonomy group by ID. Removes the category/tag group and all its terms.", {
|
|
7
|
+
id: z.guid().describe("Taxonomy group ID"),
|
|
8
|
+
}, async ({ id }, { authInfo: { token, clientId } = {} }) => {
|
|
9
|
+
const client = createMapiClient(clientId, token);
|
|
10
|
+
try {
|
|
11
|
+
await client.deleteTaxonomy().byTaxonomyId(id).toPromise();
|
|
12
|
+
return createMcpToolSuccessResponse({
|
|
13
|
+
message: `Taxonomy group '${id}' deleted successfully`,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return handleMcpToolError(error, "Taxonomy Group Deletion");
|
|
18
|
+
}
|
|
19
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const deleteWorkflow = defineTool("delete-workflow", "Delete (remove) Kontent.ai workflow. Cannot delete the default workflow.", {
|
|
7
|
+
id: z.guid().describe("Workflow ID"),
|
|
8
|
+
}, async ({ id }, { authInfo: { token, clientId } = {} }) => {
|
|
9
|
+
const client = createMapiClient(clientId, token);
|
|
10
|
+
try {
|
|
11
|
+
await client.deleteWorkflow().byWorkflowId(id).toPromise();
|
|
12
|
+
return createMcpToolSuccessResponse({
|
|
13
|
+
message: `Workflow '${id}' deleted successfully`,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return handleMcpToolError(error, "Workflow Deletion");
|
|
18
|
+
}
|
|
19
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const getAsset = defineTool("get-asset", "Retrieve Kontent.ai asset by ID. Assets are digital media files (images, videos, documents, PDFs) standalone, or referenced from other entities, typically content item variants.", {
|
|
7
|
+
assetId: z.string().describe("Asset ID"),
|
|
8
|
+
}, async ({ assetId }, { authInfo: { token, clientId } = {} }) => {
|
|
9
|
+
const client = createMapiClient(clientId, token);
|
|
10
|
+
try {
|
|
11
|
+
const response = await client.viewAsset().byAssetId(assetId).toPromise();
|
|
12
|
+
return createMcpToolSuccessResponse(response.rawData);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
return handleMcpToolError(error, "Asset Retrieval");
|
|
16
|
+
}
|
|
17
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const getContentItemTranslations = defineTool("get-content-item-translations", "Get all Kontent.ai content item translations — every language version (variant) of a specific content item. Retrieve translated content across all languages to see available translations for a single item.", {
|
|
7
|
+
itemId: z.string().describe("Content item ID"),
|
|
8
|
+
}, async ({ itemId }, { authInfo: { token, clientId } = {} }) => {
|
|
9
|
+
const client = createMapiClient(clientId, token);
|
|
10
|
+
try {
|
|
11
|
+
const response = await client
|
|
12
|
+
.listLanguageVariantsOfItem()
|
|
13
|
+
.byItemId(itemId)
|
|
14
|
+
.toPromise();
|
|
15
|
+
return createMcpToolSuccessResponse(response.rawData);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
return handleMcpToolError(error, "Content Item Translations Retrieval");
|
|
19
|
+
}
|
|
20
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const getContentItemVariant = defineTool("get-content-item-variant", "Retrieve Kontent.ai content item variant (language version/translation). Returns the current version of the variant — draft if one exists, otherwise published. Variants hold translated, language-specific content with structure defined by content type.", {
|
|
7
|
+
itemId: z.string().describe("Content item ID"),
|
|
8
|
+
languageId: z.string().describe("Language ID"),
|
|
9
|
+
}, async ({ itemId, languageId }, { authInfo: { token, clientId } = {} }) => {
|
|
10
|
+
const client = createMapiClient(clientId, token);
|
|
11
|
+
try {
|
|
12
|
+
const response = await client
|
|
13
|
+
.viewLanguageVariant()
|
|
14
|
+
.byItemId(itemId)
|
|
15
|
+
.byLanguageId(languageId)
|
|
16
|
+
.toPromise();
|
|
17
|
+
return createMcpToolSuccessResponse(response.rawData);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
return handleMcpToolError(error, "Content Item Variant Retrieval");
|
|
21
|
+
}
|
|
22
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const getContentItem = defineTool("get-content-item", "Retrieve Kontent.ai content item by ID. Items are language-neutral containers; one item has multiple content item variants (translations).", {
|
|
7
|
+
id: z.string().describe("Content item ID"),
|
|
8
|
+
}, async ({ id }, { authInfo: { token, clientId } = {} }) => {
|
|
9
|
+
const client = createMapiClient(clientId, token);
|
|
10
|
+
try {
|
|
11
|
+
const response = await client.viewContentItem().byItemId(id).toPromise();
|
|
12
|
+
return createMcpToolSuccessResponse(response.rawData);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
return handleMcpToolError(error, "Item Retrieval");
|
|
16
|
+
}
|
|
17
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const getContentTypeSnippet = defineTool("get-content-type-snippet", "Retrieve Kontent.ai content type snippet. Snippets are reusable, shared sets of elements included across multiple content types.", {
|
|
7
|
+
id: z.string().describe("Content type snippet ID"),
|
|
8
|
+
}, async ({ id }, { authInfo: { token, clientId } = {} }) => {
|
|
9
|
+
const client = createMapiClient(clientId, token);
|
|
10
|
+
try {
|
|
11
|
+
const response = await client
|
|
12
|
+
.viewContentTypeSnippet()
|
|
13
|
+
.byTypeId(id)
|
|
14
|
+
.toPromise();
|
|
15
|
+
return createMcpToolSuccessResponse(response.rawData);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
return handleMcpToolError(error, "Content Type Snippet Retrieval");
|
|
19
|
+
}
|
|
20
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createMapiClient } from "../clients/kontentClients.js";
|
|
3
|
+
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
|
+
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
|
+
import { defineTool } from "./toolDefinition.js";
|
|
6
|
+
export const getContentType = defineTool("get-content-type", "Retrieve Kontent.ai content type (schema/model definition). Content types define content structure: elements, field validation rules, and content groups.", {
|
|
7
|
+
id: z.string().describe("Content type ID"),
|
|
8
|
+
}, async ({ id }, { authInfo: { token, clientId } = {} }) => {
|
|
9
|
+
const client = createMapiClient(clientId, token);
|
|
10
|
+
try {
|
|
11
|
+
const response = await client.viewContentType().byTypeId(id).toPromise();
|
|
12
|
+
return createMcpToolSuccessResponse(response.rawData);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
return handleMcpToolError(error, "Content Type Retrieval");
|
|
16
|
+
}
|
|
17
|
+
});
|