@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.
@@ -0,0 +1,85 @@
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: string; body: any };
11
+
12
+ const realFetch = globalThis.fetch;
13
+ let calls: Call[] = [];
14
+ let client: Client;
15
+
16
+ /** Records bridge calls; the bridge resolves reference targets, so the client must pass them through untouched. */
17
+ function mockFetch() {
18
+ globalThis.fetch = (async (input: any, init: any = {}) => {
19
+ calls.push({ url: String(input), body: init.body ? JSON.parse(init.body) : undefined });
20
+ return new Response(JSON.stringify({ success: true }), {
21
+ status: 200,
22
+ headers: { 'content-type': 'application/json' },
23
+ });
24
+ }) as typeof fetch;
25
+ }
26
+
27
+ before(async () => {
28
+ setApiVersion(2);
29
+ const server = createServer();
30
+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
31
+ client = new Client({ name: 'test', version: '0.0.0' });
32
+ await Promise.all([server.connect(serverTransport), client.connect(clientTransport)]);
33
+ });
34
+
35
+ after(() => {
36
+ globalThis.fetch = realFetch;
37
+ });
38
+
39
+ beforeEach(() => {
40
+ calls = [];
41
+ mockFetch();
42
+ });
43
+
44
+ test('neos_update_node_property: a list of reference targets is sent as an array', async () => {
45
+ const targets = ['brand-1', 'brand-2', 'brand-3'];
46
+ const result = await client.callTool({
47
+ name: 'neos_update_node_property',
48
+ arguments: { node_id: 'n1', property: 'brandReferences', value: targets },
49
+ });
50
+ assert.notEqual(result.isError, true);
51
+
52
+ assert.equal(calls[0].url, 'http://bridge.test/neos/mcp/updateNodeProperty');
53
+ assert.deepEqual(calls[0].body.value, targets);
54
+ });
55
+
56
+ test('neos_create_content_node: reference targets inside properties are sent unchanged', async () => {
57
+ const properties = { contactPersonReference: 'person-1', brandReferences: ['brand-1', 'brand-2'] };
58
+ const result = await client.callTool({
59
+ name: 'neos_create_content_node',
60
+ arguments: { parent_id: 'p1', node_type: 'Vendor.Site:Content.BrandSelection', properties },
61
+ });
62
+ assert.notEqual(result.isError, true);
63
+
64
+ assert.deepEqual(calls[0].body.properties, properties);
65
+ });
66
+
67
+ test('references are described on the tools that read and write them', async () => {
68
+ const { tools } = await client.listTools();
69
+ const byName = (name: string) => tools.find((t) => t.name === name);
70
+
71
+ const value = (byName('neos_update_node_property')?.inputSchema.properties as any)?.value?.description ?? '';
72
+ assert.match(value, /"references"/);
73
+ assert.match(value, /targetNodeTypes/);
74
+ assert.match(byName('neos_list_node_types')?.description ?? '', /targetNodeTypes/);
75
+ for (const name of ['neos_list_pages', 'neos_get_page_content', 'neos_get_document_properties', 'neos_get_site_context']) {
76
+ assert.match(byName(name)?.description ?? '', /"references"/, name);
77
+ }
78
+ });
79
+
80
+ test('the references block is described as Neos 9 only', async () => {
81
+ const { tools } = await client.listTools();
82
+ const value = (tools.find((t) => t.name === 'neos_update_node_property')?.inputSchema.properties as any)?.value?.description ?? '';
83
+ assert.match(value, /Neos 9/);
84
+ assert.match(tools.find((t) => t.name === 'neos_list_node_types')?.description ?? '', /Neos 8/);
85
+ });