@upassist/neos-mcp 2.3.0 → 2.5.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/CHANGELOG.md +21 -0
- package/README.md +16 -2
- package/dist/index.js +123 -43
- package/package.json +3 -3
- package/src/dimensions.ts +60 -0
- package/src/server.ts +2 -0
- package/src/tools/createContentNode.ts +6 -3
- package/src/tools/createDocumentNode.ts +6 -3
- package/src/tools/createNodeVariant.ts +39 -0
- package/src/tools/deleteNode.ts +8 -3
- package/src/tools/entityCrud.ts +1 -1
- package/src/tools/getDocumentProperties.ts +6 -4
- package/src/tools/getPageContent.ts +6 -4
- package/src/tools/getPreviewUrl.ts +5 -3
- package/src/tools/getSiteContext.ts +4 -2
- package/src/tools/listAssets.ts +1 -1
- package/src/tools/listNodeTypes.ts +4 -2
- package/src/tools/listPages.ts +6 -4
- package/src/tools/listPendingChanges.ts +5 -3
- package/src/tools/moveNode.ts +5 -2
- package/src/tools/publishChanges.ts +7 -4
- package/src/tools/updateNodeProperty.ts +11 -4
- package/src/tools/uploadAsset.ts +1 -1
- package/src/types.ts +14 -0
- package/test/dimensions.test.ts +210 -0
- package/test/referenceValues.test.ts +85 -0
package/src/tools/deleteNode.ts
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
2
|
+
import { z } from 'zod/v3';
|
|
3
3
|
import { callBridge, nodeIdParam } from '../bridge.js';
|
|
4
|
+
import { dimensionsSchema, dimensionsParam } from '../dimensions.js';
|
|
4
5
|
|
|
5
6
|
export function registerDeleteNode(server: McpServer): void {
|
|
6
7
|
server.tool(
|
|
7
8
|
'neos_delete_node',
|
|
8
|
-
'Mark a content node as removed in the mcp workspace. The deletion is staged and will only go live after neos_publish_changes is called.'
|
|
9
|
+
'Mark a content node as removed in the mcp workspace. The deletion is staged and will only go live after neos_publish_changes is called. ' +
|
|
10
|
+
'With "dimensions" only the variant in those dimensions is removed, the variants in other dimensions stay. ' +
|
|
11
|
+
'Neos 8 refuses a node that is only shown through a fallback; Neos 9 then removes the page from the requested dimension (and its specializations) only, the page stays in the dimension it is stored in.',
|
|
9
12
|
{
|
|
10
13
|
node_id: z.string().describe('Node identifier — use nodeAggregateId (Neos 9) or contextPath/path (Neos 8)'),
|
|
11
14
|
workspace: z.string().default('mcp').describe('Workspace to operate in'),
|
|
15
|
+
dimensions: dimensionsSchema(),
|
|
12
16
|
},
|
|
13
|
-
async ({ node_id, workspace }) => {
|
|
17
|
+
async ({ node_id, workspace, dimensions }) => {
|
|
14
18
|
const data = await callBridge('deleteNode', 'POST', {
|
|
15
19
|
...await nodeIdParam('contextPath', node_id),
|
|
16
20
|
workspace,
|
|
21
|
+
...await dimensionsParam(dimensions),
|
|
17
22
|
});
|
|
18
23
|
return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
|
|
19
24
|
}
|
package/src/tools/entityCrud.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
2
|
+
import { z } from 'zod/v3';
|
|
3
3
|
import { callBridge, nodeIdParam } from '../bridge.js';
|
|
4
|
+
import { dimensionsSchema, dimensionsParam } from '../dimensions.js';
|
|
4
5
|
|
|
5
6
|
export function registerGetDocumentProperties(server: McpServer): void {
|
|
6
7
|
server.tool(
|
|
7
8
|
'neos_get_document_properties',
|
|
8
|
-
'Get all properties of a document node (page) without its content nodes. Use this for SEO fields, meta data, and other document-level properties.',
|
|
9
|
+
'Get all properties of a document node (page) without its content nodes. Use this for SEO fields, meta data, and other document-level properties. Neos 9: the document\'s "references" (nodeAggregateIds of the referenced nodes) are listed next to "properties".',
|
|
9
10
|
{
|
|
10
11
|
node_id: z.string().describe('Node identifier — use the nodeAggregateId (Neos 9) or path (Neos 8) from neos_get_site_context / neos_list_pages'),
|
|
11
12
|
workspace: z.string().default('mcp').describe('Workspace name. Use "live" for published content, "mcp" for staged changes.'),
|
|
13
|
+
dimensions: dimensionsSchema(),
|
|
12
14
|
},
|
|
13
|
-
async ({ node_id, workspace }) => {
|
|
14
|
-
const data = await callBridge('getDocumentProperties', 'GET', { ...await nodeIdParam('nodePath', node_id), workspace });
|
|
15
|
+
async ({ node_id, workspace, dimensions }) => {
|
|
16
|
+
const data = await callBridge('getDocumentProperties', 'GET', { ...await nodeIdParam('nodePath', node_id), workspace, ...await dimensionsParam(dimensions) });
|
|
15
17
|
return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
|
|
16
18
|
}
|
|
17
19
|
);
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
2
|
+
import { z } from 'zod/v3';
|
|
3
3
|
import { callBridge, nodeIdParam } from '../bridge.js';
|
|
4
|
+
import { dimensionsSchema, dimensionsParam } from '../dimensions.js';
|
|
4
5
|
|
|
5
6
|
export function registerGetPageContent(server: McpServer): void {
|
|
6
7
|
server.tool(
|
|
7
8
|
'neos_get_page_content',
|
|
8
|
-
'Get all content nodes on a specific page with their properties. Call neos_get_site_context first if you have not already done so this session.',
|
|
9
|
+
'Get all content nodes on a specific page with their properties. Neos 9: each node also lists its "references" (nodeAggregateIds of the referenced nodes, in the format neos_update_node_property accepts). Call neos_get_site_context first if you have not already done so this session.',
|
|
9
10
|
{
|
|
10
11
|
node_id: z.string().describe('Node identifier — use the nodeAggregateId (Neos 9) or path (Neos 8) from neos_get_site_context / neos_list_pages'),
|
|
11
12
|
workspace: z.string().default('mcp').describe('Workspace name'),
|
|
13
|
+
dimensions: dimensionsSchema(),
|
|
12
14
|
},
|
|
13
|
-
async ({ node_id, workspace }) => {
|
|
14
|
-
const data = await callBridge('getPageContent', 'GET', { ...await nodeIdParam('nodePath', node_id), workspace });
|
|
15
|
+
async ({ node_id, workspace, dimensions }) => {
|
|
16
|
+
const data = await callBridge('getPageContent', 'GET', { ...await nodeIdParam('nodePath', node_id), workspace, ...await dimensionsParam(dimensions) });
|
|
15
17
|
return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
|
|
16
18
|
}
|
|
17
19
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
2
|
+
import { z } from 'zod/v3';
|
|
3
3
|
import { callBridge, nodeIdParam } from '../bridge.js';
|
|
4
|
+
import { dimensionsSchema, dimensionsParam } from '../dimensions.js';
|
|
4
5
|
|
|
5
6
|
export function registerGetPreviewUrl(server: McpServer): void {
|
|
6
7
|
server.tool(
|
|
@@ -9,9 +10,10 @@ export function registerGetPreviewUrl(server: McpServer): void {
|
|
|
9
10
|
{
|
|
10
11
|
node_id: z.string().describe('Node identifier — use the nodeAggregateId (Neos 9) or path (Neos 8) from neos_list_pages'),
|
|
11
12
|
workspace: z.string().default('mcp').describe('Workspace to preview'),
|
|
13
|
+
dimensions: dimensionsSchema('The preview URL shows the page in these dimensions, including the URL prefix the site uses for them (e.g. /nl).'),
|
|
12
14
|
},
|
|
13
|
-
async ({ node_id, workspace }) => {
|
|
14
|
-
const data = await callBridge('getPreviewUrl', 'GET', { ...await nodeIdParam('nodePath', node_id), workspace });
|
|
15
|
+
async ({ node_id, workspace, dimensions }) => {
|
|
16
|
+
const data = await callBridge('getPreviewUrl', 'GET', { ...await nodeIdParam('nodePath', node_id), workspace, ...await dimensionsParam(dimensions) });
|
|
15
17
|
return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
|
|
16
18
|
}
|
|
17
19
|
);
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
2
|
+
import { z } from 'zod/v3';
|
|
3
3
|
import { callBridge, setApiVersion } from '../bridge.js';
|
|
4
4
|
|
|
5
5
|
export function registerGetSiteContext(server: McpServer): void {
|
|
6
6
|
server.tool(
|
|
7
7
|
'neos_get_site_context',
|
|
8
8
|
'Get the site context: site name, available content NodeTypes with their properties, current page tree, and editorial workflow instructions. Always call this first at the start of any Neos content editing session. ' +
|
|
9
|
-
'On a multi-site instance "sites" lists all sites; pass "site" to get the context of another site than the default one.'
|
|
9
|
+
'On a multi-site instance "sites" lists all sites; pass "site" to get the context of another site than the default one. ' +
|
|
10
|
+
'Neos 9: each node type also lists its "references" to other nodes, see neos_list_node_types. ' +
|
|
11
|
+
'The "dimensions" in the result list the content dimensions (for example language or country) with their default and fallback chains; pass "dimensions" to the other tools to work in one of them.',
|
|
10
12
|
{
|
|
11
13
|
site: z.string().optional().describe('Site node name (see neos_list_sites). Defaults to the default site of the instance.'),
|
|
12
14
|
},
|
package/src/tools/listAssets.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
2
|
+
import { z } from 'zod/v3';
|
|
3
3
|
import { callBridge } from '../bridge.js';
|
|
4
4
|
|
|
5
5
|
export function registerListNodeTypes(server: McpServer): void {
|
|
6
6
|
server.tool(
|
|
7
7
|
'neos_list_node_types',
|
|
8
|
-
'List available content node types with their property schemas. Useful to know which types and properties are available before creating or updating nodes.'
|
|
8
|
+
'List available content node types with their property schemas. Useful to know which types and properties are available before creating or updating nodes. ' +
|
|
9
|
+
'Neos 9: references to other nodes (for example selected brands or a contact person) are listed separately under "references", each with "type" ("reference" for one node, "references" for several), "label" and "targetNodeTypes" (the node types that can be referenced, null if any node can). ' +
|
|
10
|
+
'In Neos 8 references are regular properties of type "reference"/"references".',
|
|
9
11
|
{
|
|
10
12
|
filter: z.enum(['content', 'document', 'all']).default('content').describe(
|
|
11
13
|
'"content" for content elements, "document" for page types, "all" for everything'
|
package/src/tools/listPages.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
2
|
+
import { z } from 'zod/v3';
|
|
3
3
|
import { callBridge } from '../bridge.js';
|
|
4
|
+
import { dimensionsSchema, dimensionsParam } from '../dimensions.js';
|
|
4
5
|
|
|
5
6
|
export function registerListPages(server: McpServer): void {
|
|
6
7
|
server.tool(
|
|
7
8
|
'neos_list_pages',
|
|
8
|
-
'List all document nodes (pages) in the Neos CMS site as a flat tree with paths and titles.',
|
|
9
|
+
'List all document nodes (pages) in the Neos CMS site as a flat tree with paths and titles. Neos 9: each page also lists its "references" (nodeAggregateIds of the referenced nodes).',
|
|
9
10
|
{
|
|
10
11
|
workspace: z.string().default('mcp').describe('Workspace name. Use "live" for published content, "mcp" for staged changes.'),
|
|
11
12
|
site: z.string().optional().describe('Site node name (see neos_list_sites). Defaults to the default site of the instance.'),
|
|
13
|
+
dimensions: dimensionsSchema('Pages that only exist in another dimension and are shown through a fallback have "fallback": true.'),
|
|
12
14
|
},
|
|
13
|
-
async ({ workspace, site }) => {
|
|
14
|
-
const data = await callBridge('listPages', 'GET', { workspace, site });
|
|
15
|
+
async ({ workspace, site, dimensions }) => {
|
|
16
|
+
const data = await callBridge('listPages', 'GET', { workspace, site, ...await dimensionsParam(dimensions) });
|
|
15
17
|
return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
|
|
16
18
|
}
|
|
17
19
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
2
|
+
import { z } from 'zod/v3';
|
|
3
3
|
import { callBridge } from '../bridge.js';
|
|
4
|
+
import { dimensionsSchema, dimensionsParam } from '../dimensions.js';
|
|
4
5
|
|
|
5
6
|
export function registerListPendingChanges(server: McpServer): void {
|
|
6
7
|
server.tool(
|
|
@@ -9,9 +10,10 @@ export function registerListPendingChanges(server: McpServer): void {
|
|
|
9
10
|
{
|
|
10
11
|
workspace: z.string().default('mcp').describe('Workspace name to check for pending changes'),
|
|
11
12
|
site: z.string().optional().describe('Only list changes of this site (site node name, see neos_list_sites). Without it, changes of all sites are listed, each with its "site".'),
|
|
13
|
+
dimensions: dimensionsSchema('Only list the changes made in these dimensions. Without it, the changes of all dimensions are listed, each with its "dimensions".'),
|
|
12
14
|
},
|
|
13
|
-
async ({ workspace, site }) => {
|
|
14
|
-
const data = await callBridge('listPendingChanges', 'GET', { workspace, site });
|
|
15
|
+
async ({ workspace, site, dimensions }) => {
|
|
16
|
+
const data = await callBridge('listPendingChanges', 'GET', { workspace, site, ...await dimensionsParam(dimensions) });
|
|
15
17
|
return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
|
|
16
18
|
}
|
|
17
19
|
);
|
package/src/tools/moveNode.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
2
|
+
import { z } from 'zod/v3';
|
|
3
3
|
import { callBridge, nodeIdParam } from '../bridge.js';
|
|
4
|
+
import { dimensionsSchema, dimensionsParam } from '../dimensions.js';
|
|
4
5
|
|
|
5
6
|
export function registerMoveNode(server: McpServer): void {
|
|
6
7
|
server.tool(
|
|
@@ -22,14 +23,16 @@ export function registerMoveNode(server: McpServer): void {
|
|
|
22
23
|
'New parent node identifier — move into this parent (as last child)'
|
|
23
24
|
),
|
|
24
25
|
workspace: z.string().default('mcp').describe('Draft workspace name'),
|
|
26
|
+
dimensions: dimensionsSchema(),
|
|
25
27
|
},
|
|
26
|
-
async ({ node_id, insert_before, insert_after, new_parent_id, workspace }) => {
|
|
28
|
+
async ({ node_id, insert_before, insert_after, new_parent_id, workspace, dimensions }) => {
|
|
27
29
|
const data = await callBridge('moveNode', 'POST', {
|
|
28
30
|
...await nodeIdParam('contextPath', node_id),
|
|
29
31
|
...await nodeIdParam('newParentPath', new_parent_id ?? ''),
|
|
30
32
|
insertBefore: insert_before ?? '',
|
|
31
33
|
insertAfter: insert_after ?? '',
|
|
32
34
|
workspace,
|
|
35
|
+
...await dimensionsParam(dimensions),
|
|
33
36
|
});
|
|
34
37
|
return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
|
|
35
38
|
}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
2
|
+
import { z } from 'zod/v3';
|
|
3
3
|
import { callBridge } from '../bridge.js';
|
|
4
|
+
import { dimensionsSchema, dimensionsParam } from '../dimensions.js';
|
|
4
5
|
|
|
5
6
|
export function registerPublishChanges(server: McpServer): void {
|
|
6
7
|
server.tool(
|
|
7
8
|
'neos_publish_changes',
|
|
8
9
|
'Publish all pending changes from the mcp workspace to live. This is irreversible. Always call neos_list_pending_changes first and confirm with the user before publishing. ' +
|
|
9
|
-
'On a multi-site instance, pass "site" to publish only the changes of that site; without it, the changes of all sites go live.'
|
|
10
|
+
'On a multi-site instance, pass "site" to publish only the changes of that site; without it, the changes of all sites go live. ' +
|
|
11
|
+
'Without "dimensions" the changes of all content dimensions go live; with "dimensions" only the changes made in those dimensions (on Neos 9 a node that also changed in another dimension is skipped and listed in skippedNodes, because Neos publishes whole nodes).',
|
|
10
12
|
{
|
|
11
13
|
workspace: z.string().default('mcp').describe('Workspace to publish from'),
|
|
12
14
|
site: z.string().optional().describe('Only publish changes of this site (site node name, see neos_list_sites). Without it, all pending changes of all sites are published.'),
|
|
15
|
+
dimensions: dimensionsSchema('Only publish the changes made in these dimensions. Without it, the changes of all dimensions go live.'),
|
|
13
16
|
},
|
|
14
|
-
async ({ workspace, site }) => {
|
|
17
|
+
async ({ workspace, site, dimensions }) => {
|
|
15
18
|
if (site) {
|
|
16
19
|
// A bridge without multi-site support ignores "site" and would publish the changes of
|
|
17
20
|
// all sites. Publishing cannot be undone, so only go ahead when the bridge knows sites.
|
|
@@ -26,7 +29,7 @@ export function registerPublishChanges(server: McpServer): void {
|
|
|
26
29
|
);
|
|
27
30
|
}
|
|
28
31
|
}
|
|
29
|
-
const data = await callBridge('publishChanges', 'POST', { workspace, site });
|
|
32
|
+
const data = await callBridge('publishChanges', 'POST', { workspace, site, ...await dimensionsParam(dimensions) });
|
|
30
33
|
return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
|
|
31
34
|
}
|
|
32
35
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
2
|
+
import { z } from 'zod/v3';
|
|
3
3
|
import { callBridge, nodeIdParam } from '../bridge.js';
|
|
4
|
+
import { dimensionsSchema, dimensionsParam } from '../dimensions.js';
|
|
4
5
|
|
|
5
6
|
export function registerUpdateNodeProperty(server: McpServer): void {
|
|
6
7
|
server.tool(
|
|
@@ -10,21 +11,27 @@ export function registerUpdateNodeProperty(server: McpServer): void {
|
|
|
10
11
|
node_id: z.string().describe(
|
|
11
12
|
'Node identifier — use nodeAggregateId (Neos 9) or contextPath/path (Neos 8)'
|
|
12
13
|
),
|
|
13
|
-
property: z.string().describe('Property name to update'),
|
|
14
|
+
property: z.string().describe('Property or reference name to update'),
|
|
14
15
|
value: z.unknown().describe(
|
|
15
16
|
'New property value (string, number, boolean, or object). Image/asset properties: the asset identifier. ' +
|
|
16
17
|
'Link properties (type Neos\\Neos\\Domain\\Link\\Link): a URI string such as "node://<nodeAggregateId>", "asset://<id>" or "https://…", ' +
|
|
17
18
|
'or an object { href, title?, target?, rel?, download? }; an empty string clears the link. ' +
|
|
18
|
-
'A node:// target must exist in the workspace (check with neos_list_pages), otherwise the write is rejected.'
|
|
19
|
+
'A node:// target must exist in the workspace (check with neos_list_pages), otherwise the write is rejected. ' +
|
|
20
|
+
'References (Neos 9: listed under "references" of the node type in neos_list_node_types, not under "properties"): ' +
|
|
21
|
+
'a nodeAggregateId for type "reference", an array of nodeAggregateIds for type "references" (the complete new list in the desired order, it replaces the old one); ' +
|
|
22
|
+
'an empty string or empty array clears them. Every target must exist in the workspace and be of one of the reference\'s "targetNodeTypes" (if set), otherwise the write is rejected. ' +
|
|
23
|
+
'The current targets are shown under "references" in neos_get_page_content / neos_get_document_properties.'
|
|
19
24
|
),
|
|
20
25
|
workspace: z.string().default('mcp').describe('Workspace to write to'),
|
|
26
|
+
dimensions: dimensionsSchema('The property is changed in exactly these dimensions; a node that only exists in another dimension is refused, create a variant first with neos_create_node_variant.'),
|
|
21
27
|
},
|
|
22
|
-
async ({ node_id, property, value, workspace }) => {
|
|
28
|
+
async ({ node_id, property, value, workspace, dimensions }) => {
|
|
23
29
|
const data = await callBridge('updateNodeProperty', 'POST', {
|
|
24
30
|
...await nodeIdParam('contextPath', node_id),
|
|
25
31
|
property,
|
|
26
32
|
value,
|
|
27
33
|
workspace,
|
|
34
|
+
...await dimensionsParam(dimensions),
|
|
28
35
|
});
|
|
29
36
|
return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
|
|
30
37
|
}
|
package/src/tools/uploadAsset.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import { basename } from 'node:path';
|
|
3
3
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
|
-
import { z } from 'zod';
|
|
4
|
+
import { z } from 'zod/v3';
|
|
5
5
|
import { callBridge } from '../bridge.js';
|
|
6
6
|
|
|
7
7
|
async function loadSource(
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export type NodeReferences = Record<string, string | string[] | null> | [];
|
|
2
|
+
|
|
1
3
|
export interface PageNode {
|
|
2
4
|
// v2 (Neos 9) primary identifier
|
|
3
5
|
nodeAggregateId?: string;
|
|
@@ -12,6 +14,8 @@ export interface PageNode {
|
|
|
12
14
|
hidden: boolean;
|
|
13
15
|
depth: number;
|
|
14
16
|
properties?: Record<string, unknown>;
|
|
17
|
+
/** Keyed by reference name; the bridge sends an empty list ([]) instead of {} when the node type has none. */
|
|
18
|
+
references?: NodeReferences;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
export interface ContentNode {
|
|
@@ -22,6 +26,8 @@ export interface ContentNode {
|
|
|
22
26
|
nodeType: string;
|
|
23
27
|
name: string;
|
|
24
28
|
properties: Record<string, unknown>;
|
|
29
|
+
/** Keyed by reference name; the bridge sends an empty list ([]) instead of {} when the node type has none. */
|
|
30
|
+
references?: NodeReferences;
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
export interface NodeTypeProperty {
|
|
@@ -30,11 +36,19 @@ export interface NodeTypeProperty {
|
|
|
30
36
|
label: string;
|
|
31
37
|
}
|
|
32
38
|
|
|
39
|
+
export interface NodeTypeReference {
|
|
40
|
+
type: 'reference' | 'references';
|
|
41
|
+
label: string;
|
|
42
|
+
targetNodeTypes: string[] | null;
|
|
43
|
+
}
|
|
44
|
+
|
|
33
45
|
export interface NodeTypeSchema {
|
|
34
46
|
name: string;
|
|
35
47
|
isContent: boolean;
|
|
36
48
|
isDocument: boolean;
|
|
37
49
|
properties: Record<string, NodeTypeProperty>;
|
|
50
|
+
/** An empty list ([]) instead of {} when the node type has none. */
|
|
51
|
+
references?: Record<string, NodeTypeReference> | [];
|
|
38
52
|
}
|
|
39
53
|
|
|
40
54
|
export interface PendingChange {
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { test, before, after, beforeEach } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
|
|
4
|
+
import './support/env.js';
|
|
5
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
6
|
+
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
|
|
7
|
+
import { createServer } from '../src/server.js';
|
|
8
|
+
import { setApiVersion } from '../src/bridge.js';
|
|
9
|
+
import { resetDimensionSupport } from '../src/dimensions.js';
|
|
10
|
+
|
|
11
|
+
type Call = { url: URL; method: string; body: any };
|
|
12
|
+
|
|
13
|
+
const realFetch = globalThis.fetch;
|
|
14
|
+
let calls: Call[] = [];
|
|
15
|
+
let client: Client;
|
|
16
|
+
let bridgeHasDimensions = true;
|
|
17
|
+
|
|
18
|
+
/** Records bridge calls. getSiteContext reports dimensions unless the test simulates an older bridge. */
|
|
19
|
+
function mockFetch() {
|
|
20
|
+
globalThis.fetch = (async (input: any, init: any = {}) => {
|
|
21
|
+
const url = new URL(String(input));
|
|
22
|
+
calls.push({ url, method: init.method ?? 'GET', body: init.body ? JSON.parse(init.body) : undefined });
|
|
23
|
+
const payload = url.pathname.endsWith('/getSiteContext')
|
|
24
|
+
? { apiVersion: 2, ...(bridgeHasDimensions ? { dimensions: [{ name: 'language', default: 'en_US', values: [] }] } : {}) }
|
|
25
|
+
: { apiVersion: 2, success: true };
|
|
26
|
+
return new Response(JSON.stringify(payload), { status: 200, headers: { 'content-type': 'application/json' } });
|
|
27
|
+
}) as typeof fetch;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
before(async () => {
|
|
31
|
+
setApiVersion(2);
|
|
32
|
+
const server = createServer();
|
|
33
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
34
|
+
client = new Client({ name: 'test', version: '0.0.0' });
|
|
35
|
+
await Promise.all([server.connect(serverTransport), client.connect(clientTransport)]);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
after(() => {
|
|
39
|
+
globalThis.fetch = realFetch;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
calls = [];
|
|
44
|
+
bridgeHasDimensions = true;
|
|
45
|
+
resetDimensionSupport();
|
|
46
|
+
mockFetch();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const paths = () => calls.map((c) => c.url.pathname);
|
|
50
|
+
|
|
51
|
+
test('without "dimensions" no support check is made and nothing dimension related is sent', async () => {
|
|
52
|
+
const result = await client.callTool({ name: 'neos_list_pages', arguments: {} });
|
|
53
|
+
assert.notEqual(result.isError, true);
|
|
54
|
+
assert.deepEqual(paths(), ['/neos/mcp/listPages']);
|
|
55
|
+
assert.equal(calls[0].url.searchParams.has('dimensions'), false);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('neos_list_pages sends "dimensions" as a JSON string in the query, after checking bridge support', async () => {
|
|
59
|
+
const result = await client.callTool({ name: 'neos_list_pages', arguments: { workspace: 'live', dimensions: { language: 'nl' } } });
|
|
60
|
+
assert.notEqual(result.isError, true, JSON.stringify(result.content));
|
|
61
|
+
assert.deepEqual(paths(), ['/neos/mcp/getSiteContext', '/neos/mcp/listPages']);
|
|
62
|
+
const list = calls[1];
|
|
63
|
+
assert.equal(list.url.searchParams.get('workspace'), 'live');
|
|
64
|
+
assert.deepEqual(JSON.parse(list.url.searchParams.get('dimensions') ?? ''), { language: 'nl' });
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('the bridge support check is made once', async () => {
|
|
68
|
+
await client.callTool({ name: 'neos_list_pages', arguments: { dimensions: { language: 'nl' } } });
|
|
69
|
+
await client.callTool({ name: 'neos_list_pages', arguments: { dimensions: { language: 'de' } } });
|
|
70
|
+
assert.deepEqual(paths(), ['/neos/mcp/getSiteContext', '/neos/mcp/listPages', '/neos/mcp/listPages']);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('read tools pass "dimensions" with the node id', async () => {
|
|
74
|
+
await client.callTool({ name: 'neos_get_page_content', arguments: { node_id: 'abc', dimensions: { language: 'de' } } });
|
|
75
|
+
const read = calls.find((c) => c.url.pathname.endsWith('/getPageContent'))!;
|
|
76
|
+
assert.equal(read.url.searchParams.get('nodeAggregateId'), 'abc');
|
|
77
|
+
assert.deepEqual(JSON.parse(read.url.searchParams.get('dimensions') ?? ''), { language: 'de' });
|
|
78
|
+
|
|
79
|
+
calls = [];
|
|
80
|
+
await client.callTool({ name: 'neos_get_document_properties', arguments: { node_id: 'abc', dimensions: { language: 'de' } } });
|
|
81
|
+
const props = calls.find((c) => c.url.pathname.endsWith('/getDocumentProperties'))!;
|
|
82
|
+
assert.deepEqual(JSON.parse(props.url.searchParams.get('dimensions') ?? ''), { language: 'de' });
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('write tools send "dimensions" in the body', async () => {
|
|
86
|
+
const cases: Array<[string, Record<string, unknown>, string]> = [
|
|
87
|
+
['neos_update_node_property', { node_id: 'abc', property: 'title', value: 'x' }, 'updateNodeProperty'],
|
|
88
|
+
['neos_delete_node', { node_id: 'abc' }, 'deleteNode'],
|
|
89
|
+
['neos_move_node', { node_id: 'abc', insert_before: 'def' }, 'moveNode'],
|
|
90
|
+
['neos_create_content_node', { parent_id: 'abc', node_type: 'X:Y' }, 'createContentNode'],
|
|
91
|
+
['neos_create_document_node', { parent_id: 'abc', node_type: 'X:Y' }, 'createDocumentNode'],
|
|
92
|
+
];
|
|
93
|
+
for (const [tool, args, action] of cases) {
|
|
94
|
+
calls = [];
|
|
95
|
+
const result = await client.callTool({ name: tool, arguments: { ...args, dimensions: { language: 'nl' } } });
|
|
96
|
+
assert.notEqual(result.isError, true, tool + ': ' + JSON.stringify(result.content));
|
|
97
|
+
const write = calls.find((c) => c.url.pathname.endsWith('/' + action))!;
|
|
98
|
+
assert.equal(write.method, 'POST', tool);
|
|
99
|
+
assert.deepEqual(JSON.parse(write.body.dimensions), { language: 'nl' }, tool);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('write tools without "dimensions" send no dimensions key', async () => {
|
|
104
|
+
await client.callTool({ name: 'neos_update_node_property', arguments: { node_id: 'abc', property: 'title', value: 'x' } });
|
|
105
|
+
assert.equal('dimensions' in calls[0].body, false);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('neos_create_node_variant sends target and source dimensions and the mode', async () => {
|
|
109
|
+
const result = await client.callTool({
|
|
110
|
+
name: 'neos_create_node_variant',
|
|
111
|
+
arguments: { node_id: 'abc', dimensions: { language: 'nl' }, source_dimensions: { language: 'en_US' }, mode: 'empty' },
|
|
112
|
+
});
|
|
113
|
+
assert.notEqual(result.isError, true, JSON.stringify(result.content));
|
|
114
|
+
const variant = calls.find((c) => c.url.pathname.endsWith('/createNodeVariant'))!;
|
|
115
|
+
assert.equal(variant.method, 'POST');
|
|
116
|
+
assert.equal(variant.body.nodeAggregateId, 'abc');
|
|
117
|
+
assert.deepEqual(JSON.parse(variant.body.dimensions), { language: 'nl' });
|
|
118
|
+
assert.deepEqual(JSON.parse(variant.body.sourceDimensions), { language: 'en_US' });
|
|
119
|
+
assert.equal(variant.body.mode, 'empty');
|
|
120
|
+
assert.equal(variant.body.workspace, 'mcp');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('neos_create_node_variant defaults to copy mode and leaves out the source dimensions', async () => {
|
|
124
|
+
await client.callTool({ name: 'neos_create_node_variant', arguments: { node_id: 'abc', dimensions: { language: 'nl' } } });
|
|
125
|
+
const variant = calls.find((c) => c.url.pathname.endsWith('/createNodeVariant'))!;
|
|
126
|
+
assert.equal(variant.body.mode, 'copy');
|
|
127
|
+
assert.equal('sourceDimensions' in variant.body, false);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test('neos_create_node_variant needs target dimensions', async () => {
|
|
131
|
+
const result = await client.callTool({ name: 'neos_create_node_variant', arguments: { node_id: 'abc' } });
|
|
132
|
+
assert.equal(result.isError, true);
|
|
133
|
+
assert.equal(calls.length, 0);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test('with "dimensions", nothing is read or written when the bridge has no dimension support', async () => {
|
|
137
|
+
bridgeHasDimensions = false;
|
|
138
|
+
for (const [tool, args] of [
|
|
139
|
+
['neos_list_pages', {}],
|
|
140
|
+
['neos_update_node_property', { node_id: 'abc', property: 'title', value: 'x' }],
|
|
141
|
+
['neos_delete_node', { node_id: 'abc' }],
|
|
142
|
+
] as Array<[string, Record<string, unknown>]>) {
|
|
143
|
+
calls = [];
|
|
144
|
+
const result = await client.callTool({ name: tool, arguments: { ...args, dimensions: { language: 'nl' } } });
|
|
145
|
+
assert.equal(result.isError, true, tool);
|
|
146
|
+
assert.deepEqual(paths(), ['/neos/mcp/getSiteContext'], tool);
|
|
147
|
+
assert.match(JSON.stringify(result.content), /does not support content dimensions/, tool);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test('the dimension tools describe how to work with variants', async () => {
|
|
152
|
+
const { tools } = await client.listTools();
|
|
153
|
+
const variant = tools.find((t) => t.name === 'neos_create_node_variant');
|
|
154
|
+
assert.ok(variant);
|
|
155
|
+
assert.match(variant.description ?? '', /parent/);
|
|
156
|
+
const del = tools.find((t) => t.name === 'neos_delete_node');
|
|
157
|
+
assert.match(del?.description ?? '', /fallback/);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test('preview, pending changes and publishing pass "dimensions" and check bridge support first', async () => {
|
|
161
|
+
await client.callTool({ name: 'neos_get_preview_url', arguments: { node_id: 'abc', dimensions: { language: 'nl' } } });
|
|
162
|
+
const preview = calls.find((c) => c.url.pathname.endsWith('/getPreviewUrl'))!;
|
|
163
|
+
assert.deepEqual(JSON.parse(preview.url.searchParams.get('dimensions') ?? ''), { language: 'nl' });
|
|
164
|
+
|
|
165
|
+
calls = [];
|
|
166
|
+
await client.callTool({ name: 'neos_list_pending_changes', arguments: { dimensions: { language: 'nl' } } });
|
|
167
|
+
const pending = calls.find((c) => c.url.pathname.endsWith('/listPendingChanges'))!;
|
|
168
|
+
assert.deepEqual(JSON.parse(pending.url.searchParams.get('dimensions') ?? ''), { language: 'nl' });
|
|
169
|
+
|
|
170
|
+
calls = [];
|
|
171
|
+
await client.callTool({ name: 'neos_publish_changes', arguments: { dimensions: { language: 'nl' } } });
|
|
172
|
+
const publish = calls.find((c) => c.url.pathname.endsWith('/publishChanges'))!;
|
|
173
|
+
assert.equal(publish.method, 'POST');
|
|
174
|
+
assert.deepEqual(JSON.parse(publish.body.dimensions), { language: 'nl' });
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test('publishing with "dimensions" is refused when the bridge has no dimension support', async () => {
|
|
178
|
+
bridgeHasDimensions = false;
|
|
179
|
+
const result = await client.callTool({ name: 'neos_publish_changes', arguments: { dimensions: { language: 'nl' } } });
|
|
180
|
+
assert.equal(result.isError, true);
|
|
181
|
+
assert.deepEqual(paths(), ['/neos/mcp/getSiteContext']);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test('publishing without "dimensions" sends none', async () => {
|
|
185
|
+
await client.callTool({ name: 'neos_publish_changes', arguments: {} });
|
|
186
|
+
assert.equal('dimensions' in calls[0].body, false);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
test('several dimensions are sent together, for reading and writing', async () => {
|
|
190
|
+
const dimensions = { language: 'nl', country: 'be' };
|
|
191
|
+
|
|
192
|
+
await client.callTool({ name: 'neos_list_pages', arguments: { dimensions } });
|
|
193
|
+
const list = calls.find((c) => c.url.pathname.endsWith('/listPages'))!;
|
|
194
|
+
assert.deepEqual(JSON.parse(list.url.searchParams.get('dimensions') ?? ''), dimensions);
|
|
195
|
+
|
|
196
|
+
calls = [];
|
|
197
|
+
await client.callTool({
|
|
198
|
+
name: 'neos_create_node_variant',
|
|
199
|
+
arguments: { node_id: 'abc', dimensions, source_dimensions: { language: 'en_US', country: 'nl' } },
|
|
200
|
+
});
|
|
201
|
+
const variant = calls.find((c) => c.url.pathname.endsWith('/createNodeVariant'))!;
|
|
202
|
+
assert.deepEqual(JSON.parse(variant.body.dimensions), dimensions);
|
|
203
|
+
assert.deepEqual(JSON.parse(variant.body.sourceDimensions), { language: 'en_US', country: 'nl' });
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
test('an empty "dimensions" object is treated as not given', async () => {
|
|
207
|
+
await client.callTool({ name: 'neos_list_pages', arguments: { dimensions: {} } });
|
|
208
|
+
assert.deepEqual(paths(), ['/neos/mcp/listPages']);
|
|
209
|
+
assert.equal(calls[0].url.searchParams.has('dimensions'), false);
|
|
210
|
+
});
|