@kontent-ai/mcp-server 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -103,6 +103,12 @@ npx @kontent-ai/mcp-server@latest sse
103
103
 
104
104
  * **list-workflows-mapi** – List all workflows in the environment with their lifecycle stages and transitions
105
105
  * **change-variant-workflow-step-mapi** – Change the workflow step of a language variant (move content through workflow stages)
106
+ * **publish-variant-mapi** – Publish or schedule a language variant for publication. Supports immediate publishing (happens right now) or scheduled publishing at a specific future date and time with optional timezone specification
107
+ * **unpublish-variant-mapi** – Unpublish or schedule unpublishing of a language variant. Supports immediate unpublishing (removes content from Delivery API right now) or scheduled unpublishing at a specific future date and time with optional timezone specification
108
+
109
+ ### Utility
110
+
111
+ * **get-current-datetime** – Get the current date and time in UTC (ISO-8601 format)
106
112
 
107
113
  ## ⚙️ Configuration
108
114
 
package/build/server.js CHANGED
@@ -9,6 +9,7 @@ import { registerTool as registerDeleteContentItemMapi } from "./tools/delete-co
9
9
  import { registerTool as registerDeleteLanguageVariantMapi } from "./tools/delete-language-variant-mapi.js";
10
10
  import { registerTool as registerFilterVariantsMapi } from "./tools/filter-variants-mapi.js";
11
11
  import { registerTool as registerGetAssetMapi } from "./tools/get-asset-mapi.js";
12
+ import { registerTool as registerGetCurrentDatetime } from "./tools/get-current-datetime.js";
12
13
  import { registerTool as registerGetInitialContext } from "./tools/get-initial-context.js";
13
14
  import { registerTool as registerGetItemDapi } from "./tools/get-item-dapi.js";
14
15
  import { registerTool as registerGetItemMapi } from "./tools/get-item-mapi.js";
@@ -22,6 +23,8 @@ import { registerTool as registerListContentTypesMapi } from "./tools/list-conte
22
23
  import { registerTool as registerListLanguagesMapi } from "./tools/list-languages-mapi.js";
23
24
  import { registerTool as registerListTaxonomyGroupsMapi } from "./tools/list-taxonomy-groups-mapi.js";
24
25
  import { registerTool as registerListWorkflowsMapi } from "./tools/list-workflows-mapi.js";
26
+ import { registerTool as registerPublishVariantMapi } from "./tools/publish-variant-mapi.js";
27
+ import { registerTool as registerUnpublishVariantMapi } from "./tools/unpublish-variant-mapi.js";
25
28
  import { registerTool as registerUpdateContentItemMapi } from "./tools/update-content-item-mapi.js";
26
29
  import { registerTool as registerUpsertLanguageVariantMapi } from "./tools/upsert-language-variant-mapi.js";
27
30
  // Create server instance
@@ -59,5 +62,8 @@ export const createServer = () => {
59
62
  registerListWorkflowsMapi(server);
60
63
  registerChangeVariantWorkflowStepMapi(server);
61
64
  registerFilterVariantsMapi(server);
65
+ registerPublishVariantMapi(server);
66
+ registerUnpublishVariantMapi(server);
67
+ registerGetCurrentDatetime(server);
62
68
  return { server };
63
69
  };
@@ -98,6 +98,10 @@ ALL FOUR elements must be included in language variant using their internal IDs:
98
98
 
99
99
  **Failure to provide the workflowId parameter will result in workflow step change failures.**
100
100
 
101
+ ### Current date and time
102
+
103
+ **CRITICAL**: Always use the **get-current-datetime tool** to obtain the current UTC time. Never assume the current time.
104
+
101
105
  ## Essential Concepts
102
106
 
103
107
  **Taxonomies** provide hierarchical content categorization, allowing you to organize and tag content systematically.
@@ -0,0 +1,9 @@
1
+ import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
2
+ export const registerTool = (server) => {
3
+ server.tool("get-current-datetime", "Get the current date and time in UTC (ISO-8601 format)", {}, async () => {
4
+ const now = new Date();
5
+ return createMcpToolSuccessResponse({
6
+ datetime: now.toISOString(),
7
+ });
8
+ });
9
+ };
@@ -0,0 +1,78 @@
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
+ export const registerTool = (server) => {
6
+ server.tool("publish-variant-mapi", "Publish or schedule a language variant of a content item in Kontent.ai. This operation can either immediately publish the variant (publishing happens right now) or schedule it for publication at a specific future date and time. For immediate publishing: the variant is published immediately and becomes available through the Delivery API. For scheduled publishing: the variant moves to a 'Scheduled' workflow state and will automatically transition to 'Published' at the specified time. The variant must be in a valid state with all required fields filled and validation rules satisfied. A variant can only be published if a transition is defined between the variant's current workflow step and the Published workflow step.", {
7
+ itemId: z
8
+ .string()
9
+ .uuid()
10
+ .describe("Internal ID (UUID) of the content item whose language variant you want to publish or schedule. This identifies the content item container that holds all language variants."),
11
+ languageId: z
12
+ .string()
13
+ .uuid()
14
+ .describe("Internal ID (UUID) of the language variant to publish or schedule. Use '00000000-0000-0000-0000-000000000000' for the default language. Each language in your project has a unique ID that identifies the specific variant."),
15
+ scheduledTo: z
16
+ .string()
17
+ .datetime()
18
+ .optional()
19
+ .describe("ISO 8601 formatted date and time when the publish action should occur (e.g., '2024-12-25T10:00:00Z' for UTC or '2024-12-25T10:00:00+02:00' for specific timezone). If not provided, the variant will be published immediately. If provided, must be a future date/time. The actual execution may have up to 5 minutes delay from the specified time."),
20
+ displayTimezone: z
21
+ .string()
22
+ .optional()
23
+ .describe("The timezone identifier for displaying the scheduled time in the Kontent.ai UI (e.g., 'America/New_York', 'Europe/London', 'UTC'). This parameter is used for scheduled publishing to specify the timezone context for the scheduled_to parameter. If not provided, the system will use the default timezone. This helps content creators understand when content will be published in their local context."),
24
+ }, async ({ itemId, languageId, scheduledTo, displayTimezone }) => {
25
+ const client = createMapiClient();
26
+ try {
27
+ // Validate that displayTimezone can only be used with scheduledTo
28
+ if (displayTimezone && !scheduledTo) {
29
+ throw new Error("The 'displayTimezone' parameter can only be used in combination with 'scheduledTo' parameter for scheduled publishing.");
30
+ }
31
+ let action;
32
+ let message;
33
+ if (scheduledTo) {
34
+ // Scheduled publishing
35
+ const requestData = {
36
+ scheduled_to: scheduledTo,
37
+ };
38
+ // Add display_timezone if provided
39
+ if (displayTimezone) {
40
+ requestData.display_timezone = displayTimezone;
41
+ }
42
+ await client
43
+ .publishLanguageVariant()
44
+ .byItemId(itemId)
45
+ .byLanguageId(languageId)
46
+ .withData(requestData)
47
+ .toPromise();
48
+ action = "scheduled";
49
+ message = `Successfully scheduled language variant '${languageId}' for content item '${itemId}' to be published at '${scheduledTo}'${displayTimezone ? ` (timezone: ${displayTimezone})` : ""}.`;
50
+ }
51
+ else {
52
+ // Immediate publishing
53
+ await client
54
+ .publishLanguageVariant()
55
+ .byItemId(itemId)
56
+ .byLanguageId(languageId)
57
+ .withoutData()
58
+ .toPromise();
59
+ action = "published";
60
+ message = `Successfully published language variant '${languageId}' for content item '${itemId}'. The content is now live and available through Delivery API.`;
61
+ }
62
+ return createMcpToolSuccessResponse({
63
+ message,
64
+ result: {
65
+ itemId,
66
+ languageId,
67
+ scheduledTo: scheduledTo || null,
68
+ displayTimezone: displayTimezone || null,
69
+ action,
70
+ timestamp: new Date().toISOString(),
71
+ },
72
+ });
73
+ }
74
+ catch (error) {
75
+ return handleMcpToolError(error, "Publish/Schedule Language Variant");
76
+ }
77
+ });
78
+ };
@@ -0,0 +1,78 @@
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
+ export const registerTool = (server) => {
6
+ server.tool("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. For immediate unpublishing: the variant is unpublished right away and moves to the 'Archived' workflow step, becoming unavailable through the Delivery API. For scheduled unpublishing: the variant remains published but is scheduled to be automatically unpublished at the specified time. The variant must currently be in the 'Published' state for this operation to succeed.", {
7
+ itemId: z
8
+ .string()
9
+ .uuid()
10
+ .describe("Internal ID (UUID) of the content item whose language variant you want to unpublish or schedule for unpublishing. This identifies the content item container that holds all language variants."),
11
+ languageId: z
12
+ .string()
13
+ .uuid()
14
+ .describe("Internal ID (UUID) of the language variant to unpublish or schedule for unpublishing. Use '00000000-0000-0000-0000-000000000000' for the default language. Each language in your project has a unique ID that identifies the specific variant."),
15
+ scheduledTo: z
16
+ .string()
17
+ .datetime()
18
+ .optional()
19
+ .describe("ISO 8601 formatted date and time when the unpublish action should occur (e.g., '2024-12-25T10:00:00Z' for UTC or '2024-12-25T10:00:00+02:00' for specific timezone). If not provided, the variant will be unpublished immediately. If provided, must be a future date/time. The actual execution may have up to 5 minutes delay from the specified time. When unpublished, the content will no longer be available through the Delivery API."),
20
+ displayTimezone: z
21
+ .string()
22
+ .optional()
23
+ .describe("The timezone identifier for displaying the scheduled time in the Kontent.ai UI (e.g., 'America/New_York', 'Europe/London', 'UTC'). This parameter is used for scheduled unpublishing to specify the timezone context for the scheduled_to parameter. If not provided, the system will use the default timezone. This helps content creators understand when content will be unpublished in their local context."),
24
+ }, async ({ itemId, languageId, scheduledTo, displayTimezone }) => {
25
+ const client = createMapiClient();
26
+ try {
27
+ // Validate that displayTimezone can only be used with scheduledTo
28
+ if (displayTimezone && !scheduledTo) {
29
+ throw new Error("The 'displayTimezone' parameter can only be used in combination with 'scheduledTo' parameter for scheduled unpublishing.");
30
+ }
31
+ let action;
32
+ let message;
33
+ if (scheduledTo) {
34
+ // Scheduled unpublishing
35
+ const requestData = {
36
+ scheduled_to: scheduledTo,
37
+ };
38
+ // Add display_timezone if provided
39
+ if (displayTimezone) {
40
+ requestData.display_timezone = displayTimezone;
41
+ }
42
+ await client
43
+ .unpublishLanguageVariant()
44
+ .byItemId(itemId)
45
+ .byLanguageId(languageId)
46
+ .withData(requestData)
47
+ .toPromise();
48
+ action = "scheduled for unpublishing";
49
+ message = `Successfully scheduled language variant '${languageId}' for content item '${itemId}' to be unpublished at '${scheduledTo}'${displayTimezone ? ` (timezone: ${displayTimezone})` : ""}. The content will be removed from Delivery API at the scheduled time.`;
50
+ }
51
+ else {
52
+ // Immediate unpublishing
53
+ await client
54
+ .unpublishLanguageVariant()
55
+ .byItemId(itemId)
56
+ .byLanguageId(languageId)
57
+ .withoutData()
58
+ .toPromise();
59
+ action = "unpublished";
60
+ message = `Successfully unpublished language variant '${languageId}' for content item '${itemId}'. The content has been moved to Archived and is no longer available through Delivery API.`;
61
+ }
62
+ return createMcpToolSuccessResponse({
63
+ message,
64
+ result: {
65
+ itemId,
66
+ languageId,
67
+ scheduledTo: scheduledTo || null,
68
+ displayTimezone: displayTimezone || null,
69
+ action,
70
+ timestamp: new Date().toISOString(),
71
+ },
72
+ });
73
+ }
74
+ catch (error) {
75
+ return handleMcpToolError(error, "Unpublish/Schedule Unpublishing Language Variant");
76
+ }
77
+ });
78
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kontent-ai/mcp-server",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "rimraf build && tsc",