@upassist/neos-mcp 2.2.0 → 2.4.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.
@@ -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
  }
@@ -1,5 +1,5 @@
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 registerEntityCrudTools(server: McpServer): void {
@@ -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 registerGetDocumentProperties(server: McpServer): void {
6
7
  server.tool(
@@ -9,9 +10,10 @@ export function registerGetDocumentProperties(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_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,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 registerGetPageContent(server: McpServer): void {
6
7
  server.tool(
@@ -9,9 +10,10 @@ export function registerGetPageContent(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_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,13 +1,18 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { z } from 'zod/v3';
2
3
  import { callBridge, setApiVersion } from '../bridge.js';
3
4
 
4
5
  export function registerGetSiteContext(server: McpServer): void {
5
6
  server.tool(
6
7
  'neos_get_site_context',
7
- '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.',
8
- {},
9
- async () => {
10
- const data = await callBridge('getSiteContext', 'GET') as Record<string, unknown>;
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. ' +
10
+ '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.',
11
+ {
12
+ site: z.string().optional().describe('Site node name (see neos_list_sites). Defaults to the default site of the instance.'),
13
+ },
14
+ async ({ site }) => {
15
+ const data = await callBridge('getSiteContext', 'GET', { site }) as Record<string, unknown>;
11
16
 
12
17
  // Auto-detect bridge API version
13
18
  if (data && typeof data === 'object' && 'apiVersion' in data && data.apiVersion === 2) {
@@ -1,5 +1,5 @@
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 registerListAssets(server: McpServer): void {
@@ -1,5 +1,5 @@
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 {
@@ -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 registerListPages(server: McpServer): void {
6
7
  server.tool(
@@ -8,9 +9,11 @@ export function registerListPages(server: McpServer): void {
8
9
  'List all document nodes (pages) in the Neos CMS site as a flat tree with paths and titles.',
9
10
  {
10
11
  workspace: z.string().default('mcp').describe('Workspace name. Use "live" for published content, "mcp" for staged changes.'),
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.'),
11
14
  },
12
- async ({ workspace }) => {
13
- const data = await callBridge('listPages', 'GET', { workspace });
15
+ async ({ workspace, site, dimensions }) => {
16
+ const data = await callBridge('listPages', 'GET', { workspace, site, ...await dimensionsParam(dimensions) });
14
17
  return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
15
18
  }
16
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(
@@ -8,9 +9,11 @@ export function registerListPendingChanges(server: McpServer): void {
8
9
  'List all content changes staged in the MCP workspace that have not yet been published to live. Call this before neos_publish_changes to review what will go live.',
9
10
  {
10
11
  workspace: z.string().default('mcp').describe('Workspace name to check for pending changes'),
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".'),
11
14
  },
12
- async ({ workspace }) => {
13
- const data = await callBridge('listPendingChanges', 'GET', { workspace });
15
+ async ({ workspace, site, dimensions }) => {
16
+ const data = await callBridge('listPendingChanges', 'GET', { workspace, site, ...await dimensionsParam(dimensions) });
14
17
  return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
15
18
  }
16
19
  );
@@ -0,0 +1,15 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { callBridge } from '../bridge.js';
3
+
4
+ export function registerListSites(server: McpServer): void {
5
+ server.tool(
6
+ 'neos_list_sites',
7
+ 'List all sites of the Neos instance: name, node name, online state, domains and which one is the default site. ' +
8
+ 'Pass a site node name as "site" to neos_get_site_context, neos_list_pages, neos_list_pending_changes and neos_publish_changes to work on a site other than the default one.',
9
+ {},
10
+ async () => {
11
+ const data = await callBridge('listSites', 'GET');
12
+ return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
13
+ }
14
+ );
15
+ }
@@ -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,16 +1,35 @@
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
- '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
+ '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. ' +
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).',
9
12
  {
10
13
  workspace: z.string().default('mcp').describe('Workspace to publish from'),
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.'),
11
16
  },
12
- async ({ workspace }) => {
13
- const data = await callBridge('publishChanges', 'POST', { workspace });
17
+ async ({ workspace, site, dimensions }) => {
18
+ if (site) {
19
+ // A bridge without multi-site support ignores "site" and would publish the changes of
20
+ // all sites. Publishing cannot be undone, so only go ahead when the bridge knows sites.
21
+ try {
22
+ await callBridge('listSites', 'GET');
23
+ } catch (error) {
24
+ const reason = error instanceof Error ? error.message : String(error);
25
+ throw new Error(
26
+ `Not published: could not confirm that the bridge supports multi-site (${reason}). ` +
27
+ 'A bridge without multi-site support would publish the changes of all sites. ' +
28
+ 'Update the bridge (upassist/neos-mcp 2.3+ for Neos 9, 1.2+ for Neos 8) or publish without "site" if that is what you want.'
29
+ );
30
+ }
31
+ }
32
+ const data = await callBridge('publishChanges', 'POST', { workspace, site, ...await dimensionsParam(dimensions) });
14
33
  return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
15
34
  }
16
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(
@@ -18,13 +19,15 @@ export function registerUpdateNodeProperty(server: McpServer): void {
18
19
  'A node:// target must exist in the workspace (check with neos_list_pages), otherwise the write is rejected.'
19
20
  ),
20
21
  workspace: z.string().default('mcp').describe('Workspace to write to'),
22
+ 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
23
  },
22
- async ({ node_id, property, value, workspace }) => {
24
+ async ({ node_id, property, value, workspace, dimensions }) => {
23
25
  const data = await callBridge('updateNodeProperty', 'POST', {
24
26
  ...await nodeIdParam('contextPath', node_id),
25
27
  property,
26
28
  value,
27
29
  workspace,
30
+ ...await dimensionsParam(dimensions),
28
31
  });
29
32
  return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
30
33
  }
@@ -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(
@@ -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
+ });
@@ -0,0 +1,116 @@
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
+
10
+ type Call = { url: URL; method: string; body: any };
11
+
12
+ const realFetch = globalThis.fetch;
13
+ let calls: Call[] = [];
14
+ let client: Client;
15
+
16
+ /** Records bridge calls and answers with a minimal v2 payload. */
17
+ function mockFetch() {
18
+ globalThis.fetch = (async (input: any, init: any = {}) => {
19
+ calls.push({
20
+ url: new URL(String(input)),
21
+ method: init.method ?? 'GET',
22
+ body: init.body ? JSON.parse(init.body) : undefined,
23
+ });
24
+ return new Response(JSON.stringify({ apiVersion: 2, success: true }), {
25
+ status: 200,
26
+ headers: { 'content-type': 'application/json' },
27
+ });
28
+ }) as typeof fetch;
29
+ }
30
+
31
+ before(async () => {
32
+ setApiVersion(2);
33
+ const server = createServer();
34
+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
35
+ client = new Client({ name: 'test', version: '0.0.0' });
36
+ await Promise.all([server.connect(serverTransport), client.connect(clientTransport)]);
37
+ });
38
+
39
+ after(() => {
40
+ globalThis.fetch = realFetch;
41
+ });
42
+
43
+ beforeEach(() => {
44
+ calls = [];
45
+ mockFetch();
46
+ });
47
+
48
+ async function call(name: string, args: Record<string, unknown> = {}) {
49
+ const result = await client.callTool({ name, arguments: args });
50
+ assert.notEqual(result.isError, true, JSON.stringify(result.content));
51
+ assert.equal(calls.length, 1);
52
+ return calls[0];
53
+ }
54
+
55
+ test('neos_list_sites is registered and calls listSites', async () => {
56
+ const { tools } = await client.listTools();
57
+ assert.ok(tools.some((t) => t.name === 'neos_list_sites'));
58
+
59
+ const request = await call('neos_list_sites');
60
+ assert.equal(request.url.pathname, '/neos/mcp/listSites');
61
+ assert.equal(request.method, 'GET');
62
+ });
63
+
64
+ test('neos_get_site_context passes "site" only when given', async () => {
65
+ const withSite = await call('neos_get_site_context', { site: 'azubi' });
66
+ assert.equal(withSite.url.pathname, '/neos/mcp/getSiteContext');
67
+ assert.equal(withSite.url.searchParams.get('site'), 'azubi');
68
+
69
+ calls = [];
70
+ const withoutSite = await call('neos_get_site_context');
71
+ assert.equal(withoutSite.url.searchParams.has('site'), false);
72
+ });
73
+
74
+ test('neos_list_pages and neos_list_pending_changes pass "site" as query parameter', async () => {
75
+ const pages = await call('neos_list_pages', { site: 'azubi' });
76
+ assert.equal(pages.url.pathname, '/neos/mcp/listPages');
77
+ assert.equal(pages.url.searchParams.get('site'), 'azubi');
78
+ assert.equal(pages.url.searchParams.get('workspace'), 'mcp');
79
+
80
+ calls = [];
81
+ const changes = await call('neos_list_pending_changes', { site: 'site' });
82
+ assert.equal(changes.url.pathname, '/neos/mcp/listPendingChanges');
83
+ assert.equal(changes.url.searchParams.get('site'), 'site');
84
+ });
85
+
86
+ test('neos_publish_changes checks multi-site support, then sends "site" in the body, and no site without it', async () => {
87
+ const result = await client.callTool({ name: 'neos_publish_changes', arguments: { site: 'azubi' } });
88
+ assert.notEqual(result.isError, true);
89
+ assert.equal(calls.length, 2);
90
+ assert.equal(calls[0].url.pathname, '/neos/mcp/listSites');
91
+ const perSite = calls[1];
92
+ assert.equal(perSite.url.pathname, '/neos/mcp/publishChanges');
93
+ assert.equal(perSite.method, 'POST');
94
+ assert.deepEqual(perSite.body, { workspace: 'mcp', site: 'azubi' });
95
+
96
+ calls = [];
97
+ const all = await call('neos_publish_changes');
98
+ assert.deepEqual(all.body, { workspace: 'mcp' });
99
+ });
100
+
101
+ test('the publish tool warns that without "site" all sites go live', async () => {
102
+ const { tools } = await client.listTools();
103
+ const tool = tools.find((t) => t.name === 'neos_publish_changes');
104
+ assert.match(tool?.description ?? '', /all sites/);
105
+ });
106
+
107
+ test('neos_publish_changes with "site" does not publish when the bridge has no multi-site support', async () => {
108
+ globalThis.fetch = (async (input: any, init: any = {}) => {
109
+ calls.push({ url: new URL(String(input)), method: init.method ?? 'GET', body: init.body ? JSON.parse(init.body) : undefined });
110
+ return new Response(JSON.stringify({ error: 'Not found' }), { status: 404, headers: { 'content-type': 'application/json' } });
111
+ }) as typeof fetch;
112
+
113
+ const result = await client.callTool({ name: 'neos_publish_changes', arguments: { site: 'azubi' } });
114
+ assert.equal(result.isError, true);
115
+ assert.deepEqual(calls.map((c) => c.url.pathname), ['/neos/mcp/listSites']);
116
+ });