@etm-professional-control/winccoa-mcp-server 1.4.0 → 1.5.1

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 (76) hide show
  1. package/.env.example +6 -2
  2. package/LEGAL_INFO.md +47 -0
  3. package/LICENSE.md +21 -0
  4. package/OSS.md +178 -0
  5. package/README.md +57 -6
  6. package/build/config/demo-project-instructions.md +28 -0
  7. package/build/config/server.config.d.ts +16 -1
  8. package/build/config/server.config.d.ts.map +1 -1
  9. package/build/config/server.config.js +60 -10
  10. package/build/config/server.config.js.map +1 -1
  11. package/build/fields/default.md +50 -0
  12. package/build/fields/oil.md +46 -0
  13. package/build/fields/transport.md +70 -0
  14. package/build/helpers/icons/IX_ICONS_LIST.txt +1407 -0
  15. package/build/helpers/icons/IconGenerator.d.ts +54 -3
  16. package/build/helpers/icons/IconGenerator.d.ts.map +1 -1
  17. package/build/helpers/icons/IconGenerator.js +104 -22
  18. package/build/helpers/icons/IconGenerator.js.map +1 -1
  19. package/build/helpers/icons/IconList.d.ts +17 -2
  20. package/build/helpers/icons/IconList.d.ts.map +1 -1
  21. package/build/helpers/icons/IconList.js +41 -19
  22. package/build/helpers/icons/IconList.js.map +1 -1
  23. package/build/helpers/pmon/PmonClient.d.ts.map +1 -1
  24. package/build/helpers/pmon/PmonClient.js +53 -27
  25. package/build/helpers/pmon/PmonClient.js.map +1 -1
  26. package/build/index_http.d.ts +14 -1
  27. package/build/index_http.d.ts.map +1 -1
  28. package/build/index_http.js +122 -45
  29. package/build/index_http.js.map +1 -1
  30. package/build/server.d.ts +37 -3
  31. package/build/server.d.ts.map +1 -1
  32. package/build/server.js +173 -122
  33. package/build/server.js.map +1 -1
  34. package/build/systemprompt.md +50 -0
  35. package/build/tool_loader.d.ts +21 -1
  36. package/build/tool_loader.d.ts.map +1 -1
  37. package/build/tool_loader.js +65 -10
  38. package/build/tool_loader.js.map +1 -1
  39. package/build/tools/archive/archive_query.d.ts.map +1 -1
  40. package/build/tools/archive/archive_query.js +2 -5
  41. package/build/tools/archive/archive_query.js.map +1 -1
  42. package/build/tools/common/common_query.d.ts.map +1 -1
  43. package/build/tools/common/common_query.js +51 -37
  44. package/build/tools/common/common_query.js.map +1 -1
  45. package/build/tools/dashboards/widget.d.ts.map +1 -1
  46. package/build/tools/dashboards/widget.js +12 -2
  47. package/build/tools/dashboards/widget.js.map +1 -1
  48. package/build/tools/datapoints/dp_basic.d.ts.map +1 -1
  49. package/build/tools/datapoints/dp_basic.js +106 -34
  50. package/build/tools/datapoints/dp_basic.js.map +1 -1
  51. package/build/tools/datapoints/dp_types.d.ts.map +1 -1
  52. package/build/tools/datapoints/dp_types.js +31 -10
  53. package/build/tools/datapoints/dp_types.js.map +1 -1
  54. package/build/tools/icons/icon.d.ts.map +1 -1
  55. package/build/tools/icons/icon.js +52 -7
  56. package/build/tools/icons/icon.js.map +1 -1
  57. package/build/tools/pv_range/pv_range_query.d.ts +12 -0
  58. package/build/tools/pv_range/pv_range_query.d.ts.map +1 -1
  59. package/build/tools/pv_range/pv_range_query.js +63 -31
  60. package/build/tools/pv_range/pv_range_query.js.map +1 -1
  61. package/build/utils/helpers.d.ts +56 -4
  62. package/build/utils/helpers.d.ts.map +1 -1
  63. package/build/utils/helpers.js +144 -14
  64. package/build/utils/helpers.js.map +1 -1
  65. package/build/utils/logger.d.ts +29 -0
  66. package/build/utils/logger.d.ts.map +1 -0
  67. package/build/utils/logger.js +56 -0
  68. package/build/utils/logger.js.map +1 -0
  69. package/build/utils/projectPath.d.ts +52 -0
  70. package/build/utils/projectPath.d.ts.map +1 -0
  71. package/build/utils/projectPath.js +102 -0
  72. package/build/utils/projectPath.js.map +1 -0
  73. package/manifest.cjs +50 -0
  74. package/package.json +84 -71
  75. package/postinstall.cjs +10 -4
  76. package/sbom.json +5500 -0
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Minimal level-based logger.
3
+ *
4
+ * The HTTP server previously logged a running commentary on every request,
5
+ * including request headers and the first 8 characters of both the presented and
6
+ * the expected API token. Anything reaching a WinCC OA manager log is readable by
7
+ * anyone with log access, so token material must never be written there, and the
8
+ * per-request commentary belongs behind a level.
9
+ *
10
+ * Controlled by MCP_LOG_LEVEL: debug | info | warn | error (default: info).
11
+ */
12
+ const LEVELS = {
13
+ debug: 10,
14
+ info: 20,
15
+ warn: 30,
16
+ error: 40
17
+ };
18
+ function resolveLevel() {
19
+ const raw = (process.env.MCP_LOG_LEVEL || 'info').toLowerCase();
20
+ return LEVELS[raw] ?? LEVELS.info;
21
+ }
22
+ /** Re-read on every call so tests and operators can change it without a restart. */
23
+ function enabled(level) {
24
+ return LEVELS[level] >= resolveLevel();
25
+ }
26
+ /** Verbose per-request tracing. Off unless MCP_LOG_LEVEL=debug. */
27
+ export function debug(...args) {
28
+ if (enabled('debug'))
29
+ console.log(...args);
30
+ }
31
+ /** Normal operational messages: startup, listening, tool registration. */
32
+ export function info(...args) {
33
+ if (enabled('info'))
34
+ console.log(...args);
35
+ }
36
+ export function warn(...args) {
37
+ if (enabled('warn'))
38
+ console.warn(...args);
39
+ }
40
+ export function error(...args) {
41
+ if (enabled('error'))
42
+ console.error(...args);
43
+ }
44
+ /**
45
+ * Describe a secret without disclosing any of it.
46
+ *
47
+ * Use this instead of `token.substring(0, 8)`: a prefix is still secret material,
48
+ * and for a short or low-entropy token it can be most of it.
49
+ *
50
+ * @param secret - The value to describe
51
+ * @returns "set (N chars)" or "not set"
52
+ */
53
+ export function describeSecret(secret) {
54
+ return secret ? `set (${secret.length} chars)` : 'not set';
55
+ }
56
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,MAAM,MAAM,GAA6B;IACvC,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,EAAE;CACV,CAAC;AAEF,SAAS,YAAY;IACnB,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;IAChE,OAAO,MAAM,CAAC,GAAe,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC;AAChD,CAAC;AAED,oFAAoF;AACpF,SAAS,OAAO,CAAC,KAAe;IAC9B,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,YAAY,EAAE,CAAC;AACzC,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,KAAK,CAAC,GAAG,IAAe;IACtC,IAAI,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,IAAI,CAAC,GAAG,IAAe;IACrC,IAAI,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,GAAG,IAAe;IACrC,IAAI,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,GAAG,IAAe;IACtC,IAAI,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,MAAiC;IAC9D,OAAO,MAAM,CAAC,CAAC,CAAC,QAAQ,MAAM,CAAC,MAAM,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7D,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":"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"}
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,71 +1,84 @@
1
- {
2
- "name": "@etm-professional-control/winccoa-mcp-server",
3
- "version": "1.4.0",
4
- "description": "MCP Server for WinCC OA with field-specific configurations",
5
- "type": "module",
6
- "bin": {
7
- "winccoa-mcp-stdio": "./build/index_stdio.js",
8
- "winccoa-mcp-http": "./build/index_http.js"
9
- },
10
- "scripts": {
11
- "build": "./build.sh",
12
- "postinstall": "node postinstall.cjs",
13
- "inspect": "npx @modelcontextprotocol/inspector",
14
- "start": "node build/index_stdio.js",
15
- "start:http": "node build/index_http.js",
16
- "dev": "tsc && npm start"
17
- },
18
- "keywords": [
19
- "mcp",
20
- "winccoa",
21
- "scada",
22
- "automation",
23
- "siemens",
24
- "industrial"
25
- ],
26
- "author": "ETM Control GesmbH",
27
- "license": "ISC",
28
- "repository": {
29
- "type": "git",
30
- "url": "git+https://github.com/winccoa/winccoa-ae-js-mcpserver.git"
31
- },
32
- "homepage": "https://github.com/winccoa/winccoa-ae-js-mcpserver#readme",
33
- "bugs": {
34
- "url": "https://github.com/winccoa/winccoa-ae-js-mcpserver/issues"
35
- },
36
- "engines": {
37
- "node": ">=18.0.0"
38
- },
39
- "dependencies": {
40
- "@modelcontextprotocol/sdk": "^1.25.3",
41
- "cors": "^2.8.5",
42
- "dotenv": "^16.4.5",
43
- "express": "^5.1.0",
44
- "express-rate-limit": "^7.1.5",
45
- "mcp-remote": "^0.1.13",
46
- "zod": "^3.25.51"
47
- },
48
- "peerDependencies": {
49
- "winccoa-manager": "*"
50
- },
51
- "peerDependenciesMeta": {
52
- "winccoa-manager": {
53
- "optional": true
54
- }
55
- },
56
- "devDependencies": {
57
- "@types/express": "^5.0.3",
58
- "@types/node": "^18.19.129",
59
- "typescript": "^5.8.3",
60
- "winccoa-manager": "file:C:/Program Files/Siemens/WinCC_OA/3.21/javascript/winccoa-manager"
61
- },
62
- "files": [
63
- "build",
64
- "src/fields",
65
- "config",
66
- "README.md",
67
- ".env.example",
68
- "postinstall.cjs",
69
- "src/systemprompt.md"
70
- ]
71
- }
1
+ {
2
+ "name": "@etm-professional-control/winccoa-mcp-server",
3
+ "version": "1.5.1",
4
+ "description": "MCP Server for WinCC OA with field-specific configurations",
5
+ "type": "module",
6
+ "bin": {
7
+ "winccoa-mcp-stdio": "./build/index_stdio.js",
8
+ "winccoa-mcp-http": "./build/index_http.js"
9
+ },
10
+ "scripts": {
11
+ "build": "node build.mjs",
12
+ "sbom": "cyclonedx-npm --package-lock-only --omit dev --omit peer --output-format JSON --output-file sbom.json",
13
+ "oss": "npm run sbom && node gen-oss.mjs",
14
+ "zip": "npm run build && node zip.mjs",
15
+ "postinstall": "node postinstall.cjs",
16
+ "inspect": "npx @modelcontextprotocol/inspector",
17
+ "start": "node build/index_stdio.js",
18
+ "start:http": "node build/index_http.js",
19
+ "dev": "npm run build && npm start",
20
+ "test": "vitest run",
21
+ "test:watch": "vitest",
22
+ "test:coverage": "vitest run --coverage"
23
+ },
24
+ "files": [
25
+ "build",
26
+ "src/fields",
27
+ "src/systemprompt.md",
28
+ "config",
29
+ "postinstall.cjs",
30
+ "manifest.cjs",
31
+ ".env.example",
32
+ "sbom.json",
33
+ "README.md",
34
+ "OSS.md",
35
+ "LEGAL_INFO.md",
36
+ "LICENSE.md"
37
+ ],
38
+ "keywords": [
39
+ "mcp",
40
+ "winccoa",
41
+ "scada",
42
+ "automation",
43
+ "siemens",
44
+ "industrial"
45
+ ],
46
+ "author": "ETM Control GesmbH",
47
+ "license": "ISC",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/winccoa/winccoa-ae-js-mcpserver.git"
51
+ },
52
+ "homepage": "https://github.com/winccoa/winccoa-ae-js-mcpserver#readme",
53
+ "bugs": {
54
+ "url": "https://github.com/winccoa/winccoa-ae-js-mcpserver/issues"
55
+ },
56
+ "engines": {
57
+ "node": ">=24.0.0"
58
+ },
59
+ "dependencies": {
60
+ "@modelcontextprotocol/sdk": "1.30.0",
61
+ "cors": "2.8.6",
62
+ "dotenv": "16.6.1",
63
+ "express": "5.2.1",
64
+ "express-rate-limit": "7.5.1",
65
+ "mcp-remote": "0.14.3",
66
+ "zod": "3.25.76"
67
+ },
68
+ "peerDependencies": {
69
+ "winccoa-manager": "*"
70
+ },
71
+ "peerDependenciesMeta": {
72
+ "winccoa-manager": {
73
+ "optional": true
74
+ }
75
+ },
76
+ "devDependencies": {
77
+ "@cyclonedx/cyclonedx-npm": "6.0.1",
78
+ "@types/express": "5.0.6",
79
+ "@types/node": "24.19.0",
80
+ "@vitest/coverage-v8": "4.1.11",
81
+ "typescript": "5.9.3",
82
+ "vitest": "4.1.11"
83
+ }
84
+ }
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');