@codesys/mcp-toolkit 1.4.3 → 1.4.5

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/CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.4.5] - 2025-05-02
9
+ ### Fixed
10
+ - Completely redesigned path handling for Windows paths
11
+ - Removed raw string (r'...') approach for more direct path handling
12
+ - Implemented path normalization using forward slashes for cross-platform compatibility
13
+ - Fixed create_project script to properly handle Windows paths in IronPython environment
14
+
15
+ ## [1.4.4] - 2025-05-02
16
+ ### Fixed
17
+ - Fixed "unexpected token 'C'" error in create_project script
18
+ - Improved Windows path handling in create_project.py with better logging and error detection
19
+ - Added additional debugging output for raw string path processing
20
+
8
21
  ## [1.4.3] - 2025-05-02
9
22
  ### Fixed
10
23
  - Fixed "Cannot import name redirect_stdout" error in session script execution
@@ -121,19 +121,14 @@ function interpolateScript(template, params) {
121
121
  let result = template;
122
122
  // Replace each parameter in the template
123
123
  for (const [key, value] of Object.entries(params)) {
124
- // Handle Windows paths specially
125
- let escapedValue;
126
- // Check if this looks like a Windows path
127
- if (typeof value === 'string' && (value.includes(':\\') || value.includes('\\'))) {
128
- // For Windows paths, use a different approach with raw strings
129
- console.error(`SCRIPT_LOADER: Detected Windows path: ${value}`);
130
- // Use Python raw string format to avoid backslash interpretation issues
131
- escapedValue = `r'${value.replace(/'/g, "\\'")}'`;
132
- console.error(`SCRIPT_LOADER: Converted to Python raw string: ${escapedValue}`);
133
- }
134
- else {
135
- // For non-path values, just escape backslashes normally
136
- escapedValue = String(value).replace(/\\/g, '\\\\');
124
+ // Get the escaped value, handling special characters
125
+ // Note: We've changed our approach to use forward slashes everywhere
126
+ // and handle the path normalization in each script instead of using r-strings
127
+ let escapedValue = String(value);
128
+ // If value has single quotes, escape them
129
+ if (escapedValue.includes("'")) {
130
+ escapedValue = escapedValue.replace(/'/g, "\\'");
131
+ console.error(`SCRIPT_LOADER: Escaped single quotes in value: ${escapedValue}`);
137
132
  }
138
133
  // Replace {PARAM_NAME} with the escaped value
139
134
  const paramPattern = new RegExp(`\\{${key}\\}`, 'g');
@@ -1,18 +1,13 @@
1
1
  import sys, scriptengine as script_engine, os, shutil, time, traceback
2
- # Placeholders - These might be Python raw strings (r'path') from the Node.js side
3
- # So we need to handle them specially
4
- TEMPLATE_PROJECT_PATH_RAW = '{TEMPLATE_PROJECT_PATH}' # Path to Standard.project
5
- PROJECT_FILE_PATH_RAW = '{PROJECT_FILE_PATH}' # Path for the new project (Target Path)
6
2
 
7
- # Process the paths - if they start with r' and end with ', extract the content
8
- def extract_path(path_str):
9
- if path_str.startswith("r'") and path_str.endswith("'"):
10
- # This is a raw string from Node.js - extract the content
11
- return path_str[2:-1]
12
- return path_str
3
+ # Direct path assignment - no more raw string handling
4
+ # Paths will be correctly escaped in the template substitution
5
+ TEMPLATE_PROJECT_PATH = '{TEMPLATE_PROJECT_PATH}'
6
+ PROJECT_FILE_PATH = '{PROJECT_FILE_PATH}'
13
7
 
14
- TEMPLATE_PROJECT_PATH = extract_path(TEMPLATE_PROJECT_PATH_RAW)
15
- PROJECT_FILE_PATH = extract_path(PROJECT_FILE_PATH_RAW)
8
+ # Print raw paths for debugging
9
+ print("DEBUG: Template path (raw): %s" % repr(TEMPLATE_PROJECT_PATH))
10
+ print("DEBUG: Project path (raw): %s" % repr(PROJECT_FILE_PATH))
16
11
 
17
12
  print("DEBUG: Processed TEMPLATE_PROJECT_PATH: %s" % TEMPLATE_PROJECT_PATH)
18
13
  print("DEBUG: Processed PROJECT_FILE_PATH: %s" % PROJECT_FILE_PATH)
package/dist/server.js CHANGED
@@ -372,9 +372,13 @@ function startMcpServer(config) {
372
372
  try {
373
373
  // Load script template and interpolate parameters
374
374
  const scriptTemplate = yield (0, scriptLoader_1.loadScriptTemplate)('create_project');
375
+ // Normalize paths for more consistent handling between platforms
376
+ const normalizedTargetPath = absPath.replace(/\\/g, '/');
377
+ const normalizedTemplatePath = templatePath.replace(/\\/g, '/');
378
+ console.error(`Using normalized paths for script: Target=${normalizedTargetPath}, Template=${normalizedTemplatePath}`);
375
379
  const scriptContent = (0, scriptLoader_1.interpolateScript)(scriptTemplate, {
376
- 'PROJECT_FILE_PATH': absPath.replace(/\\/g, '\\\\'),
377
- 'TEMPLATE_PROJECT_PATH': templatePath.replace(/\\/g, '\\\\')
380
+ 'PROJECT_FILE_PATH': normalizedTargetPath,
381
+ 'TEMPLATE_PROJECT_PATH': normalizedTemplatePath
378
382
  });
379
383
  console.error(">>> create_project (copy-then-open): PREPARED SCRIPT:", scriptContent.substring(0, 500) + "...");
380
384
  const result = yield (0, codesys_interop_1.executeCodesysScript)(scriptContent, codesysExePath, codesysProfileName, sessionManager);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codesys/mcp-toolkit",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "description": "Model Context Protocol (MCP) server for CODESYS automation platform",
5
5
  "main": "dist/server.js",
6
6
  "bin": {