@kontent-ai/mcp-server 0.23.3 → 0.25.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 (41) hide show
  1. package/README.md +21 -2
  2. package/build/bin.js +1 -1
  3. package/build/schemas/assetFolderSchemas.js +44 -0
  4. package/build/schemas/assetSchemas.js +23 -0
  5. package/build/schemas/{contentTypeSchemas.js → contentTypeAndSnippetSchemas.js} +9 -10
  6. package/build/schemas/patchSchemas/baseTypeAndSnippetPatchSchemas.js +41 -0
  7. package/build/schemas/patchSchemas/contentTypePatchSchemas.js +4 -46
  8. package/build/schemas/patchSchemas/snippetPatchSchemas.js +22 -0
  9. package/build/schemas/patchSchemas/taxonomyPatchSchemas.js +67 -0
  10. package/build/schemas/searchOperationSchemas.js +5 -5
  11. package/build/schemas/spaceSchemas.js +30 -0
  12. package/build/schemas/workflowSchemas.js +74 -76
  13. package/build/server.js +28 -0
  14. package/build/telemetry/applicationInsights.js +1 -1
  15. package/build/tools/add-content-type-mapi.js +1 -1
  16. package/build/tools/add-content-type-snippet-mapi.js +1 -1
  17. package/build/tools/add-space-mapi.js +23 -0
  18. package/build/tools/add-workflow-mapi.js +24 -0
  19. package/build/tools/change-variant-workflow-step-mapi.js +4 -6
  20. package/build/tools/context/patch-guide-path-based.js +53 -0
  21. package/build/tools/context/patch-guide-property-based.js +42 -0
  22. package/build/tools/context/patch-guide-reference-based.js +86 -0
  23. package/build/tools/delete-space-mapi.js +20 -0
  24. package/build/tools/delete-taxonomy-group-mapi.js +20 -0
  25. package/build/tools/delete-type-snippet-mapi.js +23 -0
  26. package/build/tools/delete-workflow-mapi.js +20 -0
  27. package/build/tools/get-patch-guide.js +31 -3
  28. package/build/tools/get-taxonomy-group-mapi.js +2 -2
  29. package/build/tools/list-asset-folders-mapi.js +15 -0
  30. package/build/tools/list-roles-mapi.js +15 -0
  31. package/build/tools/list-spaces-mapi.js +1 -1
  32. package/build/tools/list-taxonomy-groups-mapi.js +1 -1
  33. package/build/tools/patch-asset-folders-mapi.js +25 -0
  34. package/build/tools/patch-content-type-mapi.js +10 -6
  35. package/build/tools/patch-space-mapi.js +28 -0
  36. package/build/tools/patch-taxonomy-group-mapi.js +28 -0
  37. package/build/tools/patch-type-snippet-mapi.js +30 -0
  38. package/build/tools/update-asset-mapi.js +24 -0
  39. package/build/tools/update-workflow-mapi.js +32 -0
  40. package/package.json +1 -1
  41. package/build/tools/context/patch-operations-guide.js +0 -58
package/README.md CHANGED
@@ -63,7 +63,7 @@ npx @kontent-ai/mcp-server@latest shttp
63
63
 
64
64
  ### Patch Operations Guide
65
65
 
66
- * **get-patch-guide** – 🚨 **REQUIRED before any patch operation**. Get JSON Patch operations guide for Kontent.ai Management API
66
+ * **get-patch-guide** – 🚨 **REQUIRED before any patch operation**. Get patch operations guide for Kontent.ai Management API by entity type
67
67
 
68
68
  ### Content Type Management
69
69
 
@@ -78,17 +78,20 @@ npx @kontent-ai/mcp-server@latest shttp
78
78
  * **get-type-snippet-mapi** – Get Kontent.ai content type snippet by internal ID from Management API
79
79
  * **list-content-type-snippets-mapi** – Get all Kontent.ai content type snippets from Management API
80
80
  * **add-content-type-snippet-mapi** – Add new Kontent.ai content type snippet via Management API
81
+ * **patch-type-snippet-mapi** – Update an existing Kontent.ai content type snippet by internal ID using patch operations (move, addInto, remove, replace)
82
+ * **delete-type-snippet-mapi** – Delete a Kontent.ai content type snippet by codename
81
83
 
82
84
  ### Taxonomy Management
83
85
 
84
86
  * **get-taxonomy-group-mapi** – Get Kontent.ai taxonomy group by internal ID from Management API
85
87
  * **list-taxonomy-groups-mapi** – Get all Kontent.ai taxonomy groups from Management API
86
88
  * **add-taxonomy-group-mapi** – Add new Kontent.ai taxonomy group via Management API
89
+ * **patch-taxonomy-group-mapi** – Update Kontent.ai taxonomy group using patch operations (addInto, move, remove, replace) via Management API
90
+ * **delete-taxonomy-group-mapi** – Delete Kontent.ai taxonomy group by internal ID
87
91
 
88
92
  ### Content Item Management
89
93
 
90
94
  * **get-item-mapi** – Get Kontent.ai item by internal ID from Management API
91
- * **get-item-dapi** – Get Kontent.ai item by codename from Delivery API
92
95
  * **get-latest-variant-mapi** – Get latest version of Kontent.ai language variant from Management API
93
96
  * **get-published-variant-mapi** – Get published version of Kontent.ai language variant from Management API
94
97
  * **list-variants-item-mapi** – List all Kontent.ai language variants of a content item from Management API
@@ -109,6 +112,12 @@ npx @kontent-ai/mcp-server@latest shttp
109
112
 
110
113
  * **get-asset-mapi** – Get a specific Kontent.ai asset by internal ID from Management API
111
114
  * **list-assets-mapi** – Get all Kontent.ai assets from Management API
115
+ * **update-asset-mapi** – Update Kontent.ai asset by internal ID
116
+
117
+ ### Asset Folder Management
118
+
119
+ * **list-asset-folders-mapi** – List all Kontent.ai asset folders
120
+ * **patch-asset-folders-mapi** – Modify Kontent.ai asset folders using patch operations (addInto to add new folders, rename to change names, remove to delete folders)
112
121
 
113
122
  ### Language Management
114
123
 
@@ -124,10 +133,20 @@ npx @kontent-ai/mcp-server@latest shttp
124
133
  ### Space Management
125
134
 
126
135
  * **list-spaces-mapi** – Get all Kontent.ai spaces from Management API
136
+ * **add-space-mapi** – Add Kontent.ai space to environment
137
+ * **patch-space-mapi** – Patch Kontent.ai space using replace operations
138
+ * **delete-space-mapi** – Delete Kontent.ai space
139
+
140
+ ### Role Management
141
+
142
+ * **list-roles-mapi** – Get all Kontent.ai roles from Management API. Requires Enterprise or Flex plan with "Manage custom roles" permission
127
143
 
128
144
  ### Workflow Management
129
145
 
130
146
  * **list-workflows-mapi** – Get all Kontent.ai workflows from Management API. Workflows define the content lifecycle stages and transitions between them
147
+ * **add-workflow-mapi** – Create a new Kontent.ai workflow via Management API. Define custom workflow steps, transitions, scopes (content types and collections), and role permissions
148
+ * **update-workflow-mapi** – Update an existing Kontent.ai workflow by ID via Management API. Modify steps, transitions, scopes, and role permissions. Cannot remove steps that are in use
149
+ * **delete-workflow-mapi** – Delete a Kontent.ai workflow by ID via Management API. The workflow must not be in use by any content items
131
150
  * **change-variant-workflow-step-mapi** – Change the workflow step of a language variant in Kontent.ai. This operation moves a language variant to a different step in the workflow, enabling content lifecycle management such as moving content from draft to review, review to published, etc.
132
151
  * **publish-variant-mapi** – Publish or schedule a language variant of a content item in Kontent.ai. This operation can either immediately publish the variant or schedule it for publication at a specific future date and time with optional timezone specification
133
152
  * **unpublish-variant-mapi** – Unpublish or schedule unpublishing of a language variant of a content item in Kontent.ai. This operation can either immediately unpublish the variant (making it unavailable through the Delivery API) or schedule it for unpublishing at a specific future date and time with optional timezone specification
package/build/bin.js CHANGED
@@ -152,7 +152,7 @@ Available endpoints:
152
152
  async function startStdio() {
153
153
  const { server } = createServer();
154
154
  const transport = new StdioServerTransport();
155
- console.log(`Kontent.ai MCP Server v${version} (stdio) starting`);
155
+ console.error(`Kontent.ai MCP Server v${version} (stdio) starting`);
156
156
  await server.connect(transport);
157
157
  }
158
158
  async function main() {
@@ -0,0 +1,44 @@
1
+ import { z } from "zod";
2
+ import { referenceObjectSchema } from "./referenceObjectSchema.js";
3
+ const assetFolderValueSchema = z.object({
4
+ name: z.string(),
5
+ codename: z.string().optional(),
6
+ external_id: z.string().optional(),
7
+ folders: z.lazy(() => z.array(assetFolderValueSchema)).optional(),
8
+ });
9
+ const addIntoBaseSchema = {
10
+ op: z.literal("addInto"),
11
+ reference: referenceObjectSchema
12
+ .optional()
13
+ .describe("Parent folder reference. Omit to add at root level."),
14
+ value: assetFolderValueSchema,
15
+ };
16
+ const addIntoBeforeOperationSchema = z.object({
17
+ ...addIntoBaseSchema,
18
+ before: referenceObjectSchema,
19
+ });
20
+ const addIntoAfterOperationSchema = z.object({
21
+ ...addIntoBaseSchema,
22
+ after: referenceObjectSchema,
23
+ });
24
+ const addIntoDefaultOperationSchema = z.object(addIntoBaseSchema);
25
+ const renameOperationSchema = z.object({
26
+ op: z.literal("rename"),
27
+ reference: referenceObjectSchema,
28
+ value: z.string(),
29
+ });
30
+ const removeOperationSchema = z.object({
31
+ op: z.literal("remove"),
32
+ reference: referenceObjectSchema,
33
+ });
34
+ const assetFolderPatchOperationSchema = z.union([
35
+ addIntoBeforeOperationSchema,
36
+ addIntoAfterOperationSchema,
37
+ addIntoDefaultOperationSchema,
38
+ renameOperationSchema,
39
+ removeOperationSchema,
40
+ ]);
41
+ export const assetFolderPatchOperationsSchema = z
42
+ .array(assetFolderPatchOperationSchema)
43
+ .min(1)
44
+ .describe("Patch operations array. Use addInto to add new folders (with optional reference for parent, before/after for positioning), rename to change folder names, remove to delete folders.");
@@ -0,0 +1,23 @@
1
+ import { z } from "zod";
2
+ import { referenceObjectSchema } from "./referenceObjectSchema.js";
3
+ const assetDescriptionSchema = z.object({
4
+ language: referenceObjectSchema,
5
+ description: z.string(),
6
+ });
7
+ const assetTaxonomyElementSchema = z.object({
8
+ element: referenceObjectSchema,
9
+ value: z.array(referenceObjectSchema),
10
+ });
11
+ const assetCollectionReferenceSchema = z.object({
12
+ reference: referenceObjectSchema,
13
+ });
14
+ export const updateAssetDataSchema = z
15
+ .object({
16
+ title: z.string().optional(),
17
+ codename: z.string().optional(),
18
+ collection: assetCollectionReferenceSchema.optional(),
19
+ folder: referenceObjectSchema.optional(),
20
+ descriptions: z.array(assetDescriptionSchema).optional(),
21
+ elements: z.array(assetTaxonomyElementSchema).optional(),
22
+ })
23
+ .describe("Only include properties you want to update; omitted fields retain existing values.");
@@ -1,9 +1,5 @@
1
1
  import { z } from "zod";
2
- // Reference by id or codename (id preferred)
3
- export const referenceObjectSchema = z.object({
4
- id: z.string().optional(),
5
- codename: z.string().optional(),
6
- });
2
+ import { referenceObjectSchema } from "./referenceObjectSchema.js";
7
3
  // Common property schemas
8
4
  const baseElementSchema = {
9
5
  codename: z.string().optional(),
@@ -16,7 +12,10 @@ const contentGroupElementSchema = {
16
12
  const namedElementSchema = {
17
13
  ...baseElementSchema,
18
14
  name: z.string(),
19
- guidelines: z.string().optional(),
15
+ guidelines: z
16
+ .string()
17
+ .optional()
18
+ .describe("Plain text guidelines shown to editors"),
20
19
  is_required: z.boolean().optional(),
21
20
  is_non_localizable: z.boolean().optional(),
22
21
  };
@@ -93,7 +92,7 @@ const assetElementSchema = {
93
92
  const customElementSchema = {
94
93
  type: z.literal("custom"),
95
94
  ...namedElementSchema,
96
- source_url: z.string(),
95
+ source_url: z.url(),
97
96
  json_parameters: z.string().optional(),
98
97
  allowed_elements: z.array(referenceObjectSchema).optional(),
99
98
  };
@@ -105,7 +104,9 @@ const dateTimeElementSchema = {
105
104
  const guidelinesElementSchema = {
106
105
  type: z.literal("guidelines"),
107
106
  ...baseElementSchema,
108
- guidelines: z.string(),
107
+ guidelines: z
108
+ .string()
109
+ .describe("HTML content for guidelines element. Must be valid HTML."),
109
110
  };
110
111
  const modularContentElementSchema = {
111
112
  type: z.literal("modular_content"),
@@ -292,14 +293,12 @@ export const contentGroupSchema = z.object({
292
293
  external_id: z.string().optional(),
293
294
  codename: z.string().optional(),
294
295
  });
295
- // Define a union type for snippet elements (excluding url_slug and snippet elements)
296
296
  export const snippetElementSchema = z.discriminatedUnion("type", [
297
297
  z.object(assetElementSchema),
298
298
  z.object(customElementSchema),
299
299
  z.object(dateTimeElementSchema),
300
300
  z.object(guidelinesElementSchema),
301
301
  z.object(modularContentElementSchema),
302
- z.object(subpagesElementSchema),
303
302
  z.object(multipleChoiceElementSchema),
304
303
  z.object(numberElementSchema),
305
304
  z.object(richTextElementSchema),
@@ -0,0 +1,41 @@
1
+ import { z } from "zod";
2
+ import { allowedBlockSchema, allowedFormattingSchema, allowedTableBlockSchema, allowedTableFormattingSchema, allowedTableTextBlockSchema, allowedTextBlockSchema, arrayDefaultSchema, countLimitSchema, numberDefaultSchema, optionSchema, regexValidationSchema, stringDefaultSchema, textLengthLimitSchema, } from "../contentTypeAndSnippetSchemas.js";
3
+ import { referenceObjectSchema } from "../referenceObjectSchema.js";
4
+ export const moveOperationSchema = z.object({
5
+ op: z.literal("move"),
6
+ path: z.string().describe("Path to object (format: id:{uuid})"),
7
+ before: referenceObjectSchema.optional(),
8
+ after: referenceObjectSchema.optional(),
9
+ });
10
+ export const removeOperationSchema = z.object({
11
+ op: z.literal("remove"),
12
+ path: z.string().describe("Path to item to remove (format: id:{uuid})"),
13
+ });
14
+ export const sharedAddIntoValueSchemas = [
15
+ optionSchema,
16
+ referenceObjectSchema,
17
+ allowedBlockSchema,
18
+ allowedFormattingSchema,
19
+ allowedTextBlockSchema,
20
+ allowedTableBlockSchema,
21
+ allowedTableFormattingSchema,
22
+ allowedTableTextBlockSchema,
23
+ z.string(),
24
+ z.number(),
25
+ z.boolean(),
26
+ z.null(),
27
+ z.any(),
28
+ ];
29
+ export const sharedReplaceValueSchemas = [
30
+ regexValidationSchema,
31
+ textLengthLimitSchema,
32
+ countLimitSchema,
33
+ arrayDefaultSchema,
34
+ stringDefaultSchema,
35
+ numberDefaultSchema,
36
+ z.string(),
37
+ z.number(),
38
+ z.boolean(),
39
+ z.null(),
40
+ z.any(),
41
+ ];
@@ -1,66 +1,24 @@
1
- // Patch operation schemas for content type modifications
2
- // Based on: https://kontent.ai/learn/docs/apis/openapi/management-api-v2/#operation/modify-a-content-type
3
1
  import { z } from "zod";
4
- import { allowedBlockSchema, allowedFormattingSchema, allowedTableBlockSchema, allowedTableFormattingSchema, allowedTableTextBlockSchema, allowedTextBlockSchema, arrayDefaultSchema, contentGroupSchema, countLimitSchema, dependsOnSchema, elementSchema, numberDefaultSchema, optionSchema, referenceObjectSchema, regexValidationSchema, stringDefaultSchema, textLengthLimitSchema, } from "../contentTypeSchemas.js";
5
- // Move operation - Move elements within content type
6
- const moveOperationSchema = z.object({
7
- op: z.literal("move"),
8
- path: z.string().describe("Path to object (format: id:{uuid})"),
9
- before: referenceObjectSchema.optional(),
10
- after: referenceObjectSchema.optional(),
11
- });
12
- // AddInto operation - Add new elements to content type
2
+ import { contentGroupSchema, dependsOnSchema, elementSchema, } from "../contentTypeAndSnippetSchemas.js";
3
+ import { moveOperationSchema, removeOperationSchema, sharedAddIntoValueSchemas, sharedReplaceValueSchemas, } from "./baseTypeAndSnippetPatchSchemas.js";
13
4
  const addIntoOperationSchema = z.object({
14
5
  op: z.literal("addInto"),
15
6
  path: z.string().describe("Path where to add item (format: id:{uuid})"),
16
7
  value: z.union([
17
8
  elementSchema,
18
- optionSchema,
19
9
  contentGroupSchema,
20
- referenceObjectSchema,
21
- allowedBlockSchema,
22
- allowedFormattingSchema,
23
- allowedTextBlockSchema,
24
- allowedTableBlockSchema,
25
- allowedTableFormattingSchema,
26
- allowedTableTextBlockSchema,
27
- z.string(),
28
- z.number(),
29
- z.boolean(),
30
- z.null(),
31
- z.any(),
10
+ ...sharedAddIntoValueSchemas,
32
11
  ]),
33
12
  });
34
- // Remove operation - Remove elements from content type
35
- const removeOperationSchema = z.object({
36
- op: z.literal("remove"),
37
- path: z.string().describe("Path to item to remove (format: id:{uuid})"),
38
- });
39
- // Replace operation - Replace/update existing elements in content type
40
13
  const replaceOperationSchema = z.object({
41
14
  op: z.literal("replace"),
42
15
  path: z.string().describe("Path to property to replace (format: id:{uuid})"),
43
- value: z.union([
44
- dependsOnSchema,
45
- regexValidationSchema,
46
- textLengthLimitSchema,
47
- countLimitSchema,
48
- arrayDefaultSchema,
49
- stringDefaultSchema,
50
- numberDefaultSchema,
51
- z.string(),
52
- z.number(),
53
- z.boolean(),
54
- z.null(),
55
- z.any(),
56
- ]),
16
+ value: z.union([dependsOnSchema, ...sharedReplaceValueSchemas]),
57
17
  });
58
- // Union type for all patch operations
59
18
  export const patchOperationSchema = z.discriminatedUnion("op", [
60
19
  moveOperationSchema,
61
20
  addIntoOperationSchema,
62
21
  removeOperationSchema,
63
22
  replaceOperationSchema,
64
23
  ]);
65
- // Schema for array of patch operations
66
24
  export const patchOperationsSchema = z.array(patchOperationSchema).min(1);
@@ -0,0 +1,22 @@
1
+ import { z } from "zod";
2
+ import { snippetElementSchema } from "../contentTypeAndSnippetSchemas.js";
3
+ import { moveOperationSchema, removeOperationSchema, sharedAddIntoValueSchemas, sharedReplaceValueSchemas, } from "./baseTypeAndSnippetPatchSchemas.js";
4
+ const addIntoOperationSchema = z.object({
5
+ op: z.literal("addInto"),
6
+ path: z.string().describe("Path where to add item (format: id:{uuid})"),
7
+ value: z.union([snippetElementSchema, ...sharedAddIntoValueSchemas]),
8
+ });
9
+ const replaceOperationSchema = z.object({
10
+ op: z.literal("replace"),
11
+ path: z.string().describe("Path to property to replace (format: id:{uuid})"),
12
+ value: z.union(sharedReplaceValueSchemas),
13
+ });
14
+ export const snippetPatchOperationSchema = z.discriminatedUnion("op", [
15
+ moveOperationSchema,
16
+ addIntoOperationSchema,
17
+ removeOperationSchema,
18
+ replaceOperationSchema,
19
+ ]);
20
+ export const snippetPatchOperationsSchema = z
21
+ .array(snippetPatchOperationSchema)
22
+ .min(1);
@@ -0,0 +1,67 @@
1
+ import { z } from "zod";
2
+ import { referenceObjectSchema } from "../referenceObjectSchema.js";
3
+ const taxonomyTermValueSchema = z.object({
4
+ name: z.string(),
5
+ codename: z.string().optional(),
6
+ external_id: z.string().optional(),
7
+ terms: z.lazy(() => z.array(taxonomyTermValueSchema)).optional(),
8
+ });
9
+ const addIntoBaseSchema = {
10
+ op: z.literal("addInto"),
11
+ reference: referenceObjectSchema
12
+ .optional()
13
+ .describe("Parent term reference. Omit to add at root level of taxonomy group."),
14
+ value: taxonomyTermValueSchema,
15
+ };
16
+ const addIntoBeforeOperationSchema = z.object({
17
+ ...addIntoBaseSchema,
18
+ before: referenceObjectSchema,
19
+ });
20
+ const addIntoAfterOperationSchema = z.object({
21
+ ...addIntoBaseSchema,
22
+ after: referenceObjectSchema,
23
+ });
24
+ const addIntoDefaultOperationSchema = z.object(addIntoBaseSchema);
25
+ const moveBaseSchema = {
26
+ op: z.literal("move"),
27
+ reference: referenceObjectSchema,
28
+ };
29
+ const moveBeforeOperationSchema = z.object({
30
+ ...moveBaseSchema,
31
+ before: referenceObjectSchema,
32
+ });
33
+ const moveAfterOperationSchema = z.object({
34
+ ...moveBaseSchema,
35
+ after: referenceObjectSchema,
36
+ });
37
+ const moveUnderOperationSchema = z.object({
38
+ ...moveBaseSchema,
39
+ under: referenceObjectSchema.describe("Move as child of this term (tree nesting)"),
40
+ });
41
+ const removeOperationSchema = z.object({
42
+ op: z.literal("remove"),
43
+ reference: referenceObjectSchema,
44
+ });
45
+ const replaceOperationSchema = z.object({
46
+ op: z.literal("replace"),
47
+ reference: referenceObjectSchema
48
+ .optional()
49
+ .describe("Term reference. Omit when modifying group-level properties (name, codename). Required when modifying specific term."),
50
+ property_name: z.enum(["name", "codename", "terms"]),
51
+ value: z
52
+ .union([z.string(), z.array(taxonomyTermValueSchema)])
53
+ .describe("New value. String for name/codename, array for terms."),
54
+ });
55
+ export const taxonomyPatchOperationSchema = z.union([
56
+ addIntoBeforeOperationSchema,
57
+ addIntoAfterOperationSchema,
58
+ addIntoDefaultOperationSchema,
59
+ moveBeforeOperationSchema,
60
+ moveAfterOperationSchema,
61
+ moveUnderOperationSchema,
62
+ removeOperationSchema,
63
+ replaceOperationSchema,
64
+ ]);
65
+ export const taxonomyPatchOperationsSchema = z
66
+ .array(taxonomyPatchOperationSchema)
67
+ .min(1);
@@ -3,9 +3,9 @@ export const searchOperationSchema = z.object({
3
3
  searchPhrase: z
4
4
  .string()
5
5
  .describe("Search phrase for AI-powered semantic search. Uses vector database to find content by meaning and similarity, not just exact keyword matching"),
6
- filter: z
7
- .object({
8
- variantId: z.guid().describe("UUID of the language variant to filter by"),
9
- })
10
- .describe("Mandatory content item variant filter to restrict search scope. Must specify a valid variant UUID"),
6
+ filter: z.object({
7
+ variantId: z
8
+ .guid()
9
+ .describe("Language ID from list-languages-mapi. Use default language (is_default=true) if not specified by user."),
10
+ }),
11
11
  });
@@ -0,0 +1,30 @@
1
+ import { z } from "zod";
2
+ import { referenceObjectSchema } from "./referenceObjectSchema.js";
3
+ const nameReplaceOperationSchema = z.object({
4
+ op: z.literal("replace"),
5
+ property_name: z.literal("name"),
6
+ value: z.string(),
7
+ });
8
+ const codenameReplaceOperationSchema = z.object({
9
+ op: z.literal("replace"),
10
+ property_name: z.literal("codename"),
11
+ value: z.string(),
12
+ });
13
+ const collectionsReplaceOperationSchema = z.object({
14
+ op: z.literal("replace"),
15
+ property_name: z.literal("collections"),
16
+ value: z.array(referenceObjectSchema),
17
+ });
18
+ export const spacePatchOperationSchema = z.discriminatedUnion("property_name", [
19
+ nameReplaceOperationSchema,
20
+ codenameReplaceOperationSchema,
21
+ collectionsReplaceOperationSchema,
22
+ ]);
23
+ export const spacePatchOperationsSchema = z
24
+ .array(spacePatchOperationSchema)
25
+ .min(1);
26
+ export const addSpaceSchema = z.object({
27
+ name: z.string(),
28
+ codename: z.string().optional(),
29
+ collections: z.array(referenceObjectSchema).optional(),
30
+ });
@@ -1,98 +1,96 @@
1
1
  import { z } from "zod";
2
- // Schema for a workflow step
3
- const workflowStepSchema = z.object({
4
- id: z
5
- .guid()
6
- .describe("The unique identifier of the workflow step in UUID format"),
7
- name: z.string().describe("The human-readable name of the workflow step"),
2
+ import { referenceObjectSchema } from "./referenceObjectSchema.js";
3
+ // Step color options (matching SDK WorkflowColor type)
4
+ const workflowStepColorSchema = z
5
+ .enum([
6
+ "gray",
7
+ "red",
8
+ "rose",
9
+ "light-purple",
10
+ "dark-purple",
11
+ "dark-blue",
12
+ "light-blue",
13
+ "sky-blue",
14
+ "mint-green",
15
+ "persian-green",
16
+ "dark-green",
17
+ "light-green",
18
+ "yellow",
19
+ "pink",
20
+ "orange",
21
+ "brown",
22
+ ])
23
+ .describe("Color of the workflow step displayed in the UI");
24
+ // Transition reference schema (step codename reference)
25
+ const transitionToStepSchema = z.object({
26
+ codename: z.string().optional().describe("Target step codename"),
27
+ id: z.guid().optional().describe("Target step ID (for update operations)"),
28
+ });
29
+ const transitionToSchema = z.object({
30
+ step: transitionToStepSchema.describe("Reference to the target step"),
31
+ });
32
+ // Workflow step input schema (for creating/updating workflows)
33
+ const workflowStepInputSchema = z.object({
34
+ name: z.string().describe("Human-readable name of the workflow step"),
8
35
  codename: z
9
36
  .string()
10
- .describe("The codename of the workflow step used for API operations"),
37
+ .describe("Codename of the workflow step. Must be unique across all workflows - usually prepended with the workflow codename."),
38
+ id: z
39
+ .guid()
40
+ .optional()
41
+ .readonly()
42
+ .describe("Read-only workflow step ID (useful to reference a step when updating its codename)"),
43
+ color: workflowStepColorSchema,
11
44
  transitions_to: z
12
- .array(z.guid())
13
- .describe("Array of workflow step IDs that this step can transition to")
14
- .optional(),
45
+ .array(transitionToSchema)
46
+ .min(1)
47
+ .describe("Array of step references this step can transition to."),
15
48
  role_ids: z
16
49
  .array(z.guid())
17
- .describe("Array of role IDs that have permissions for this workflow step")
18
- .optional(),
50
+ .min(1)
51
+ .describe("Array of role IDs that have permissions for this step."),
19
52
  });
20
- // Schema for the published step
21
- const publishedStepSchema = z.object({
22
- id: z
23
- .guid()
24
- .describe("The unique identifier of the published step in UUID format"),
25
- name: z
26
- .string()
27
- .describe("The name of the published step - typically 'Published'"),
28
- codename: z
29
- .string()
30
- .describe("The codename of the published step - typically 'published'"),
53
+ // Published step input schema
54
+ const publishedStepInputSchema = z.object({
31
55
  unpublish_role_ids: z
32
56
  .array(z.guid())
33
- .describe("Array of role IDs that can unpublish content from this step")
34
- .optional(),
57
+ .min(1)
58
+ .describe("Array of role IDs that can unpublish content."),
35
59
  create_new_version_role_ids: z
36
60
  .array(z.guid())
37
- .describe("Array of role IDs that can create new versions of content in this step")
38
- .optional(),
61
+ .min(1)
62
+ .describe("Array of role IDs that can create new versions."),
39
63
  });
40
- // Schema for the scheduled step
41
- const scheduledStepSchema = z.object({
42
- id: z
43
- .guid()
44
- .describe("The unique identifier of the scheduled step in UUID format"),
45
- name: z
46
- .string()
47
- .describe("The name of the scheduled step - typically 'Scheduled'"),
48
- codename: z
49
- .string()
50
- .describe("The codename of the scheduled step - typically 'scheduled'"),
51
- });
52
- // Schema for the archived step
53
- const archivedStepSchema = z.object({
54
- id: z
55
- .guid()
56
- .describe("The unique identifier of the archived step in UUID format"),
57
- name: z
58
- .string()
59
- .describe("The name of the archived step - typically 'Archived'"),
60
- codename: z
61
- .string()
62
- .describe("The codename of the archived step - typically 'archived'"),
64
+ // Archived step input schema
65
+ const archivedStepInputSchema = z.object({
63
66
  role_ids: z
64
67
  .array(z.guid())
65
- .describe("Array of role IDs that can unarchive content from this step")
66
- .optional(),
68
+ .min(1)
69
+ .describe("Array of role IDs that can restore archived content."),
67
70
  });
68
- // Schema for workflow scope
69
- const workflowScopeSchema = z.object({
71
+ // Workflow scope input schema
72
+ const workflowScopeInputSchema = z.object({
70
73
  content_types: z
71
- .array(z.object({
72
- id: z
73
- .guid()
74
- .describe("The unique identifier of the content type in UUID format"),
75
- }))
76
- .describe("Array of content types that this workflow applies to"),
74
+ .array(referenceObjectSchema)
75
+ .describe("Content types this workflow applies to"),
76
+ collections: z
77
+ .array(referenceObjectSchema)
78
+ .optional()
79
+ .describe("Collections this workflow applies to"),
77
80
  });
78
- // Main workflow schema
79
- export const workflowSchema = z.object({
80
- id: z.guid().describe("The unique identifier of the workflow in UUID format"),
81
- name: z.string().describe("The human-readable name of the workflow"),
81
+ // Main add/update workflow schema
82
+ export const workflowInputSchema = z.object({
83
+ name: z.string().describe("Human-readable name of the workflow"),
82
84
  codename: z
83
85
  .string()
84
- .describe("The codename of the workflow used for API operations"),
86
+ .optional()
87
+ .describe("Codename for API operations (auto-generated if omitted)"),
85
88
  scopes: z
86
- .array(workflowScopeSchema)
87
- .describe("Array of scopes defining which content types use this workflow"),
89
+ .array(workflowScopeInputSchema)
90
+ .describe("Array of scopes defining which combinations of content types and collections this workflow applies to. If both content types and collections are empty, the workflow can be used for any type of content in collection that isn't limited to any other workflow."),
88
91
  steps: z
89
- .array(workflowStepSchema)
90
- .describe("Array of custom workflow steps between draft and published states"),
91
- published_step: publishedStepSchema.describe("The published step configuration of the workflow"),
92
- scheduled_step: scheduledStepSchema.describe("The scheduled step configuration of the workflow"),
93
- archived_step: archivedStepSchema.describe("The archived step configuration of the workflow"),
92
+ .array(workflowStepInputSchema)
93
+ .describe("Array of custom workflow steps"),
94
+ published_step: publishedStepInputSchema.describe("Configuration for the published step"),
95
+ archived_step: archivedStepInputSchema.describe("Configuration for the archived step"),
94
96
  });
95
- // Schema for the list workflows response
96
- export const listWorkflowsResponseSchema = z
97
- .array(workflowSchema)
98
- .describe("Array of workflows in the project");