@kontent-ai/mcp-server 0.30.1 → 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.
Files changed (119) hide show
  1. package/README.md +57 -61
  2. package/build/schemas/bulkGetItemsWithVariantsSchemas.js +1 -1
  3. package/build/schemas/contentItemSchemas.js +1 -1
  4. package/build/schemas/filterVariantSchemas.js +8 -3
  5. package/build/schemas/searchOperationSchemas.js +2 -1
  6. package/build/server.js +4 -112
  7. package/build/test/bm25/bm25.js +47 -0
  8. package/build/test/bm25/toolSearchBm25.spec.js +874 -0
  9. package/build/tools/bulk-get-content-item-variants.js +31 -0
  10. package/build/tools/change-content-item-variant-workflow-step.js +35 -0
  11. package/build/tools/create-content-item-variant.js +44 -0
  12. package/build/tools/create-content-item.js +47 -0
  13. package/build/tools/create-content-type-snippet.js +34 -0
  14. package/build/tools/create-content-type.js +37 -0
  15. package/build/tools/create-language.js +24 -0
  16. package/build/tools/create-new-content-item-variant-version.js +27 -0
  17. package/build/tools/create-space.js +22 -0
  18. package/build/tools/create-taxonomy-group.js +18 -0
  19. package/build/tools/create-workflow.js +23 -0
  20. package/build/tools/delete-content-item-variant.js +25 -0
  21. package/build/tools/delete-content-item.js +23 -0
  22. package/build/tools/delete-content-type-snippet.js +19 -0
  23. package/build/tools/delete-content-type.js +23 -0
  24. package/build/tools/delete-space.js +19 -0
  25. package/build/tools/delete-taxonomy-group.js +19 -0
  26. package/build/tools/delete-workflow.js +19 -0
  27. package/build/tools/get-asset.js +17 -0
  28. package/build/tools/get-content-item-translations.js +20 -0
  29. package/build/tools/get-content-item-variant.js +22 -0
  30. package/build/tools/get-content-item.js +17 -0
  31. package/build/tools/get-content-type-snippet.js +20 -0
  32. package/build/tools/get-content-type.js +17 -0
  33. package/build/tools/get-patch-guide.js +12 -12
  34. package/build/tools/get-published-content-item-variant-version.js +23 -0
  35. package/build/tools/get-taxonomy-group.js +17 -0
  36. package/build/tools/index.js +106 -0
  37. package/build/tools/list-asset-folders.js +14 -0
  38. package/build/tools/list-assets.js +23 -0
  39. package/build/tools/list-collections.js +14 -0
  40. package/build/tools/list-content-item-variants.js +50 -0
  41. package/build/tools/list-content-type-snippets.js +23 -0
  42. package/build/tools/list-content-types.js +23 -0
  43. package/build/tools/list-languages.js +24 -0
  44. package/build/tools/list-roles.js +14 -0
  45. package/build/tools/list-spaces.js +14 -0
  46. package/build/tools/list-taxonomy-groups.js +23 -0
  47. package/build/tools/list-workflows.js +14 -0
  48. package/build/tools/patch-asset-folders.js +25 -0
  49. package/build/tools/patch-collections.js +25 -0
  50. package/build/tools/patch-content-type-snippet.js +30 -0
  51. package/build/tools/patch-content-type.js +33 -0
  52. package/build/tools/patch-language.js +24 -0
  53. package/build/tools/patch-space.js +28 -0
  54. package/build/tools/patch-taxonomy-group.js +28 -0
  55. package/build/tools/publish-content-item-variant.js +72 -0
  56. package/build/tools/referencedToolNames.js +10 -0
  57. package/build/tools/search-content-item-variants.js +108 -0
  58. package/build/tools/toolDefinition.js +1 -0
  59. package/build/tools/unpublish-content-item-variant.js +72 -0
  60. package/build/tools/update-asset.js +23 -0
  61. package/build/tools/update-content-item-variant.js +36 -0
  62. package/build/tools/update-content-item.js +74 -0
  63. package/build/tools/update-workflow.js +31 -0
  64. package/package.json +18 -17
  65. package/build/tools/add-content-item-mapi.js +0 -47
  66. package/build/tools/add-content-type-mapi.js +0 -38
  67. package/build/tools/add-content-type-snippet-mapi.js +0 -35
  68. package/build/tools/add-language-mapi.js +0 -25
  69. package/build/tools/add-space-mapi.js +0 -23
  70. package/build/tools/add-taxonomy-group-mapi.js +0 -19
  71. package/build/tools/add-workflow-mapi.js +0 -24
  72. package/build/tools/bulk-get-items-variants-mapi.js +0 -31
  73. package/build/tools/change-variant-workflow-step-mapi.js +0 -36
  74. package/build/tools/create-language-variant-mapi.js +0 -44
  75. package/build/tools/create-variant-version-mapi.js +0 -28
  76. package/build/tools/delete-content-item-mapi.js +0 -24
  77. package/build/tools/delete-content-type-mapi.js +0 -24
  78. package/build/tools/delete-language-variant-mapi.js +0 -26
  79. package/build/tools/delete-space-mapi.js +0 -20
  80. package/build/tools/delete-taxonomy-group-mapi.js +0 -20
  81. package/build/tools/delete-type-snippet-mapi.js +0 -23
  82. package/build/tools/delete-workflow-mapi.js +0 -20
  83. package/build/tools/filter-variants-mapi.js +0 -49
  84. package/build/tools/get-asset-mapi.js +0 -21
  85. package/build/tools/get-item-mapi.js +0 -21
  86. package/build/tools/get-latest-variant-mapi.js +0 -23
  87. package/build/tools/get-published-variant-mapi.js +0 -24
  88. package/build/tools/get-taxonomy-group-mapi.js +0 -21
  89. package/build/tools/get-type-mapi.js +0 -21
  90. package/build/tools/get-type-snippet-mapi.js +0 -21
  91. package/build/tools/list-asset-folders-mapi.js +0 -15
  92. package/build/tools/list-assets-mapi.js +0 -24
  93. package/build/tools/list-collections-mapi.js +0 -15
  94. package/build/tools/list-content-type-snippets-mapi.js +0 -24
  95. package/build/tools/list-content-types-mapi.js +0 -24
  96. package/build/tools/list-languages-mapi.js +0 -24
  97. package/build/tools/list-roles-mapi.js +0 -15
  98. package/build/tools/list-spaces-mapi.js +0 -15
  99. package/build/tools/list-taxonomy-groups-mapi.js +0 -24
  100. package/build/tools/list-variants-collection-mapi.js +0 -26
  101. package/build/tools/list-variants-components-type-mapi.js +0 -26
  102. package/build/tools/list-variants-item-mapi.js +0 -21
  103. package/build/tools/list-variants-space-mapi.js +0 -24
  104. package/build/tools/list-variants-type-mapi.js +0 -26
  105. package/build/tools/list-workflows-mapi.js +0 -15
  106. package/build/tools/patch-asset-folders-mapi.js +0 -25
  107. package/build/tools/patch-collections-mapi.js +0 -25
  108. package/build/tools/patch-content-type-mapi.js +0 -33
  109. package/build/tools/patch-language-mapi.js +0 -24
  110. package/build/tools/patch-space-mapi.js +0 -28
  111. package/build/tools/patch-taxonomy-group-mapi.js +0 -28
  112. package/build/tools/patch-type-snippet-mapi.js +0 -30
  113. package/build/tools/publish-variant-mapi.js +0 -73
  114. package/build/tools/search-variants-mapi.js +0 -95
  115. package/build/tools/unpublish-variant-mapi.js +0 -73
  116. package/build/tools/update-asset-mapi.js +0 -24
  117. package/build/tools/update-content-item-mapi.js +0 -74
  118. package/build/tools/update-language-variant-mapi.js +0 -37
  119. package/build/tools/update-workflow-mapi.js +0 -32
@@ -3,6 +3,8 @@ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
3
3
  import { pathBasedPatchGuide } from "./context/patch-guide-path-based.js";
4
4
  import { propertyBasedPatchGuide } from "./context/patch-guide-property-based.js";
5
5
  import { referenceBasedPatchGuide } from "./context/patch-guide-reference-based.js";
6
+ import { getPatchGuideToolName } from "./referencedToolNames.js";
7
+ import { defineTool } from "./toolDefinition.js";
6
8
  const entityTypeSchema = z.enum([
7
9
  "content-type",
8
10
  "snippet",
@@ -26,15 +28,13 @@ const getGuideForEntity = (entityType) => {
26
28
  return propertyBasedPatchGuide;
27
29
  }
28
30
  };
29
- export const registerTool = (server) => {
30
- server.tool("get-patch-guide", "REQUIRED before any patch operation. Get patch operations guide for Kontent.ai Management API.", {
31
- entityType: entityTypeSchema.describe("Entity type to get patch guide for: content-type, snippet, taxonomy, collection, asset-folder, space, language"),
32
- }, async ({ entityType }) => {
33
- try {
34
- return createMcpToolSuccessResponse(getGuideForEntity(entityType));
35
- }
36
- catch (error) {
37
- throw new Error(`Failed to read patch guide: ${error instanceof Error ? error.message : "Unknown error"}`);
38
- }
39
- });
40
- };
31
+ export const getPatchGuide = defineTool(getPatchGuideToolName, "REQUIRED before any patch operation. Retrieve patch operations guide for modifying Kontent.ai content types, snippets, taxonomies, collections, asset folders, spaces, or languages.", {
32
+ entityType: entityTypeSchema.describe("Entity type to get patch guide for: content-type, snippet, taxonomy, collection, asset-folder, space, language"),
33
+ }, async ({ entityType }) => {
34
+ try {
35
+ return createMcpToolSuccessResponse(getGuideForEntity(entityType));
36
+ }
37
+ catch (error) {
38
+ throw new Error(`Failed to read patch guide: ${error instanceof Error ? error.message : "Unknown error"}`);
39
+ }
40
+ });
@@ -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 getPublishedContentItemVariantVersion = defineTool("get-published-content-item-variant-version", "Retrieve the published version of a Kontent.ai content item variant (live content). Use when a newer draft version exists but you need the currently published content. Returns the variant snapshot that is live on the Delivery API.", {
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
+ .published()
17
+ .toPromise();
18
+ return createMcpToolSuccessResponse(response.rawData);
19
+ }
20
+ catch (error) {
21
+ return handleMcpToolError(error, "Published Content Item Variant Version Retrieval");
22
+ }
23
+ });
@@ -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 getTaxonomyGroup = defineTool("get-taxonomy-group", "Retrieve Kontent.ai taxonomy group by ID or codename. Taxonomy groups provide a classification hierarchy of tree-structured terms (categories/tags) that can be nested to any depth for content categorization.", {
7
+ id: z.guid().describe("Taxonomy group ID"),
8
+ }, async ({ id }, { authInfo: { token, clientId } = {} }) => {
9
+ const client = createMapiClient(clientId, token);
10
+ try {
11
+ const response = await client.getTaxonomy().byTaxonomyId(id).toPromise();
12
+ return createMcpToolSuccessResponse(response.rawData);
13
+ }
14
+ catch (error) {
15
+ return handleMcpToolError(error, "Taxonomy Group Retrieval");
16
+ }
17
+ });
@@ -0,0 +1,106 @@
1
+ import { bulkGetContentItemVariants } from "./bulk-get-content-item-variants.js";
2
+ import { changeContentItemVariantWorkflowStep } from "./change-content-item-variant-workflow-step.js";
3
+ import { createContentItem } from "./create-content-item.js";
4
+ import { createContentItemVariant } from "./create-content-item-variant.js";
5
+ import { createContentType } from "./create-content-type.js";
6
+ import { createContentTypeSnippet } from "./create-content-type-snippet.js";
7
+ import { createLanguage } from "./create-language.js";
8
+ import { createNewContentItemVariantVersion } from "./create-new-content-item-variant-version.js";
9
+ import { createSpace } from "./create-space.js";
10
+ import { createTaxonomyGroup } from "./create-taxonomy-group.js";
11
+ import { createWorkflow } from "./create-workflow.js";
12
+ import { deleteContentItem } from "./delete-content-item.js";
13
+ import { deleteContentItemVariant } from "./delete-content-item-variant.js";
14
+ import { deleteContentType } from "./delete-content-type.js";
15
+ import { deleteContentTypeSnippet } from "./delete-content-type-snippet.js";
16
+ import { deleteSpace } from "./delete-space.js";
17
+ import { deleteTaxonomyGroup } from "./delete-taxonomy-group.js";
18
+ import { deleteWorkflow } from "./delete-workflow.js";
19
+ import { getAsset } from "./get-asset.js";
20
+ import { getContentItem } from "./get-content-item.js";
21
+ import { getContentItemTranslations } from "./get-content-item-translations.js";
22
+ import { getContentItemVariant } from "./get-content-item-variant.js";
23
+ import { getContentType } from "./get-content-type.js";
24
+ import { getContentTypeSnippet } from "./get-content-type-snippet.js";
25
+ import { getPatchGuide } from "./get-patch-guide.js";
26
+ import { getPublishedContentItemVariantVersion } from "./get-published-content-item-variant-version.js";
27
+ import { getTaxonomyGroup } from "./get-taxonomy-group.js";
28
+ import { listAssetFolders } from "./list-asset-folders.js";
29
+ import { listAssets } from "./list-assets.js";
30
+ import { listCollections } from "./list-collections.js";
31
+ import { listContentItemVariants } from "./list-content-item-variants.js";
32
+ import { listContentTypeSnippets } from "./list-content-type-snippets.js";
33
+ import { listContentTypes } from "./list-content-types.js";
34
+ import { listLanguages } from "./list-languages.js";
35
+ import { listRoles } from "./list-roles.js";
36
+ import { listSpaces } from "./list-spaces.js";
37
+ import { listTaxonomyGroups } from "./list-taxonomy-groups.js";
38
+ import { listWorkflows } from "./list-workflows.js";
39
+ import { patchAssetFolders } from "./patch-asset-folders.js";
40
+ import { patchCollections } from "./patch-collections.js";
41
+ import { patchContentType } from "./patch-content-type.js";
42
+ import { patchContentTypeSnippet } from "./patch-content-type-snippet.js";
43
+ import { patchLanguage } from "./patch-language.js";
44
+ import { patchSpace } from "./patch-space.js";
45
+ import { patchTaxonomyGroup } from "./patch-taxonomy-group.js";
46
+ import { publishContentItemVariant } from "./publish-content-item-variant.js";
47
+ import { searchContentItemVariants } from "./search-content-item-variants.js";
48
+ import { unpublishContentItemVariant } from "./unpublish-content-item-variant.js";
49
+ import { updateAsset } from "./update-asset.js";
50
+ import { updateContentItem } from "./update-content-item.js";
51
+ import { updateContentItemVariant } from "./update-content-item-variant.js";
52
+ import { updateWorkflow } from "./update-workflow.js";
53
+ export const allTools = {
54
+ createContentItem,
55
+ createContentTypeSnippet,
56
+ createContentType,
57
+ createLanguage,
58
+ createSpace,
59
+ createTaxonomyGroup,
60
+ createWorkflow,
61
+ bulkGetContentItemVariants,
62
+ changeContentItemVariantWorkflowStep,
63
+ createContentItemVariant,
64
+ createNewContentItemVariantVersion,
65
+ deleteContentItem,
66
+ deleteContentTypeSnippet,
67
+ deleteContentType,
68
+ deleteContentItemVariant,
69
+ deleteSpace,
70
+ deleteTaxonomyGroup,
71
+ deleteWorkflow,
72
+ getAsset,
73
+ getContentItem,
74
+ getContentTypeSnippet,
75
+ getContentType,
76
+ getContentItemTranslations,
77
+ getContentItemVariant,
78
+ getPatchGuide,
79
+ getPublishedContentItemVariantVersion,
80
+ getTaxonomyGroup,
81
+ listAssetFolders,
82
+ listAssets,
83
+ listCollections,
84
+ listContentTypeSnippets,
85
+ listContentTypes,
86
+ listContentItemVariants,
87
+ listLanguages,
88
+ listRoles,
89
+ listSpaces,
90
+ listTaxonomyGroups,
91
+ listWorkflows,
92
+ patchAssetFolders,
93
+ patchCollections,
94
+ patchContentTypeSnippet,
95
+ patchContentType,
96
+ patchLanguage,
97
+ patchSpace,
98
+ patchTaxonomyGroup,
99
+ publishContentItemVariant,
100
+ searchContentItemVariants,
101
+ unpublishContentItemVariant,
102
+ updateAsset,
103
+ updateContentItem,
104
+ updateContentItemVariant,
105
+ updateWorkflow,
106
+ };
@@ -0,0 +1,14 @@
1
+ import { createMapiClient } from "../clients/kontentClients.js";
2
+ import { handleMcpToolError } from "../utils/errorHandler.js";
3
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
4
+ import { defineTool } from "./toolDefinition.js";
5
+ export const listAssetFolders = defineTool("list-asset-folders", "List all Kontent.ai asset folders. Folders organize digital media files (images, videos, documents) into a hierarchical directory structure.", {}, async (_params, { authInfo: { token, clientId } = {} }) => {
6
+ const client = createMapiClient(clientId, token);
7
+ try {
8
+ const response = await client.listAssetFolders().toPromise();
9
+ return createMcpToolSuccessResponse(response.rawData);
10
+ }
11
+ catch (error) {
12
+ return handleMcpToolError(error, "Asset Folders Listing");
13
+ }
14
+ });
@@ -0,0 +1,23 @@
1
+ import { createMapiClient } from "../clients/kontentClients.js";
2
+ import { listAssetsSchema } from "../schemas/listSchemas.js";
3
+ import { handleMcpToolError } from "../utils/errorHandler.js";
4
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
5
+ import { defineTool } from "./toolDefinition.js";
6
+ export const listAssets = defineTool("list-assets", "List all Kontent.ai assets (paginated). Assets are digital media files (images, videos, documents, PDFs) referenced in content items.", listAssetsSchema.shape, async ({ continuation_token }, { authInfo: { token, clientId } = {} }) => {
7
+ const client = createMapiClient(clientId, token);
8
+ try {
9
+ const query = client.listAssets();
10
+ const response = await (continuation_token
11
+ ? query.xContinuationToken(continuation_token)
12
+ : query).toPromise();
13
+ return createMcpToolSuccessResponse({
14
+ data: response.rawData.assets,
15
+ pagination: {
16
+ continuation_token: response.data.pagination.continuationToken,
17
+ },
18
+ });
19
+ }
20
+ catch (error) {
21
+ return handleMcpToolError(error, "Assets Listing");
22
+ }
23
+ });
@@ -0,0 +1,14 @@
1
+ import { createMapiClient } from "../clients/kontentClients.js";
2
+ import { handleMcpToolError } from "../utils/errorHandler.js";
3
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
4
+ import { defineTool } from "./toolDefinition.js";
5
+ export const listCollections = defineTool("list-collections", "List all Kontent.ai collections. Collections organize and group content items by team, brand, or project for access control and content separation.", {}, async (_, { authInfo: { token, clientId } = {} }) => {
6
+ const client = createMapiClient(clientId, token);
7
+ try {
8
+ const response = await client.listCollections().toPromise();
9
+ return createMcpToolSuccessResponse(response.rawData);
10
+ }
11
+ catch (error) {
12
+ return handleMcpToolError(error, "Collections Listing");
13
+ }
14
+ });
@@ -0,0 +1,50 @@
1
+ import { createMapiClient } from "../clients/kontentClients.js";
2
+ import { filterVariantsSchema } from "../schemas/filterVariantSchemas.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, listContentItemVariantsToolName, searchContentItemVariantsToolName, } from "./referencedToolNames.js";
7
+ import { defineTool } from "./toolDefinition.js";
8
+ export const listContentItemVariants = defineTool(listContentItemVariantsToolName, `List, find, filter Kontent.ai content items with content item variants (language versions/translations) returning references (item ID + language ID). Filter by content item content type, collection, space, workflow step, taxonomy, contained content component content type, or publishing state. Search items and variants by EXACT keyword matching (terms use OR). Use ${searchContentItemVariantsToolName} for semantic/topic search. Use ${bulkGetContentItemVariantsToolName} to retrieve full content of the content item variants.`, filterVariantsSchema.shape, async ({ search_phrase, content_types, contributors, has_no_contributors, completion_statuses, language, workflow_steps, taxonomy_groups, spaces, collections, component_types, publishing_states, order_by, order_direction, 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.filterItemsWithVariants().withData({
16
+ filters: {
17
+ search_phrase,
18
+ content_types,
19
+ contributors,
20
+ has_no_contributors,
21
+ completion_statuses,
22
+ language,
23
+ workflow_steps,
24
+ taxonomy_groups,
25
+ spaces,
26
+ collections,
27
+ component_types,
28
+ publishing_states,
29
+ },
30
+ order: order_by
31
+ ? {
32
+ by: order_by,
33
+ direction: order_direction || "asc",
34
+ }
35
+ : undefined,
36
+ });
37
+ const response = await (continuation_token
38
+ ? query.xContinuationToken(continuation_token)
39
+ : query).toPromise();
40
+ return createMcpToolSuccessResponse({
41
+ variants: response.rawData.variants,
42
+ pagination: {
43
+ continuation_token: response.data.pagination.continuationToken,
44
+ },
45
+ });
46
+ }
47
+ catch (error) {
48
+ return handleMcpToolError(error, "Variant Filter");
49
+ }
50
+ });
@@ -0,0 +1,23 @@
1
+ import { createMapiClient } from "../clients/kontentClients.js";
2
+ import { listContentTypeSnippetsSchema } from "../schemas/listSchemas.js";
3
+ import { handleMcpToolError } from "../utils/errorHandler.js";
4
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
5
+ import { defineTool } from "./toolDefinition.js";
6
+ export const listContentTypeSnippets = defineTool("list-content-type-snippets", "List all Kontent.ai content type snippets (paginated). Retrieve every content type snippet — reusable, shared sets of elements included across multiple content types.", listContentTypeSnippetsSchema.shape, async ({ continuation_token }, { authInfo: { token, clientId } = {} }) => {
7
+ const client = createMapiClient(clientId, token);
8
+ try {
9
+ const query = client.listContentTypeSnippets();
10
+ const response = await (continuation_token
11
+ ? query.xContinuationToken(continuation_token)
12
+ : query).toPromise();
13
+ return createMcpToolSuccessResponse({
14
+ data: response.rawData.snippets,
15
+ pagination: {
16
+ continuation_token: response.data.pagination.continuationToken,
17
+ },
18
+ });
19
+ }
20
+ catch (error) {
21
+ return handleMcpToolError(error, "Content Type Snippets Listing");
22
+ }
23
+ });
@@ -0,0 +1,23 @@
1
+ import { createMapiClient } from "../clients/kontentClients.js";
2
+ import { listContentTypesSchema } from "../schemas/listSchemas.js";
3
+ import { handleMcpToolError } from "../utils/errorHandler.js";
4
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
5
+ import { defineTool } from "./toolDefinition.js";
6
+ export const listContentTypes = defineTool("list-content-types", "List all Kontent.ai content types (paginated). Retrieve every content type (schema/model) definition. Get an overview of all content type models, their elements, field validation rules, and content groups.", listContentTypesSchema.shape, async ({ continuation_token }, { authInfo: { token, clientId } = {} }) => {
7
+ const client = createMapiClient(clientId, token);
8
+ try {
9
+ const query = client.listContentTypes();
10
+ const response = await (continuation_token
11
+ ? query.xContinuationToken(continuation_token)
12
+ : query).toPromise();
13
+ return createMcpToolSuccessResponse({
14
+ data: response.rawData.types,
15
+ pagination: {
16
+ continuation_token: response.data.pagination.continuationToken,
17
+ },
18
+ });
19
+ }
20
+ catch (error) {
21
+ return handleMcpToolError(error, "Content Types Listing");
22
+ }
23
+ });
@@ -0,0 +1,24 @@
1
+ import { createMapiClient } from "../clients/kontentClients.js";
2
+ import { listLanguagesSchema } from "../schemas/listSchemas.js";
3
+ import { handleMcpToolError } from "../utils/errorHandler.js";
4
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
5
+ import { listLanguagesToolName } from "./referencedToolNames.js";
6
+ import { defineTool } from "./toolDefinition.js";
7
+ export const listLanguages = defineTool(listLanguagesToolName, "List all Kontent.ai languages (paginated), including inactive ones - check is_active property. Languages define available locales for translations and localization; each can have fallback language for content inheritance.", listLanguagesSchema.shape, async ({ continuation_token }, { authInfo: { token, clientId } = {} }) => {
8
+ const client = createMapiClient(clientId, token);
9
+ try {
10
+ const query = client.listLanguages();
11
+ const response = await (continuation_token
12
+ ? query.xContinuationToken(continuation_token)
13
+ : query).toPromise();
14
+ return createMcpToolSuccessResponse({
15
+ data: response.rawData.languages,
16
+ pagination: {
17
+ continuation_token: response.data.pagination.continuationToken,
18
+ },
19
+ });
20
+ }
21
+ catch (error) {
22
+ return handleMcpToolError(error, "Languages Listing");
23
+ }
24
+ });
@@ -0,0 +1,14 @@
1
+ import { createMapiClient } from "../clients/kontentClients.js";
2
+ import { handleMcpToolError } from "../utils/errorHandler.js";
3
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
4
+ import { defineTool } from "./toolDefinition.js";
5
+ export const listRoles = defineTool("list-roles", "List all Kontent.ai roles. Roles define user permissions and access control within the environment.", {}, async (_, { authInfo: { token, clientId } = {} }) => {
6
+ const client = createMapiClient(clientId, token);
7
+ try {
8
+ const response = await client.listRoles().toPromise();
9
+ return createMcpToolSuccessResponse(response.rawData.roles);
10
+ }
11
+ catch (error) {
12
+ return handleMcpToolError(error, "Roles Listing");
13
+ }
14
+ });
@@ -0,0 +1,14 @@
1
+ import { createMapiClient } from "../clients/kontentClients.js";
2
+ import { handleMcpToolError } from "../utils/errorHandler.js";
3
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
4
+ import { defineTool } from "./toolDefinition.js";
5
+ export const listSpaces = defineTool("list-spaces", "List all Kontent.ai spaces. Spaces provide channel-specific site configuration for managing multiple websites/channels. Each space has its own domain and preview URLs; collections connect to spaces to organize content per channel.", {}, async (_, { authInfo: { token, clientId } = {} }) => {
6
+ const client = createMapiClient(clientId, token);
7
+ try {
8
+ const response = await client.listSpaces().toPromise();
9
+ return createMcpToolSuccessResponse(response.rawData);
10
+ }
11
+ catch (error) {
12
+ return handleMcpToolError(error, "Spaces Listing");
13
+ }
14
+ });
@@ -0,0 +1,23 @@
1
+ import { createMapiClient } from "../clients/kontentClients.js";
2
+ import { listTaxonomyGroupsSchema } from "../schemas/listSchemas.js";
3
+ import { handleMcpToolError } from "../utils/errorHandler.js";
4
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
5
+ import { defineTool } from "./toolDefinition.js";
6
+ export const listTaxonomyGroups = defineTool("list-taxonomy-groups", "List all Kontent.ai taxonomy groups (paginated). Taxonomy groups contain hierarchical tree-structured terms (categories/tags) that can be nested to any depth for content categorization and classification.", listTaxonomyGroupsSchema.shape, async ({ continuation_token }, { authInfo: { token, clientId } = {} }) => {
7
+ const client = createMapiClient(clientId, token);
8
+ try {
9
+ const query = client.listTaxonomies();
10
+ const response = await (continuation_token
11
+ ? query.xContinuationToken(continuation_token)
12
+ : query).toPromise();
13
+ return createMcpToolSuccessResponse({
14
+ data: response.rawData.taxonomies,
15
+ pagination: {
16
+ continuation_token: response.data.pagination.continuationToken,
17
+ },
18
+ });
19
+ }
20
+ catch (error) {
21
+ return handleMcpToolError(error, "Taxonomy Groups Listing");
22
+ }
23
+ });
@@ -0,0 +1,14 @@
1
+ import { createMapiClient } from "../clients/kontentClients.js";
2
+ import { handleMcpToolError } from "../utils/errorHandler.js";
3
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
4
+ import { defineTool } from "./toolDefinition.js";
5
+ export const listWorkflows = defineTool("list-workflows", "List all Kontent.ai workflows and their steps. Workflows define content lifecycle stages: draft, review, approval, published, scheduled, archived.", {}, async (_, { authInfo: { token, clientId } = {} }) => {
6
+ const client = createMapiClient(clientId, token);
7
+ try {
8
+ const response = await client.listWorkflows().toPromise();
9
+ return createMcpToolSuccessResponse(response.rawData);
10
+ }
11
+ catch (error) {
12
+ return handleMcpToolError(error, "Workflows Listing");
13
+ }
14
+ });
@@ -0,0 +1,25 @@
1
+ import { createMapiClient } from "../clients/kontentClients.js";
2
+ import { assetFolderPatchOperationsSchema } from "../schemas/assetFolderSchemas.js";
3
+ import { handleMcpToolError } from "../utils/errorHandler.js";
4
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
5
+ import { getPatchGuideToolName } from "./referencedToolNames.js";
6
+ import { defineTool } from "./toolDefinition.js";
7
+ export const patchAssetFolders = defineTool("patch-asset-folders", `Update (modify/edit) Kontent.ai asset folders using patch operations (addInto, rename, remove). Call ${getPatchGuideToolName} first for operations reference.`, {
8
+ operations: assetFolderPatchOperationsSchema,
9
+ }, async ({ operations }, { authInfo: { token, clientId } = {} }) => {
10
+ const client = createMapiClient(clientId, token);
11
+ try {
12
+ const response = await client
13
+ .modifyAssetFolders()
14
+ .withData(operations)
15
+ .toPromise();
16
+ return createMcpToolSuccessResponse({
17
+ message: `Asset folders modified with ${operations.length} operation(s)`,
18
+ folders: response.rawData,
19
+ appliedOperations: operations,
20
+ });
21
+ }
22
+ catch (error) {
23
+ return handleMcpToolError(error, "Asset Folders Modification");
24
+ }
25
+ });
@@ -0,0 +1,25 @@
1
+ import { createMapiClient } from "../clients/kontentClients.js";
2
+ import { collectionPatchOperationsSchema } from "../schemas/collectionSchemas.js";
3
+ import { handleMcpToolError } from "../utils/errorHandler.js";
4
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
5
+ import { getPatchGuideToolName, listCollectionsToolName, } from "./referencedToolNames.js";
6
+ import { defineTool } from "./toolDefinition.js";
7
+ export const patchCollections = defineTool("patch-collections", `Update (modify/edit) Kontent.ai collections using patch operations (addInto, move, rename, remove). Call ${getPatchGuideToolName} first for operations reference.`, {
8
+ operations: collectionPatchOperationsSchema.describe(`Patch operations array. Call ${listCollectionsToolName} first. Use addInto to add new collections, move to reorder, remove to delete empty collections, replace to rename.`),
9
+ }, async ({ operations }, { authInfo: { token, clientId } = {} }) => {
10
+ const client = createMapiClient(clientId, token);
11
+ try {
12
+ const response = await client
13
+ .setCollections()
14
+ .withData(operations)
15
+ .toPromise();
16
+ return createMcpToolSuccessResponse({
17
+ message: `Collections updated successfully with ${operations.length} operation(s)`,
18
+ collections: response.rawData,
19
+ appliedOperations: operations,
20
+ });
21
+ }
22
+ catch (error) {
23
+ return handleMcpToolError(error, "Collections Patch");
24
+ }
25
+ });
@@ -0,0 +1,30 @@
1
+ import { z } from "zod";
2
+ import { createMapiClient } from "../clients/kontentClients.js";
3
+ import { snippetPatchOperationsSchema } from "../schemas/patchSchemas/snippetPatchSchemas.js";
4
+ import { handleMcpToolError } from "../utils/errorHandler.js";
5
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
6
+ import { getPatchGuideToolName } from "./referencedToolNames.js";
7
+ import { defineTool } from "./toolDefinition.js";
8
+ export const patchContentTypeSnippet = defineTool("patch-content-type-snippet", `Update (modify/edit) Kontent.ai content type snippet using patch operations (move, addInto, remove, replace elements). Call ${getPatchGuideToolName} first for operations reference.`, {
9
+ id: z.guid().describe("Content type snippet ID"),
10
+ operations: snippetPatchOperationsSchema.describe(`Patch operations array. CRITICAL: Always call get-content-type-snippet first.
11
+ - Use addInto/remove for arrays, replace for primitives/objects
12
+ - Snippets cannot contain: content_groups, snippet, or url_slug elements`),
13
+ }, async ({ id, operations }, { authInfo: { token, clientId } = {} }) => {
14
+ const client = createMapiClient(clientId, token);
15
+ try {
16
+ const response = await client
17
+ .modifyContentTypeSnippet()
18
+ .byTypeId(id)
19
+ .withData(operations)
20
+ .toPromise();
21
+ return createMcpToolSuccessResponse({
22
+ message: `Content type snippet updated successfully with ${operations.length} operation(s)`,
23
+ snippet: response.rawData,
24
+ appliedOperations: operations,
25
+ });
26
+ }
27
+ catch (error) {
28
+ return handleMcpToolError(error, "Content Type Snippet Patch");
29
+ }
30
+ });
@@ -0,0 +1,33 @@
1
+ import { z } from "zod";
2
+ import { createMapiClient } from "../clients/kontentClients.js";
3
+ import { patchOperationsSchema } from "../schemas/patchSchemas/contentTypePatchSchemas.js";
4
+ import { handleMcpToolError } from "../utils/errorHandler.js";
5
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
6
+ import { getPatchGuideToolName } from "./referencedToolNames.js";
7
+ import { defineTool } from "./toolDefinition.js";
8
+ export const patchContentType = defineTool("patch-content-type", `Update (modify/edit) Kontent.ai content type schema using patch operations (add, move, remove, replace elements/fields). Add new fields, rearrange or remove existing elements. Call ${getPatchGuideToolName} first for operations reference.`, {
9
+ id: z.guid().describe("Content type ID"),
10
+ operations: patchOperationsSchema.describe(`Patch operations array. CRITICAL: Always call get-content-type first.
11
+ - Use addInto/remove for arrays, replace for primitives/objects
12
+ - Only one url_slug element allowed per content type
13
+ - To remove content groups: set ALL elements' content_group to null AND remove ALL groups in one request
14
+ - URL slug with snippet: add snippet element first, then url_slug with depends_on reference`),
15
+ }, async ({ id, operations }, { authInfo: { token, clientId } = {} }) => {
16
+ const client = createMapiClient(clientId, token);
17
+ try {
18
+ // Apply patch operations using the modifyContentType method
19
+ const response = await client
20
+ .modifyContentType()
21
+ .byTypeId(id)
22
+ .withData(operations)
23
+ .toPromise();
24
+ return createMcpToolSuccessResponse({
25
+ message: `Content type updated successfully with ${operations.length} operation(s)`,
26
+ contentType: response.rawData,
27
+ appliedOperations: operations,
28
+ });
29
+ }
30
+ catch (error) {
31
+ return handleMcpToolError(error, `Content Type Patch`);
32
+ }
33
+ });
@@ -0,0 +1,24 @@
1
+ import { createMapiClient } from "../clients/kontentClients.js";
2
+ import { patchLanguageSchema } from "../schemas/languageSchemas.js";
3
+ import { handleMcpToolError } from "../utils/errorHandler.js";
4
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
5
+ import { getPatchGuideToolName } from "./referencedToolNames.js";
6
+ import { defineTool } from "./toolDefinition.js";
7
+ export const patchLanguage = defineTool("patch-language", `Update (modify/edit) Kontent.ai language properties using replace patch operations. Call ${getPatchGuideToolName} first. Only active languages can be edited - to activate/deactivate, use the Kontent.ai web UI.`, patchLanguageSchema.shape, async ({ languageId, operations }, { authInfo: { token, clientId } = {} }) => {
8
+ const client = createMapiClient(clientId, token);
9
+ try {
10
+ const response = await client
11
+ .modifyLanguage()
12
+ .byLanguageId(languageId)
13
+ .withData(operations)
14
+ .toPromise();
15
+ return createMcpToolSuccessResponse({
16
+ message: `Language updated with ${operations.length} operation(s)`,
17
+ language: response.rawData,
18
+ appliedOperations: operations,
19
+ });
20
+ }
21
+ catch (error) {
22
+ return handleMcpToolError(error, "Language Patch");
23
+ }
24
+ });
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+ import { createMapiClient } from "../clients/kontentClients.js";
3
+ import { spacePatchOperationsSchema } from "../schemas/spaceSchemas.js";
4
+ import { handleMcpToolError } from "../utils/errorHandler.js";
5
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
6
+ import { getPatchGuideToolName } from "./referencedToolNames.js";
7
+ import { defineTool } from "./toolDefinition.js";
8
+ export const patchSpace = defineTool("patch-space", `Update (modify/edit) Kontent.ai space properties using replace patch operations. Call ${getPatchGuideToolName} first for operations reference.`, {
9
+ id: z.guid().describe("Space ID"),
10
+ operations: spacePatchOperationsSchema,
11
+ }, async ({ id, operations }, { authInfo: { token, clientId } = {} }) => {
12
+ const client = createMapiClient(clientId, token);
13
+ try {
14
+ const response = await client
15
+ .modifySpace()
16
+ .bySpaceId(id)
17
+ .withData(operations)
18
+ .toPromise();
19
+ return createMcpToolSuccessResponse({
20
+ message: `Space updated successfully with ${operations.length} operation(s)`,
21
+ space: response.rawData,
22
+ appliedOperations: operations,
23
+ });
24
+ }
25
+ catch (error) {
26
+ return handleMcpToolError(error, "Space Modification");
27
+ }
28
+ });
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+ import { createMapiClient } from "../clients/kontentClients.js";
3
+ import { taxonomyPatchOperationsSchema } from "../schemas/patchSchemas/taxonomyPatchSchemas.js";
4
+ import { handleMcpToolError } from "../utils/errorHandler.js";
5
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
6
+ import { getPatchGuideToolName, getTaxonomyGroupToolName, } from "./referencedToolNames.js";
7
+ import { defineTool } from "./toolDefinition.js";
8
+ export const patchTaxonomyGroup = defineTool("patch-taxonomy-group", `Update (modify/edit) and organize Kontent.ai taxonomy group terms using patch operations (addInto, move, remove, replace). Call ${getPatchGuideToolName} first for operations reference.`, {
9
+ id: z.guid().describe("Taxonomy group ID"),
10
+ operations: taxonomyPatchOperationsSchema.describe(`Patch operations array. Call ${getTaxonomyGroupToolName} first. Use addInto to add terms (with optional reference for parent), move to reorder/nest terms (before/after/under - mutually exclusive), remove to delete terms, replace for name/codename/terms.`),
11
+ }, async ({ id, operations }, { authInfo: { token, clientId } = {} }) => {
12
+ const client = createMapiClient(clientId, token);
13
+ try {
14
+ const response = await client
15
+ .modifyTaxonomy()
16
+ .byTaxonomyId(id)
17
+ .withData(operations)
18
+ .toPromise();
19
+ return createMcpToolSuccessResponse({
20
+ message: `Taxonomy group updated with ${operations.length} operation(s)`,
21
+ taxonomyGroup: response.rawData,
22
+ appliedOperations: operations,
23
+ });
24
+ }
25
+ catch (error) {
26
+ return handleMcpToolError(error, "Taxonomy Group Patch");
27
+ }
28
+ });