@codesys/mcp-toolkit 1.1.4 → 1.1.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.
@@ -0,0 +1,13 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "WebFetch(domain:github.com)",
5
+ "Bash(git add:*)",
6
+ "Bash(git commit:*)",
7
+ "Bash(grep:*)",
8
+ "Bash(npm run build:*)",
9
+ "Bash(ls:*)"
10
+ ],
11
+ "deny": []
12
+ }
13
+ }
package/CHANGELOG.md CHANGED
@@ -1,26 +1,38 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [1.0.0] - 2025-04-23
9
-
10
- ### Added
11
- - Initial release of the MCP server for CODESYS
12
- - Command-line interface with configuration options
13
- - Project management functionality:
14
- - Opening existing CODESYS projects
15
- - Creating new CODESYS projects
16
- - Saving projects
17
- - POU (Program Organization Unit) management:
18
- - Creating POUs (Programs, Function Blocks, Functions)
19
- - Setting POU code (declaration and implementation)
20
- - Creating properties and methods for Function Blocks
21
- - Project compilation support
22
- - Resources for querying:
23
- - Project status
24
- - Project structure
25
- - POU code
26
- - Documentation for installation and usage
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.1.5] - 2025-05-06
9
+
10
+ ### Fixed
11
+ - Bug that prevented creating POUs in new projects due to path resolution issues
12
+ - Enhanced path resolution to better handle "Application" paths in both new and existing projects
13
+ - Fixed TypeScript build error by updating McpServer method from start() to connect()
14
+
15
+ ## [1.1.4] - 2025-04-30
16
+
17
+ ### Changed
18
+ - Refactored the code for better maintainability
19
+
20
+ ## [1.0.0] - 2025-04-23
21
+
22
+ ### Added
23
+ - Initial release of the MCP server for CODESYS
24
+ - Command-line interface with configuration options
25
+ - Project management functionality:
26
+ - Opening existing CODESYS projects
27
+ - Creating new CODESYS projects
28
+ - Saving projects
29
+ - POU (Program Organization Unit) management:
30
+ - Creating POUs (Programs, Function Blocks, Functions)
31
+ - Setting POU code (declaration and implementation)
32
+ - Creating properties and methods for Function Blocks
33
+ - Project compilation support
34
+ - Resources for querying:
35
+ - Project status
36
+ - Project structure
37
+ - POU code
38
+ - Documentation for installation and usage
package/CONTRIBUTING.md CHANGED
@@ -1,72 +1,72 @@
1
- # Contributing to @codesys/mcp-toolkit
2
-
3
- Thank you for considering contributing to the CODESYS MCP Toolkit! This document provides guidelines and steps for contributing.
4
-
5
- ## Code of Conduct
6
-
7
- Please be respectful and considerate of others when contributing to this project. We aim to foster an inclusive and welcoming community.
8
-
9
- ## How Can I Contribute?
10
-
11
- ### Reporting Bugs
12
-
13
- Bug reports help improve the project! When reporting bugs:
14
-
15
- 1. Check if the bug has already been reported
16
- 2. Use the bug report template
17
- 3. Include detailed steps to reproduce the issue
18
- 4. Describe the expected vs. actual behavior
19
- 5. Include screenshots if applicable
20
- 6. Provide environment details (OS, Node.js version, etc.)
21
-
22
- ### Suggesting Features
23
-
24
- We welcome feature suggestions! When suggesting features:
25
-
26
- 1. Describe the problem your feature would solve
27
- 2. Explain how your feature would work
28
- 3. Consider potential alternatives
29
- 4. Provide examples of similar features in other projects (if applicable)
30
-
31
- ### Pull Requests
32
-
33
- 1. Fork the repository
34
- 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
35
- 3. Make your changes
36
- 4. Run tests and ensure they pass
37
- 5. Commit your changes (`git commit -m 'Add amazing feature'`)
38
- 6. Push to your branch (`git push origin feature/amazing-feature`)
39
- 7. Open a Pull Request
40
-
41
- ## Development Setup
42
-
43
- 1. Clone the repository
44
- ```bash
45
- git clone https://github.com/yourusername/codesys-mcp-toolkit.git
46
- cd codesys-mcp-toolkit
47
- ```
48
-
49
- 2. Install dependencies
50
- ```bash
51
- npm install
52
- ```
53
-
54
- 3. Build the project
55
- ```bash
56
- npm run build
57
- ```
58
-
59
- ## Style Guidelines
60
-
61
- - Follow existing code formatting patterns
62
- - Use meaningful variable and function names
63
- - Add comments where necessary to explain complex logic
64
- - Update documentation when changing functionality
65
-
66
- ## Testing
67
-
68
- - Add tests for new features
69
- - Ensure all tests pass before submitting a PR
70
- - Consider edge cases in your tests
71
-
72
- Thank you for contributing!
1
+ # Contributing to @codesys/mcp-toolkit
2
+
3
+ Thank you for considering contributing to the CODESYS MCP Toolkit! This document provides guidelines and steps for contributing.
4
+
5
+ ## Code of Conduct
6
+
7
+ Please be respectful and considerate of others when contributing to this project. We aim to foster an inclusive and welcoming community.
8
+
9
+ ## How Can I Contribute?
10
+
11
+ ### Reporting Bugs
12
+
13
+ Bug reports help improve the project! When reporting bugs:
14
+
15
+ 1. Check if the bug has already been reported
16
+ 2. Use the bug report template
17
+ 3. Include detailed steps to reproduce the issue
18
+ 4. Describe the expected vs. actual behavior
19
+ 5. Include screenshots if applicable
20
+ 6. Provide environment details (OS, Node.js version, etc.)
21
+
22
+ ### Suggesting Features
23
+
24
+ We welcome feature suggestions! When suggesting features:
25
+
26
+ 1. Describe the problem your feature would solve
27
+ 2. Explain how your feature would work
28
+ 3. Consider potential alternatives
29
+ 4. Provide examples of similar features in other projects (if applicable)
30
+
31
+ ### Pull Requests
32
+
33
+ 1. Fork the repository
34
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
35
+ 3. Make your changes
36
+ 4. Run tests and ensure they pass
37
+ 5. Commit your changes (`git commit -m 'Add amazing feature'`)
38
+ 6. Push to your branch (`git push origin feature/amazing-feature`)
39
+ 7. Open a Pull Request
40
+
41
+ ## Development Setup
42
+
43
+ 1. Clone the repository
44
+ ```bash
45
+ git clone https://github.com/yourusername/codesys-mcp-toolkit.git
46
+ cd codesys-mcp-toolkit
47
+ ```
48
+
49
+ 2. Install dependencies
50
+ ```bash
51
+ npm install
52
+ ```
53
+
54
+ 3. Build the project
55
+ ```bash
56
+ npm run build
57
+ ```
58
+
59
+ ## Style Guidelines
60
+
61
+ - Follow existing code formatting patterns
62
+ - Use meaningful variable and function names
63
+ - Add comments where necessary to explain complex logic
64
+ - Update documentation when changing functionality
65
+
66
+ ## Testing
67
+
68
+ - Add tests for new features
69
+ - Ensure all tests pass before submitting a PR
70
+ - Consider edge cases in your tests
71
+
72
+ Thank you for contributing!
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 CODESYS MCP Server Contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 CODESYS MCP Server Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,145 +1,145 @@
1
-
2
- # @codesys/mcp-toolkit
3
-
4
- ![npm](https://img.shields.io/npm/v/@codesys/mcp-toolkit)
5
- ![License](https://img.shields.io/github/license/johannesPettersson80/codesys-mcp-toolkit)
6
- ![Node Version](https://img.shields.io/node/v/@codesys/mcp-toolkit)
7
-
8
- A Model Context Protocol (MCP) server for CODESYS V3 programming environments. This toolkit enables seamless interaction between MCP clients (like Claude Desktop) and CODESYS, allowing automation of project management, POU creation, code editing, and compilation tasks via the CODESYS Scripting Engine.
9
-
10
- ## 🌟 Features
11
-
12
- - **Project Management**
13
- - Open existing CODESYS projects (`open_project`)
14
- - Create new projects from standard templates (`create_project`)
15
- - Save project changes (`save_project`)
16
-
17
- - **POU Management**
18
- - Create Programs, Function Blocks, and Functions (`create_pou`)
19
- - Set declaration and implementation code (`set_pou_code`)
20
- - Create properties for Function Blocks (`create_property`)
21
- - Create methods for Function Blocks (`create_method`)
22
- - Compile projects (`compile_project`)
23
-
24
- - **MCP Resources**
25
- - `codesys://project/status`: Check scripting status and currently open project state.
26
- - `codesys://project/{+project_path}/structure`: Retrieve the object structure of a specified project.
27
- - `codesys://project/{+project_path}/pou/{+pou_path}/code`: Read the declaration and implementation code for a specified POU, Method, or Property accessor.
28
-
29
- ## 📋 Prerequisites
30
-
31
- - **CODESYS V3**: A working CODESYS V3 installation (tested with 3.5 SP21) with the **Scripting Engine** component enabled during installation.
32
- - **Node.js**: Version 18.0.0 or later is recommended.
33
- - **MCP Client**: An MCP-enabled application (e.g., Claude Desktop).
34
-
35
- *(Note: CODESYS uses Python 2.7 internally for its scripting engine, but this toolkit handles the interaction; you do not need to manage Python separately.)*
36
-
37
- ## 🚀 Installation
38
-
39
- The recommended way to install is globally using npm:
40
-
41
- ```bash
42
- npm install -g @codesys/mcp-toolkit
43
- ```
44
-
45
- This installs the package globally, making the `codesys-mcp-tool` command available in your system's terminal PATH.
46
-
47
- *(Advanced users can also install from source for development - see CONTRIBUTING.md if available).*
48
-
49
- ## 🔧 Configuration (IMPORTANT!)
50
-
51
- This toolkit needs to know where your CODESYS installation is and which profile to use. Configuration is typically done within your MCP Client application (like Claude Desktop).
52
-
53
- ### Recommended Configuration Method (Direct Command)
54
-
55
- Due to potential environment variable issues (especially with `PATH`) when launching Node.js tools via wrappers like `npx` within certain host applications (e.g., Claude Desktop), it is **strongly recommended** to configure your MCP client to run the installed command `codesys-mcp-tool` **directly**.
56
-
57
- **Example for Claude Desktop (`settings.json` -> `mcpServers`):**
58
-
59
- ```json
60
- {
61
- "mcpServers": {
62
- // ... other servers ...
63
- "codesys_local": {
64
- "command": "codesys-mcp-tool", // <<< Use the direct command name
65
- "args": [
66
- // Pass arguments directly to the tool using flags
67
- "--codesys-path", "C:\\Program Files\\Path\\To\\Your\\CODESYS\\Common\\CODESYS.exe",
68
- "--codesys-profile", "Your CODESYS Profile Name"
69
- // Optional: Add --workspace "/path/to/your/projects" if needed
70
- ]
71
- }
72
- // ... other servers ...
73
- }
74
- }
75
- ```
76
-
77
- **Key Steps:**
78
- 1. Replace `"C:\\Program Files\\Path\\To\\Your\\CODESYS\\Common\\CODESYS.exe"` with the **full, correct path** to your specific `CODESYS.exe` file.
79
- 2. Replace `"Your CODESYS Profile Name"` with the **exact name** of the CODESYS profile you want to use (visible in the CODESYS UI).
80
- 3. Ensure the `codesys-mcp-tool` command is accessible in the system PATH where the MCP Client application runs. Global installation via `npm install -g` usually handles this.
81
- 4. Restart your MCP Client application (e.g., Claude Desktop) to apply the settings changes.
82
-
83
- ### Alternative Configuration (Using `npx` - Not Recommended)
84
-
85
- Launching with `npx` has been observed to cause immediate errors (`'C:\Program' is not recognized...`) in some environments, likely due to how `npx` handles the execution environment. **Use the Direct Command method above if possible.** If you must use `npx`:
86
-
87
- ```json
88
- // Example using npx (POTENTIALLY PROBLEMATIC - USE WITH CAUTION):
89
- {
90
- "mcpServers": {
91
- "codesys_local": {
92
- "command": "npx",
93
- "args": [
94
- "-y", // Tells npx to install temporarily if not found globally
95
- "@codesys/mcp-toolkit",
96
- // Arguments for the tool MUST come AFTER the package name
97
- "--codesys-path", "C:\\Program Files\\Path\\To\\Your\\CODESYS\\Common\\CODESYS.exe",
98
- "--codesys-profile", "Your CODESYS Profile Name"
99
- ]
100
- }
101
- }
102
- }
103
- ```
104
- *(Note: The `--` separator after the package name might sometimes help `npx` but is not guaranteed to fix the environment issue.)*
105
-
106
- ## 🛠️ Command-Line Arguments
107
-
108
- When running `codesys-mcp-tool` directly or configuring it, you can use these arguments:
109
-
110
- * `-p, --codesys-path <path>`: Full path to `CODESYS.exe`. (Required, overrides `CODESYS_PATH` env var, has a default but relying on it is not recommended).
111
- * `-f, --codesys-profile <profile>`: Name of the CODESYS profile. (Required, overrides `CODESYS_PROFILE` env var, has a default but relying on it is not recommended).
112
- * `-w, --workspace <dir>`: Workspace directory for resolving relative project paths passed to tools. Defaults to the directory where the command was launched (which might be unpredictable when run by another application). Setting this explicitly might be needed if using relative paths.
113
- * `-h, --help`: Show help message.
114
- * `--version`: Show package version.
115
-
116
- ## 🔍 Troubleshooting
117
-
118
- * **`'C:\Program' is not recognized...` error immediately after connection:**
119
- * **Cause:** This typically happens when the tool is launched via `npx` within an environment like Claude Desktop. The execution environment (`PATH` variable) provided to the process likely causes an internal CODESYS command (like running Python) to fail.
120
- * **Solution:** Configure your MCP Client to run the command **directly** (`"command": "codesys-mcp-tool"`) instead of using `"command": "npx"`. See the **Recommended Configuration Method** section above.
121
-
122
- * **Tool Fails / Errors in Output:**
123
- * Check the logs from your MCP Client application (e.g., Claude Desktop logs). Look for `INTEROP:` messages or Python `DEBUG:` / `ERROR:` messages printed to stderr from the CODESYS script execution.
124
- * Ensure the `--codesys-path` and `--codesys-profile` arguments passed to the command are correct and point to a valid CODESYS installation with scripting enabled.
125
- * Verify the project paths and object paths you are passing to tools are correct (use forward slashes `/`).
126
- * Make sure no other CODESYS instances are running in conflicting ways (e.g., holding a lock on the profile).
127
-
128
- * **`command not found: codesys-mcp-tool`:**
129
- * Ensure the package was installed globally (`npm install -g @codesys/mcp-toolkit`).
130
- * Ensure the npm global bin directory is in your system's `PATH` environment variable. Find it with `npm config get prefix` and add the `bin` subdirectory (or the main directory itself on Windows) to your PATH.
131
-
132
- * **Check Logs:**
133
- * Claude Desktop logs: `C:\Users\<YourUsername>\AppData\Roaming\Claude\logs\` (Windows)
134
-
135
- ## 🤝 Contributing
136
- Contributions, issues, and feature requests are welcome! Feel free to check the issues page. (Optionally add a CONTRIBUTING.md file with more details).
137
-
138
- ## 📝 License
139
- This project is licensed under the MIT License - see the LICENSE file for details.
140
-
141
- ## 🙏 Acknowledgements
142
- - The CODESYS GmbH team for the powerful CODESYS platform and its scripting engine.
143
- - The Model Context Protocol project for defining the interaction standard.
144
- - All contributors and users who help improve this toolkit.
145
-
1
+
2
+ # @codesys/mcp-toolkit
3
+
4
+ ![npm](https://img.shields.io/npm/v/@codesys/mcp-toolkit)
5
+ ![License](https://img.shields.io/github/license/johannesPettersson80/codesys-mcp-toolkit)
6
+ ![Node Version](https://img.shields.io/node/v/@codesys/mcp-toolkit)
7
+
8
+ A Model Context Protocol (MCP) server for CODESYS V3 programming environments. This toolkit enables seamless interaction between MCP clients (like Claude Desktop) and CODESYS, allowing automation of project management, POU creation, code editing, and compilation tasks via the CODESYS Scripting Engine.
9
+
10
+ ## 🌟 Features
11
+
12
+ - **Project Management**
13
+ - Open existing CODESYS projects (`open_project`)
14
+ - Create new projects from standard templates (`create_project`)
15
+ - Save project changes (`save_project`)
16
+
17
+ - **POU Management**
18
+ - Create Programs, Function Blocks, and Functions (`create_pou`)
19
+ - Set declaration and implementation code (`set_pou_code`)
20
+ - Create properties for Function Blocks (`create_property`)
21
+ - Create methods for Function Blocks (`create_method`)
22
+ - Compile projects (`compile_project`)
23
+
24
+ - **MCP Resources**
25
+ - `codesys://project/status`: Check scripting status and currently open project state.
26
+ - `codesys://project/{+project_path}/structure`: Retrieve the object structure of a specified project.
27
+ - `codesys://project/{+project_path}/pou/{+pou_path}/code`: Read the declaration and implementation code for a specified POU, Method, or Property accessor.
28
+
29
+ ## 📋 Prerequisites
30
+
31
+ - **CODESYS V3**: A working CODESYS V3 installation (tested with 3.5 SP21) with the **Scripting Engine** component enabled during installation.
32
+ - **Node.js**: Version 18.0.0 or later is recommended.
33
+ - **MCP Client**: An MCP-enabled application (e.g., Claude Desktop).
34
+
35
+ *(Note: CODESYS uses Python 2.7 internally for its scripting engine, but this toolkit handles the interaction; you do not need to manage Python separately.)*
36
+
37
+ ## 🚀 Installation
38
+
39
+ The recommended way to install is globally using npm:
40
+
41
+ ```bash
42
+ npm install -g @codesys/mcp-toolkit
43
+ ```
44
+
45
+ This installs the package globally, making the `codesys-mcp-tool` command available in your system's terminal PATH.
46
+
47
+ *(Advanced users can also install from source for development - see CONTRIBUTING.md if available).*
48
+
49
+ ## 🔧 Configuration (IMPORTANT!)
50
+
51
+ This toolkit needs to know where your CODESYS installation is and which profile to use. Configuration is typically done within your MCP Client application (like Claude Desktop).
52
+
53
+ ### Recommended Configuration Method (Direct Command)
54
+
55
+ Due to potential environment variable issues (especially with `PATH`) when launching Node.js tools via wrappers like `npx` within certain host applications (e.g., Claude Desktop), it is **strongly recommended** to configure your MCP client to run the installed command `codesys-mcp-tool` **directly**.
56
+
57
+ **Example for Claude Desktop (`settings.json` -> `mcpServers`):**
58
+
59
+ ```json
60
+ {
61
+ "mcpServers": {
62
+ // ... other servers ...
63
+ "codesys_local": {
64
+ "command": "codesys-mcp-tool", // <<< Use the direct command name
65
+ "args": [
66
+ // Pass arguments directly to the tool using flags
67
+ "--codesys-path", "C:\\Program Files\\Path\\To\\Your\\CODESYS\\Common\\CODESYS.exe",
68
+ "--codesys-profile", "Your CODESYS Profile Name"
69
+ // Optional: Add --workspace "/path/to/your/projects" if needed
70
+ ]
71
+ }
72
+ // ... other servers ...
73
+ }
74
+ }
75
+ ```
76
+
77
+ **Key Steps:**
78
+ 1. Replace `"C:\\Program Files\\Path\\To\\Your\\CODESYS\\Common\\CODESYS.exe"` with the **full, correct path** to your specific `CODESYS.exe` file.
79
+ 2. Replace `"Your CODESYS Profile Name"` with the **exact name** of the CODESYS profile you want to use (visible in the CODESYS UI).
80
+ 3. Ensure the `codesys-mcp-tool` command is accessible in the system PATH where the MCP Client application runs. Global installation via `npm install -g` usually handles this.
81
+ 4. Restart your MCP Client application (e.g., Claude Desktop) to apply the settings changes.
82
+
83
+ ### Alternative Configuration (Using `npx` - Not Recommended)
84
+
85
+ Launching with `npx` has been observed to cause immediate errors (`'C:\Program' is not recognized...`) in some environments, likely due to how `npx` handles the execution environment. **Use the Direct Command method above if possible.** If you must use `npx`:
86
+
87
+ ```json
88
+ // Example using npx (POTENTIALLY PROBLEMATIC - USE WITH CAUTION):
89
+ {
90
+ "mcpServers": {
91
+ "codesys_local": {
92
+ "command": "npx",
93
+ "args": [
94
+ "-y", // Tells npx to install temporarily if not found globally
95
+ "@codesys/mcp-toolkit",
96
+ // Arguments for the tool MUST come AFTER the package name
97
+ "--codesys-path", "C:\\Program Files\\Path\\To\\Your\\CODESYS\\Common\\CODESYS.exe",
98
+ "--codesys-profile", "Your CODESYS Profile Name"
99
+ ]
100
+ }
101
+ }
102
+ }
103
+ ```
104
+ *(Note: The `--` separator after the package name might sometimes help `npx` but is not guaranteed to fix the environment issue.)*
105
+
106
+ ## 🛠️ Command-Line Arguments
107
+
108
+ When running `codesys-mcp-tool` directly or configuring it, you can use these arguments:
109
+
110
+ * `-p, --codesys-path <path>`: Full path to `CODESYS.exe`. (Required, overrides `CODESYS_PATH` env var, has a default but relying on it is not recommended).
111
+ * `-f, --codesys-profile <profile>`: Name of the CODESYS profile. (Required, overrides `CODESYS_PROFILE` env var, has a default but relying on it is not recommended).
112
+ * `-w, --workspace <dir>`: Workspace directory for resolving relative project paths passed to tools. Defaults to the directory where the command was launched (which might be unpredictable when run by another application). Setting this explicitly might be needed if using relative paths.
113
+ * `-h, --help`: Show help message.
114
+ * `--version`: Show package version.
115
+
116
+ ## 🔍 Troubleshooting
117
+
118
+ * **`'C:\Program' is not recognized...` error immediately after connection:**
119
+ * **Cause:** This typically happens when the tool is launched via `npx` within an environment like Claude Desktop. The execution environment (`PATH` variable) provided to the process likely causes an internal CODESYS command (like running Python) to fail.
120
+ * **Solution:** Configure your MCP Client to run the command **directly** (`"command": "codesys-mcp-tool"`) instead of using `"command": "npx"`. See the **Recommended Configuration Method** section above.
121
+
122
+ * **Tool Fails / Errors in Output:**
123
+ * Check the logs from your MCP Client application (e.g., Claude Desktop logs). Look for `INTEROP:` messages or Python `DEBUG:` / `ERROR:` messages printed to stderr from the CODESYS script execution.
124
+ * Ensure the `--codesys-path` and `--codesys-profile` arguments passed to the command are correct and point to a valid CODESYS installation with scripting enabled.
125
+ * Verify the project paths and object paths you are passing to tools are correct (use forward slashes `/`).
126
+ * Make sure no other CODESYS instances are running in conflicting ways (e.g., holding a lock on the profile).
127
+
128
+ * **`command not found: codesys-mcp-tool`:**
129
+ * Ensure the package was installed globally (`npm install -g @codesys/mcp-toolkit`).
130
+ * Ensure the npm global bin directory is in your system's `PATH` environment variable. Find it with `npm config get prefix` and add the `bin` subdirectory (or the main directory itself on Windows) to your PATH.
131
+
132
+ * **Check Logs:**
133
+ * Claude Desktop logs: `C:\Users\<YourUsername>\AppData\Roaming\Claude\logs\` (Windows)
134
+
135
+ ## 🤝 Contributing
136
+ Contributions, issues, and feature requests are welcome! Feel free to check the issues page. (Optionally add a CONTRIBUTING.md file with more details).
137
+
138
+ ## 📝 License
139
+ This project is licensed under the MIT License - see the LICENSE file for details.
140
+
141
+ ## 🙏 Acknowledgements
142
+ - The CODESYS GmbH team for the powerful CODESYS platform and its scripting engine.
143
+ - The Model Context Protocol project for defining the interaction standard.
144
+ - All contributors and users who help improve this toolkit.
145
+