@etm-professional-control/winccoa-mcp-server 1.5.0 → 1.5.2

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.
Files changed (63) hide show
  1. package/.env.example +12 -2
  2. package/OSS.md +20 -20
  3. package/README.md +10 -14
  4. package/build/config/limits.d.ts +35 -0
  5. package/build/config/limits.d.ts.map +1 -0
  6. package/build/config/limits.js +70 -0
  7. package/build/config/limits.js.map +1 -0
  8. package/build/config/server.config.d.ts.map +1 -1
  9. package/build/config/server.config.js +2 -1
  10. package/build/config/server.config.js.map +1 -1
  11. package/build/helpers/icons/IX_ICONS_LIST.txt +1407 -0
  12. package/build/helpers/icons/IconGenerator.d.ts +54 -3
  13. package/build/helpers/icons/IconGenerator.d.ts.map +1 -1
  14. package/build/helpers/icons/IconGenerator.js +104 -22
  15. package/build/helpers/icons/IconGenerator.js.map +1 -1
  16. package/build/helpers/icons/IconList.d.ts +17 -2
  17. package/build/helpers/icons/IconList.d.ts.map +1 -1
  18. package/build/helpers/icons/IconList.js +41 -19
  19. package/build/helpers/icons/IconList.js.map +1 -1
  20. package/build/index_http.d.ts.map +1 -1
  21. package/build/index_http.js +32 -2
  22. package/build/index_http.js.map +1 -1
  23. package/build/server.d.ts.map +1 -1
  24. package/build/server.js +8 -1
  25. package/build/server.js.map +1 -1
  26. package/build/tool_loader.d.ts +21 -1
  27. package/build/tool_loader.d.ts.map +1 -1
  28. package/build/tool_loader.js +49 -8
  29. package/build/tool_loader.js.map +1 -1
  30. package/build/tools/archive/archive_query.d.ts.map +1 -1
  31. package/build/tools/archive/archive_query.js +2 -5
  32. package/build/tools/archive/archive_query.js.map +1 -1
  33. package/build/tools/common/common_query.d.ts.map +1 -1
  34. package/build/tools/common/common_query.js +2 -5
  35. package/build/tools/common/common_query.js.map +1 -1
  36. package/build/tools/dashboards/widget.d.ts.map +1 -1
  37. package/build/tools/dashboards/widget.js +4 -6
  38. package/build/tools/dashboards/widget.js.map +1 -1
  39. package/build/tools/datapoints/dp_basic.d.ts.map +1 -1
  40. package/build/tools/datapoints/dp_basic.js +62 -38
  41. package/build/tools/datapoints/dp_basic.js.map +1 -1
  42. package/build/tools/datapoints/dp_types.d.ts.map +1 -1
  43. package/build/tools/datapoints/dp_types.js +15 -9
  44. package/build/tools/datapoints/dp_types.js.map +1 -1
  45. package/build/tools/icons/icon.d.ts.map +1 -1
  46. package/build/tools/icons/icon.js +52 -7
  47. package/build/tools/icons/icon.js.map +1 -1
  48. package/build/tools/pv_range/pv_range_query.d.ts +12 -0
  49. package/build/tools/pv_range/pv_range_query.d.ts.map +1 -1
  50. package/build/tools/pv_range/pv_range_query.js +63 -31
  51. package/build/tools/pv_range/pv_range_query.js.map +1 -1
  52. package/build/utils/helpers.d.ts +56 -4
  53. package/build/utils/helpers.d.ts.map +1 -1
  54. package/build/utils/helpers.js +144 -14
  55. package/build/utils/helpers.js.map +1 -1
  56. package/build/utils/projectPath.d.ts +52 -0
  57. package/build/utils/projectPath.d.ts.map +1 -0
  58. package/build/utils/projectPath.js +102 -0
  59. package/build/utils/projectPath.js.map +1 -0
  60. package/manifest.cjs +50 -0
  61. package/package.json +7 -6
  62. package/postinstall.cjs +10 -4
  63. package/sbom.json +615 -615
@@ -1,26 +1,156 @@
1
1
  /**
2
2
  * Utility helper functions for MCP tool responses and datapoint operations
3
3
  */
4
+ import * as log from './logger.js';
4
5
  /**
5
- * Create content array for MCP responses, filtering internal types if needed
6
+ * Filter datapoint type names, dropping internal types (starting with _) unless requested
6
7
  * @param arr - Array of type names
7
8
  * @param withInternals - Whether to include internal types (starting with _)
8
- * @returns Content array for MCP response
9
+ * @returns Filtered type names
9
10
  */
10
- export function mkTypesContent(arr, withInternals) {
11
- const ret = [];
12
- for (let i = 0; i < arr.length; i++) {
13
- const item = arr[i];
14
- if (item !== undefined) {
15
- if (!item.startsWith('_')) {
16
- ret.push({ type: "text", text: item });
17
- }
18
- else if (withInternals) {
19
- ret.push({ type: "text", text: item });
20
- }
11
+ export function filterTypeNames(arr, withInternals) {
12
+ return arr.filter((item) => typeof item === 'string' && (withInternals === true || !item.startsWith('_')));
13
+ }
14
+ /** Read a numeric `code` from an error-like value. */
15
+ function errorCode(e) {
16
+ const code = e?.code;
17
+ if (typeof code === 'number')
18
+ return code;
19
+ if (typeof code === 'string' && code.trim() !== '' && !Number.isNaN(Number(code)))
20
+ return Number(code);
21
+ return undefined;
22
+ }
23
+ /** Read a message from an error-like value. */
24
+ function errorMessage(e) {
25
+ if (e instanceof Error)
26
+ return e.message;
27
+ if (typeof e === 'string')
28
+ return e;
29
+ const message = e?.message;
30
+ return typeof message === 'string' ? message : String(e);
31
+ }
32
+ /** Read the dpe an error refers to, if the manager attached one. */
33
+ function errorDpe(e) {
34
+ const err = e;
35
+ if (typeof err?.dpe === 'string')
36
+ return err.dpe;
37
+ if (typeof err?.dpName === 'string')
38
+ return err.dpName;
39
+ return undefined;
40
+ }
41
+ /** Nested WinCC OA errors, if any. */
42
+ function errorDetails(e) {
43
+ const details = e?.details;
44
+ if (Array.isArray(details))
45
+ return details;
46
+ // A single nested error instead of an array
47
+ if (details instanceof Error || (typeof details === 'object' && details !== null && 'message' in details)) {
48
+ return [details];
49
+ }
50
+ return [];
51
+ }
52
+ /**
53
+ * Flatten a WinccoaError into code, message and inner details.
54
+ *
55
+ * A failing dpGet usually throws 9399 "multiple errors (N errors total)" with
56
+ * the real cause - e.g. 71 "DP does not exist" naming the element - only in
57
+ * `details`. Forwarding `error.message` alone hides that from the client.
58
+ * Nested details are flattened (their own details are pulled up one level).
59
+ *
60
+ * @param e - Caught error
61
+ * @param fallbackDpe - DPE the caller requested; used for inner details that carry no dpe themselves
62
+ * @returns Flattened description
63
+ */
64
+ export function describeWinccoaError(e, fallbackDpe) {
65
+ const outerCode = errorCode(e);
66
+ const outerMessage = errorMessage(e);
67
+ const details = [];
68
+ const push = (inner) => {
69
+ const detail = { message: errorMessage(inner) };
70
+ const code = errorCode(inner);
71
+ if (code !== undefined)
72
+ detail.code = code;
73
+ const dpe = errorDpe(inner) || fallbackDpe;
74
+ if (dpe)
75
+ detail.dpe = dpe;
76
+ details.push(detail);
77
+ };
78
+ for (const inner of errorDetails(e)) {
79
+ const nested = errorDetails(inner);
80
+ if (nested.length > 0) {
81
+ nested.forEach(push);
82
+ }
83
+ else {
84
+ push(inner);
21
85
  }
22
86
  }
23
- return ret;
87
+ if (details.length === 0) {
88
+ return {
89
+ ...(outerCode !== undefined ? { code: outerCode, outerCode } : {}),
90
+ message: outerMessage,
91
+ details
92
+ };
93
+ }
94
+ const innerCodes = new Set(details.map(d => d.code));
95
+ const commonCode = innerCodes.size === 1 ? [...innerCodes][0] : undefined;
96
+ const code = commonCode !== undefined ? commonCode : outerCode;
97
+ const message = [...new Set(details.map(d => d.message))].join('; ');
98
+ return {
99
+ ...(code !== undefined ? { code } : {}),
100
+ ...(outerCode !== undefined ? { outerCode } : {}),
101
+ message,
102
+ details
103
+ };
104
+ }
105
+ /** Codes meaning "the client asked for something that does not exist": expected, not a server fault. */
106
+ const EXPECTED_NOT_FOUND_CODES = new Set([71, 57, 19]);
107
+ /**
108
+ * Log a caught WinCC OA error as a single line.
109
+ *
110
+ * Expected not-found codes (71 DP does not exist, 57 DP type does not exist,
111
+ * 19 attribute not in config) are client mistakes and go out at warn level.
112
+ * Everything else is logged at error level; the stack is added only at
113
+ * MCP_LOG_LEVEL=debug. The error object itself is never dumped.
114
+ *
115
+ * @param context - What was being attempted, e.g. "Error getting type name for X"
116
+ * @param e - Caught error
117
+ * @param fallbackDpe - DPE the caller requested
118
+ */
119
+ export function logWinccoaError(context, e, fallbackDpe) {
120
+ const described = describeWinccoaError(e, fallbackDpe);
121
+ // WinccoaError messages already start with "<code>, "; do not repeat the code.
122
+ const hasCodePrefix = described.code !== undefined && described.message.trimStart().startsWith(`${described.code},`);
123
+ const codePrefix = described.code !== undefined && !hasCodePrefix ? `[${described.code}] ` : '';
124
+ const line = `${context}: ${codePrefix}${described.message}`;
125
+ if (described.code !== undefined && EXPECTED_NOT_FOUND_CODES.has(described.code)) {
126
+ log.warn(line);
127
+ return;
128
+ }
129
+ log.error(line);
130
+ if (e instanceof Error && e.stack)
131
+ log.debug(e.stack);
132
+ }
133
+ /** errorType per WinCC OA error code, for winccoaErrorResponse. */
134
+ const WINCCOA_ERROR_TYPES = {
135
+ 71: 'DP_NOT_EXIST',
136
+ 57: 'DP_TYPE_NOT_EXIST'
137
+ };
138
+ /**
139
+ * Build the uniform error envelope for a caught WinCC OA error:
140
+ * `{error, message, errorCode?, errorType?, details}`.
141
+ *
142
+ * @param prefix - Message prefix, e.g. "Failed to get type name for X"
143
+ * @param e - Caught error
144
+ * @param fallbackDpe - DPE the caller requested (fills empty details[].dpe)
145
+ */
146
+ export function winccoaErrorResponse(prefix, e, fallbackDpe) {
147
+ const described = describeWinccoaError(e, fallbackDpe);
148
+ const errorType = described.code !== undefined ? WINCCOA_ERROR_TYPES[described.code] : undefined;
149
+ return createErrorResponse(`${prefix}: ${described.message}`, {
150
+ errorCode: described.code,
151
+ ...(errorType ? { errorType } : {}),
152
+ details: described.details
153
+ });
24
154
  }
25
155
  /**
26
156
  * Recursively add description and unit information to datapoint children
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,GAAa,EAAE,aAAuB;IACnE,MAAM,GAAG,GAAiB,EAAE,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC1B,GAAG,CAAC,IAAI,CAAC,EA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AE7B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,6BAA6B,CAAC,GAAG,CAAC,EAAE,CAAC;YACxC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,MAAM,KAAK,CAAC;QAC3B,OAAO;KACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * WinCC OA project path resolution.
3
+ *
4
+ * Tools that write into the project (custom dashboard icons under
5
+ * <proj>/data/WebUI/icons) need the project directory. It used to be derived by
6
+ * walking a fixed number of directories up from the compiled module, which is
7
+ * only right for one layout: a git clone inside <proj>/javascript/. It is wrong
8
+ * for the flat npm/zip layout (<proj>/javascript/mcpWinCCOA/...), for older zip
9
+ * layouts, and for symlinked development checkouts (Node resolves ESM modules
10
+ * through their real path), and it then pointed somewhere outside the project.
11
+ *
12
+ * The WinCC OA JavaScript manager knows the project path, so ask it first.
13
+ */
14
+ /** Where a resolved project path came from, for logging. */
15
+ export type ProjectPathSource = 'WINCCOA_PROJ_PATH' | 'winccoa.getPaths()' | 'PVSS_II' | 'directory search' | 'none';
16
+ export interface ProjectPathResolution {
17
+ /** Absolute project directory, or undefined if none could be determined. */
18
+ path: string | undefined;
19
+ /** Which strategy produced the path. */
20
+ source: ProjectPathSource;
21
+ }
22
+ /**
23
+ * Directory search fallback: a WinCC OA project is the directory that contains
24
+ * config/config. Walk upward from `startDir`.
25
+ *
26
+ * @param startDir - Directory to start in
27
+ * @returns The project directory, or undefined if no marker is found
28
+ */
29
+ export declare function findProjectDirUpward(startDir: string): string | undefined;
30
+ /**
31
+ * Resolve the WinCC OA project path and report where it came from.
32
+ *
33
+ * Order:
34
+ * 1. WINCCOA_PROJ_PATH environment variable (explicit override)
35
+ * 2. winccoa.getPaths()[0] - the manager API; the project path is always first
36
+ * 3. PVSS_II environment variable (<proj>/config/config), set in the manager process
37
+ * 4. Upward search from this module for a directory containing config/config
38
+ *
39
+ * Never throws.
40
+ *
41
+ * @param winccoa - WinCC OA manager instance (optional)
42
+ * @param startDir - Start directory for the upward search (defaults to this module's directory)
43
+ */
44
+ export declare function resolveProjectPathWithSource(winccoa?: unknown, startDir?: string): ProjectPathResolution;
45
+ /**
46
+ * Resolve the WinCC OA project path (see resolveProjectPathWithSource for the order).
47
+ *
48
+ * @param winccoa - WinCC OA manager instance (optional)
49
+ * @returns Absolute project directory, or undefined
50
+ */
51
+ export declare function resolveProjectPath(winccoa?: unknown): string | undefined;
52
+ //# sourceMappingURL=projectPath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projectPath.d.ts","sourceRoot":"","sources":["../../src/utils/projectPath.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,4DAA4D;AAC5D,MAAM,MAAM,iBAAiB,GACzB,mBAAmB,GACnB,oBAAoB,GACpB,SAAS,GACT,kBAAkB,GAClB,MAAM,CAAC;AAEX,MAAM,WAAW,qBAAqB;IACpC,4EAA4E;IAC5E,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,wCAAwC;IACxC,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAKD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAazE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,CAAC,EAAE,OAAO,EACjB,QAAQ,CAAC,EAAE,MAAM,GAChB,qBAAqB,CAwCvB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAExE"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * WinCC OA project path resolution.
3
+ *
4
+ * Tools that write into the project (custom dashboard icons under
5
+ * <proj>/data/WebUI/icons) need the project directory. It used to be derived by
6
+ * walking a fixed number of directories up from the compiled module, which is
7
+ * only right for one layout: a git clone inside <proj>/javascript/. It is wrong
8
+ * for the flat npm/zip layout (<proj>/javascript/mcpWinCCOA/...), for older zip
9
+ * layouts, and for symlinked development checkouts (Node resolves ESM modules
10
+ * through their real path), and it then pointed somewhere outside the project.
11
+ *
12
+ * The WinCC OA JavaScript manager knows the project path, so ask it first.
13
+ */
14
+ import { existsSync } from 'fs';
15
+ import { dirname, join, resolve } from 'path';
16
+ import { fileURLToPath } from 'url';
17
+ /** Upper bound for the upward directory search. */
18
+ const MAX_SEARCH_LEVELS = 10;
19
+ /**
20
+ * Directory search fallback: a WinCC OA project is the directory that contains
21
+ * config/config. Walk upward from `startDir`.
22
+ *
23
+ * @param startDir - Directory to start in
24
+ * @returns The project directory, or undefined if no marker is found
25
+ */
26
+ export function findProjectDirUpward(startDir) {
27
+ let current = resolve(startDir);
28
+ for (let i = 0; i <= MAX_SEARCH_LEVELS; i++) {
29
+ if (existsSync(join(current, 'config', 'config'))) {
30
+ return current;
31
+ }
32
+ const parent = dirname(current);
33
+ if (parent === current) {
34
+ break;
35
+ }
36
+ current = parent;
37
+ }
38
+ return undefined;
39
+ }
40
+ /**
41
+ * Resolve the WinCC OA project path and report where it came from.
42
+ *
43
+ * Order:
44
+ * 1. WINCCOA_PROJ_PATH environment variable (explicit override)
45
+ * 2. winccoa.getPaths()[0] - the manager API; the project path is always first
46
+ * 3. PVSS_II environment variable (<proj>/config/config), set in the manager process
47
+ * 4. Upward search from this module for a directory containing config/config
48
+ *
49
+ * Never throws.
50
+ *
51
+ * @param winccoa - WinCC OA manager instance (optional)
52
+ * @param startDir - Start directory for the upward search (defaults to this module's directory)
53
+ */
54
+ export function resolveProjectPathWithSource(winccoa, startDir) {
55
+ const fromEnv = process.env.WINCCOA_PROJ_PATH?.trim();
56
+ if (fromEnv) {
57
+ return { path: resolve(fromEnv), source: 'WINCCOA_PROJ_PATH' };
58
+ }
59
+ const getPaths = winccoa?.getPaths;
60
+ if (typeof getPaths === 'function') {
61
+ try {
62
+ const paths = getPaths.call(winccoa);
63
+ const first = paths?.[0];
64
+ if (typeof first === 'string' && first.trim().length > 0) {
65
+ return { path: first.trim(), source: 'winccoa.getPaths()' };
66
+ }
67
+ }
68
+ catch {
69
+ // Fall through to the next strategy.
70
+ }
71
+ }
72
+ const pvssII = process.env.PVSS_II?.trim();
73
+ if (pvssII) {
74
+ return { path: dirname(dirname(pvssII)), source: 'PVSS_II' };
75
+ }
76
+ let searchStart = startDir;
77
+ if (!searchStart) {
78
+ try {
79
+ searchStart = dirname(fileURLToPath(import.meta.url));
80
+ }
81
+ catch {
82
+ searchStart = undefined;
83
+ }
84
+ }
85
+ if (searchStart) {
86
+ const found = findProjectDirUpward(searchStart);
87
+ if (found) {
88
+ return { path: found, source: 'directory search' };
89
+ }
90
+ }
91
+ return { path: undefined, source: 'none' };
92
+ }
93
+ /**
94
+ * Resolve the WinCC OA project path (see resolveProjectPathWithSource for the order).
95
+ *
96
+ * @param winccoa - WinCC OA manager instance (optional)
97
+ * @returns Absolute project directory, or undefined
98
+ */
99
+ export function resolveProjectPath(winccoa) {
100
+ return resolveProjectPathWithSource(winccoa).path;
101
+ }
102
+ //# sourceMappingURL=projectPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projectPath.js","sourceRoot":"","sources":["../../src/utils/projectPath.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAiBpC,mDAAmD;AACnD,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,IAAI,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChC,KAAK,IAAI,CAAC,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OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAC/D,CAAC;IAED,IAAI,WAAW,GAAG,QAAQ,CAAC;IAC3B,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,IAAI,CAAC;YACH,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACxD,CAAC;QAAC,MAAM,CAAC;YACP,WAAW,GAAG,SAAS,CAAC;QAC1B,CAAC;IACH,CAAC;IACD,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,KAAK,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;QAChD,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC;QACrD,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAiB;IAClD,OAAO,4BAA4B,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC;AACpD,CAAC"}
package/manifest.cjs ADDED
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Builds the runtime manifest (package.json) that is written next to the flat
5
+ * server files, for both delivery paths:
6
+ *
7
+ * - npm install: postinstall.cjs writes it into the install directory
8
+ * - SIOS archive: zip.mjs writes it into the archive
9
+ *
10
+ * CommonJS so that postinstall.cjs can require() it and zip.mjs can load it via
11
+ * createRequire(). It is listed in the package.json "files" field because
12
+ * postinstall.cjs needs it inside the published npm package.
13
+ *
14
+ * The manifest exists only so that `npm install` in the flat directory pulls the
15
+ * runtime dependencies. Everything that refers to the repository/npm layout is
16
+ * removed:
17
+ *
18
+ * - scripts.postinstall: would run postinstall.cjs, which is not copied into
19
+ * the flat directory (and has nothing to do there).
20
+ * - build/test/release scripts: they need src/ and the dev toolchain.
21
+ * start / start:http are rewritten to the flat paths.
22
+ * - devDependencies: a finished build is shipped; keeps the installed set equal
23
+ * to what sbom.json (--omit dev) describes.
24
+ * - bin / files: describe the npm package layout (./build/...), not the flat one.
25
+ *
26
+ * "private": true guards against an accidental `npm publish` from the install
27
+ * directory. The published package.json itself is not affected.
28
+ *
29
+ * @param {Record<string, unknown>} source the package's own package.json
30
+ * @returns {Record<string, unknown>} the sanitized manifest
31
+ */
32
+ function buildRuntimeManifest(source) {
33
+ const {
34
+ scripts: _scripts,
35
+ devDependencies: _devDependencies,
36
+ bin: _bin,
37
+ files: _files,
38
+ ...rest
39
+ } = source;
40
+ return {
41
+ ...rest,
42
+ private: true,
43
+ scripts: {
44
+ start: 'node index_stdio.js',
45
+ 'start:http': 'node index_http.js'
46
+ }
47
+ };
48
+ }
49
+
50
+ module.exports = { buildRuntimeManifest };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etm-professional-control/winccoa-mcp-server",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "MCP Server for WinCC OA with field-specific configurations",
5
5
  "type": "module",
6
6
  "bin": {
@@ -27,6 +27,7 @@
27
27
  "src/systemprompt.md",
28
28
  "config",
29
29
  "postinstall.cjs",
30
+ "manifest.cjs",
30
31
  ".env.example",
31
32
  "sbom.json",
32
33
  "README.md",
@@ -53,16 +54,16 @@
53
54
  "url": "https://github.com/winccoa/winccoa-ae-js-mcpserver/issues"
54
55
  },
55
56
  "engines": {
56
- "node": ">=20.0.0"
57
+ "node": ">=24.0.0"
57
58
  },
58
59
  "dependencies": {
59
- "@modelcontextprotocol/sdk": "1.30.0",
60
+ "@modelcontextprotocol/sdk": "1.32.0",
60
61
  "cors": "2.8.6",
61
62
  "dotenv": "16.6.1",
62
63
  "express": "5.2.1",
63
64
  "express-rate-limit": "7.5.1",
64
- "mcp-remote": "0.1.37",
65
- "zod": "3.25.76"
65
+ "mcp-remote": "0.14.3",
66
+ "zod": "4.6.6"
66
67
  },
67
68
  "peerDependencies": {
68
69
  "winccoa-manager": "*"
@@ -75,7 +76,7 @@
75
76
  "devDependencies": {
76
77
  "@cyclonedx/cyclonedx-npm": "6.0.1",
77
78
  "@types/express": "5.0.6",
78
- "@types/node": "20.19.43",
79
+ "@types/node": "24.19.0",
79
80
  "@vitest/coverage-v8": "4.1.11",
80
81
  "typescript": "5.9.3",
81
82
  "vitest": "4.1.11"
package/postinstall.cjs CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
+ const { buildRuntimeManifest } = require('./manifest.cjs');
5
6
 
6
7
  // Get package info dynamically
7
8
  const packageJson = require('./package.json');
@@ -66,12 +67,17 @@ try {
66
67
  console.log('Copied systemprompt.md');
67
68
  }
68
69
 
69
- // Copy package.json
70
+ // Write a runtime package.json. The package's own manifest must NOT be copied
71
+ // verbatim: it still has the postinstall hook (postinstall.cjs is not copied, so
72
+ // a later `npm install` here would fail), build/-based bin and start entries,
73
+ // files and devDependencies. See manifest.cjs (shared with zip.mjs).
74
+ // Like the build files above, an existing package.json is overwritten.
70
75
  const packageJsonSrc = path.join(nodeModulesPath, 'package.json');
71
76
  const packageJsonDest = path.join(installDir, 'package.json');
72
77
  if (fs.existsSync(packageJsonSrc)) {
73
- fs.copyFileSync(packageJsonSrc, packageJsonDest);
74
- console.log('Copied package.json');
78
+ const runtimeManifest = buildRuntimeManifest(JSON.parse(fs.readFileSync(packageJsonSrc, 'utf8')));
79
+ fs.writeFileSync(packageJsonDest, JSON.stringify(runtimeManifest, null, 2) + '\n');
80
+ console.log('Wrote runtime package.json');
75
81
  }
76
82
 
77
83
 
@@ -116,7 +122,7 @@ try {
116
122
  console.log('\nNext steps:');
117
123
  console.log('1. Copy the environment file: cp .env.example .env');
118
124
  console.log('2. Edit .env with your configuration');
119
- console.log('3. Add JavaScript Manager in WinCC OA with script path: index_http.js');
125
+ console.log('3. Add JavaScript Manager in WinCC OA with script path: mcpWinCCOA/index_http.js (install into <OA_ProjPath>/javascript/mcpWinCCOA)');
120
126
 
121
127
  } else {
122
128
  console.error('Build directory not found in package');