@etm-professional-control/winccoa-mcp-server 1.5.3 → 1.5.4

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/README.md CHANGED
@@ -81,6 +81,22 @@ Then install the required packages:
81
81
  npm install @etm-professional-control/winccoa-mcp-server
82
82
  ```
83
83
 
84
+ Run the setup step to copy the server files into the project directory:
85
+
86
+ ```bash
87
+ npx winccoa-mcp-install
88
+ ```
89
+
90
+ **npm 12 and later do not run install scripts by default**, so this step is required there; on older npm
91
+ the files are copied automatically and running it again is harmless (it keeps your `.env`, `systemprompt.md` and
92
+ any edited files in `fields/`). Alternatively, approve the package's install script once and re-install:
93
+
94
+ ```bash
95
+ npm install-scripts approve @etm-professional-control/winccoa-mcp-server
96
+ ```
97
+
98
+ (or allow it through the `allowScripts` setting in your npm configuration).
99
+
84
100
  Install the WinCC OA JavaScript Manager package from your local WinCC OA installation. The path depends on your WinCC OA version and installation:
85
101
 
86
102
  **WinCC OA 3.20** (default path):
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@etm-professional-control/winccoa-mcp-server",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "description": "MCP Server for WinCC OA with field-specific configurations",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "winccoa-mcp-stdio": "./build/index_stdio.js",
8
- "winccoa-mcp-http": "./build/index_http.js"
8
+ "winccoa-mcp-http": "./build/index_http.js",
9
+ "winccoa-mcp-install": "./postinstall.cjs"
9
10
  },
10
11
  "scripts": {
11
12
  "build": "node build.mjs",
package/postinstall.cjs CHANGED
@@ -8,14 +8,25 @@ const { buildRuntimeManifest } = require('./manifest.cjs');
8
8
  const packageJson = require('./package.json');
9
9
  const packageName = packageJson.name;
10
10
 
11
- // Determine the installation directory (where npm install was run)
12
- const installDir = process.env.INIT_CWD || process.cwd();
13
- const nodeModulesPath = path.join(installDir, 'node_modules', packageName);
11
+ // The package root is where this script lives. It is inside a node_modules folder
12
+ // whenever the package was installed (also hoisted or with a non-default layout);
13
+ // in a repository checkout it is not.
14
+ const packageRoot = __dirname;
15
+ const isInstalledPackage = packageRoot.split(path.sep).includes('node_modules');
16
+
17
+ // Two entry points share this script:
18
+ // - npm "postinstall" lifecycle (npm 11 and older): INIT_CWD is the directory where
19
+ // `npm install` was run, process.cwd() is the package folder itself.
20
+ // - the "winccoa-mcp-install" bin (`npx winccoa-mcp-install`, required on npm 12+,
21
+ // where install scripts are opt-in): the user's project directory is process.cwd().
22
+ const isLifecycle = process.env.npm_lifecycle_event === 'postinstall';
23
+ const installDir = path.resolve(isLifecycle ? (process.env.INIT_CWD || process.cwd()) : process.cwd());
24
+ const nodeModulesPath = packageRoot;
14
25
  const srcPath = path.join(nodeModulesPath, 'src');
15
26
 
16
- // Skip postinstall if running inside the package itself (development mode)
17
- // Check if we're in the package directory by comparing with process.cwd()
18
- const isDevMode = !fs.existsSync(nodeModulesPath) || process.cwd() === installDir;
27
+ // Skip when running inside the repository itself (development mode): the package is not
28
+ // installed under node_modules, or the target would be the package folder itself.
29
+ const isDevMode = !isInstalledPackage || installDir === path.resolve(packageRoot);
19
30
 
20
31
  if (isDevMode) {
21
32
  console.log('Development mode detected - skipping postinstall.');
@@ -38,6 +49,12 @@ try {
38
49
  const srcPath = path.join(buildDir, file.name);
39
50
  const destPath = path.join(installDir, file.name);
40
51
 
52
+ // User-owned files: never overwrite on a re-run. fields/ is handled below
53
+ // (per file, existing files are kept).
54
+ if (file.name === 'fields' || ((file.name === '.env' || file.name === 'systemprompt.md') && fs.existsSync(destPath))) {
55
+ continue;
56
+ }
57
+
41
58
  if (file.isDirectory()) {
42
59
  // Copy directory recursively
43
60
  fs.cpSync(srcPath, destPath, { recursive: true });
@@ -119,6 +136,7 @@ try {
119
136
 
120
137
 
121
138
  console.log('\n✅ Installation complete!');
139
+ console.log('(Safe to re-run: npx winccoa-mcp-install. Needed on npm 12+, where install scripts are opt-in.)');
122
140
  console.log('\nNext steps:');
123
141
  console.log('1. Copy the environment file: cp .env.example .env');
124
142
  console.log('2. Edit .env with your configuration');
@@ -130,6 +148,6 @@ try {
130
148
  }
131
149
 
132
150
  } catch (error) {
133
- console.error('Error during postinstall:', error.message);
151
+ console.error('Error during setup:', error.message);
134
152
  process.exit(1);
135
153
  }