@kontent-ai/mcp-server 0.28.0 → 0.29.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 +3 -2
- package/build/server.js +4 -2
- package/build/tools/create-language-variant-mapi.js +44 -0
- package/build/tools/delete-workflow-mapi.js +1 -1
- package/build/tools/{upsert-language-variant-mapi.js → update-language-variant-mapi.js} +2 -2
- package/build/utils/extractUserIdFromToken.js +19 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -98,10 +98,11 @@ npx @kontent-ai/mcp-server@latest shttp
|
|
|
98
98
|
* **list-variants-type-mapi** – List Kontent.ai language variants by content type from Management API (paginated)
|
|
99
99
|
* **list-variants-components-type-mapi** – List Kontent.ai language variants containing components of a specific content type from Management API (paginated)
|
|
100
100
|
* **list-variants-space-mapi** – List Kontent.ai language variants by space from Management API (paginated)
|
|
101
|
-
* **add-content-item-mapi** – Add new Kontent.ai content item via Management API. This creates the content item structure but does not add content to language variants. Use
|
|
101
|
+
* **add-content-item-mapi** – Add new Kontent.ai content item via Management API. This creates the content item structure but does not add content to language variants. Use create-language-variant-mapi to add content to the item
|
|
102
102
|
* **update-content-item-mapi** – Update existing Kontent.ai content item by internal ID via Management API. The content item must already exist - this tool will not create new items
|
|
103
103
|
* **delete-content-item-mapi** – Delete Kontent.ai content item by internal ID from Management API
|
|
104
|
-
* **
|
|
104
|
+
* **create-language-variant-mapi** – Create Kontent.ai variant assigning current user as contributor. Element values must fulfill limitations and guidelines defined in content type
|
|
105
|
+
* **update-language-variant-mapi** – Update Kontent.ai language variant of a content item via Management API. Element values must fulfill limitations and guidelines defined in content type. Only provided elements will be modified
|
|
105
106
|
* **create-variant-version-mapi** – Create new version of Kontent.ai language variant via Management API. This operation creates a new version of an existing language variant, useful for content versioning and creating new drafts from published content
|
|
106
107
|
* **delete-language-variant-mapi** – Delete Kontent.ai language variant from Management API
|
|
107
108
|
* **filter-variants-mapi** – Filter Kontent.ai items with variants returning references (item ID + language ID). Use for exact keyword matching and finding specific terms in content. Supports full filtering capabilities (content types, workflow steps, taxonomies, spaces, collections, publishing states, etc.). Returns paginated results with continuation token for fetching subsequent pages. Use bulk-get-items-variants-mapi to retrieve full content for matched items
|
package/build/server.js
CHANGED
|
@@ -9,6 +9,7 @@ import { registerTool as registerAddTaxonomyGroupMapi } from "./tools/add-taxono
|
|
|
9
9
|
import { registerTool as registerAddWorkflowMapi } from "./tools/add-workflow-mapi.js";
|
|
10
10
|
import { registerTool as registerBulkGetItemsVariantsMapi } from "./tools/bulk-get-items-variants-mapi.js";
|
|
11
11
|
import { registerTool as registerChangeVariantWorkflowStepMapi } from "./tools/change-variant-workflow-step-mapi.js";
|
|
12
|
+
import { registerTool as registerCreateLanguageVariantMapi } from "./tools/create-language-variant-mapi.js";
|
|
12
13
|
import { registerTool as registerCreateVariantVersionMapi } from "./tools/create-variant-version-mapi.js";
|
|
13
14
|
import { registerTool as registerDeleteContentItemMapi } from "./tools/delete-content-item-mapi.js";
|
|
14
15
|
import { registerTool as registerDeleteContentTypeMapi } from "./tools/delete-content-type-mapi.js";
|
|
@@ -53,8 +54,8 @@ import { registerTool as registerSearchVariantsMapi } from "./tools/search-varia
|
|
|
53
54
|
import { registerTool as registerUnpublishVariantMapi } from "./tools/unpublish-variant-mapi.js";
|
|
54
55
|
import { registerTool as registerUpdateAssetMapi } from "./tools/update-asset-mapi.js";
|
|
55
56
|
import { registerTool as registerUpdateContentItemMapi } from "./tools/update-content-item-mapi.js";
|
|
57
|
+
import { registerTool as registerUpdateLanguageVariantMapi } from "./tools/update-language-variant-mapi.js";
|
|
56
58
|
import { registerTool as registerUpdateWorkflowMapi } from "./tools/update-workflow-mapi.js";
|
|
57
|
-
import { registerTool as registerUpsertLanguageVariantMapi } from "./tools/upsert-language-variant-mapi.js";
|
|
58
59
|
// Create server instance
|
|
59
60
|
export const createServer = () => {
|
|
60
61
|
const server = new McpServer({
|
|
@@ -104,7 +105,8 @@ export const createServer = () => {
|
|
|
104
105
|
registerAddContentItemMapi(server);
|
|
105
106
|
registerUpdateContentItemMapi(server);
|
|
106
107
|
registerDeleteContentItemMapi(server);
|
|
107
|
-
|
|
108
|
+
registerCreateLanguageVariantMapi(server);
|
|
109
|
+
registerUpdateLanguageVariantMapi(server);
|
|
108
110
|
registerCreateVariantVersionMapi(server);
|
|
109
111
|
registerDeleteLanguageVariantMapi(server);
|
|
110
112
|
registerListWorkflowsMapi(server);
|
|
@@ -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
|
+
export const registerTool = (server) => {
|
|
8
|
+
server.tool("create-language-variant-mapi", "Create Kontent.ai variant. Element values must fulfill limitations and guidelines defined in content type.", {
|
|
9
|
+
itemId: z.string().describe("Content item ID"),
|
|
10
|
+
languageId: z
|
|
11
|
+
.string()
|
|
12
|
+
.describe("Language variant ID (default: 00000000-0000-0000-0000-000000000000)"),
|
|
13
|
+
elements: z
|
|
14
|
+
.array(languageVariantElementSchema)
|
|
15
|
+
.describe("Content elements array"),
|
|
16
|
+
workflow_step_id: z.string().optional().describe("Workflow step ID"),
|
|
17
|
+
}, async ({ itemId, languageId, elements, workflow_step_id }, { authInfo: { token, clientId } = {} }) => {
|
|
18
|
+
const client = createMapiClient(clientId, token);
|
|
19
|
+
const data = {
|
|
20
|
+
elements,
|
|
21
|
+
};
|
|
22
|
+
if (workflow_step_id) {
|
|
23
|
+
data.workflow_step = { id: workflow_step_id };
|
|
24
|
+
}
|
|
25
|
+
if (token) {
|
|
26
|
+
const userId = extractUserIdFromToken(token);
|
|
27
|
+
if (userId) {
|
|
28
|
+
data.contributors = [{ id: userId }];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const response = await client
|
|
33
|
+
.upsertLanguageVariant()
|
|
34
|
+
.byItemId(itemId)
|
|
35
|
+
.byLanguageId(languageId)
|
|
36
|
+
.withData(() => data)
|
|
37
|
+
.toPromise();
|
|
38
|
+
return createMcpToolSuccessResponse(response.rawData);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
return handleMcpToolError(error, "Language Variant Create");
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
};
|
|
@@ -3,7 +3,7 @@ import { createMapiClient } from "../clients/kontentClients.js";
|
|
|
3
3
|
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
4
4
|
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
5
5
|
export const registerTool = (server) => {
|
|
6
|
-
server.tool("delete-workflow-mapi", {
|
|
6
|
+
server.tool("delete-workflow-mapi", "Delete Kontent.ai workflow", {
|
|
7
7
|
id: z.guid().describe("Workflow ID"),
|
|
8
8
|
}, async ({ id }, { authInfo: { token, clientId } = {} }) => {
|
|
9
9
|
const client = createMapiClient(clientId, token);
|
|
@@ -4,7 +4,7 @@ import { languageVariantElementSchema } from "../schemas/contentItemSchemas.js";
|
|
|
4
4
|
import { handleMcpToolError } from "../utils/errorHandler.js";
|
|
5
5
|
import { createMcpToolSuccessResponse } from "../utils/responseHelper.js";
|
|
6
6
|
export const registerTool = (server) => {
|
|
7
|
-
server.tool("
|
|
7
|
+
server.tool("update-language-variant-mapi", "Update Kontent.ai variant. Element values must fulfill limitations and guidelines defined in content type.", {
|
|
8
8
|
itemId: z.string().describe("Content item ID"),
|
|
9
9
|
languageId: z
|
|
10
10
|
.string()
|
|
@@ -31,7 +31,7 @@ export const registerTool = (server) => {
|
|
|
31
31
|
return createMcpToolSuccessResponse(response.rawData);
|
|
32
32
|
}
|
|
33
33
|
catch (error) {
|
|
34
|
-
return handleMcpToolError(error, "Language Variant
|
|
34
|
+
return handleMcpToolError(error, "Language Variant Update");
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts user ID from JWT token's uid claim.
|
|
3
|
+
* Decodes the JWT payload using base64url.
|
|
4
|
+
* @param token JWT token string
|
|
5
|
+
* @returns User ID string or null if decoding fails
|
|
6
|
+
*/
|
|
7
|
+
export const extractUserIdFromToken = (token) => {
|
|
8
|
+
try {
|
|
9
|
+
const parts = token.split(".");
|
|
10
|
+
if (parts.length !== 3) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const payload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf-8"));
|
|
14
|
+
return typeof payload.uid === "string" ? payload.uid : null;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kontent-ai/mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"mcpName": "io.github.kontent-ai/mcp-server",
|
|
6
6
|
"repository": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"author": "Jiri Lojda",
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@kontent-ai/management-sdk": "^8.3.
|
|
33
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
32
|
+
"@kontent-ai/management-sdk": "^8.3.1",
|
|
33
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
34
34
|
"applicationinsights": "^2.9.8",
|
|
35
35
|
"dotenv": "^17.2.3",
|
|
36
36
|
"express": "^5.2.1",
|