@codesys/mcp-toolkit 1.5.7 → 2.0.0-alpha.0
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 +153 -183
- package/LICENSE +21 -21
- package/README.md +224 -107
- package/dist/actions.d.ts +28 -0
- package/dist/actions.js +98 -0
- package/dist/actions.js.map +1 -0
- package/dist/bridge/bridge.d.ts +105 -0
- package/dist/bridge/bridge.js +400 -0
- package/dist/bridge/bridge.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +196 -0
- package/dist/cli.js.map +1 -0
- package/dist/codesys/cache.d.ts +48 -0
- package/dist/codesys/cache.js +82 -0
- package/dist/codesys/cache.js.map +1 -0
- package/dist/codesys/changes.d.ts +57 -0
- package/dist/codesys/changes.js +133 -0
- package/dist/codesys/changes.js.map +1 -0
- package/dist/codesys/decl.d.ts +45 -0
- package/dist/codesys/decl.js +251 -0
- package/dist/codesys/decl.js.map +1 -0
- package/dist/codesys/devices.d.ts +34 -0
- package/dist/codesys/devices.js +82 -0
- package/dist/codesys/devices.js.map +1 -0
- package/dist/codesys/diff.d.ts +13 -0
- package/dist/codesys/diff.js +61 -0
- package/dist/codesys/diff.js.map +1 -0
- package/dist/codesys/install.d.ts +40 -0
- package/dist/codesys/install.js +144 -0
- package/dist/codesys/install.js.map +1 -0
- package/dist/codesys/library-browse.d.ts +19 -0
- package/dist/codesys/library-browse.js +57 -0
- package/dist/codesys/library-browse.js.map +1 -0
- package/dist/codesys/outline.d.ts +32 -0
- package/dist/codesys/outline.js +219 -0
- package/dist/codesys/outline.js.map +1 -0
- package/dist/codesys/simulation.d.ts +34 -0
- package/dist/codesys/simulation.js +57 -0
- package/dist/codesys/simulation.js.map +1 -0
- package/dist/codesys/st.d.ts +36 -0
- package/dist/codesys/st.js +69 -0
- package/dist/codesys/st.js.map +1 -0
- package/dist/daemon.d.ts +46 -0
- package/dist/daemon.js +173 -0
- package/dist/daemon.js.map +1 -0
- package/dist/driver.d.ts +25 -0
- package/dist/driver.js +33 -0
- package/dist/driver.js.map +1 -0
- package/dist/panel/sim-panel.html +357 -0
- package/dist/panel/viewer.html +126 -0
- package/dist/panel-types.d.ts +20 -0
- package/dist/panel-types.js +3 -0
- package/dist/panel-types.js.map +1 -0
- package/dist/panel.d.ts +27 -0
- package/dist/panel.js +208 -0
- package/dist/panel.js.map +1 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.js +33 -941
- package/dist/server.js.map +1 -0
- package/dist/tools.d.ts +103 -0
- package/dist/tools.js +793 -0
- package/dist/tools.js.map +1 -0
- package/dist/viewer.d.ts +14 -0
- package/dist/viewer.js +125 -0
- package/dist/viewer.js.map +1 -0
- package/package.json +37 -21
- package/watcher/mcp_compat.py +147 -0
- package/watcher/mcp_ops.py +1178 -0
- package/watcher/mcp_sim.py +246 -0
- package/watcher/watcher.py +255 -0
- package/.claude/settings.local.json +0 -29
- package/CLAUDE.md +0 -26
- package/CONTRIBUTING.md +0 -72
- package/README.md.enhanced +0 -155
- package/codesys-mcp-toolkit-1.2.0.tgz +0 -0
- package/codesys-mcp-toolkit-1.2.1.tgz +0 -0
- package/codesys-mcp-toolkit-1.5.7.tgz +0 -0
- package/dist/bin.js +0 -75
- package/dist/check_session_paths.js +0 -149
- package/dist/codesys_interop.js +0 -435
- package/dist/direct_session_command.js +0 -293
- package/dist/scriptLoader.js +0 -165
- package/dist/scripts/check_status.py +0 -21
- package/dist/scripts/compile_project.py +0 -65
- package/dist/scripts/create_method.py +0 -80
- package/dist/scripts/create_pou.py +0 -102
- package/dist/scripts/create_project.py +0 -116
- package/dist/scripts/create_property.py +0 -78
- package/dist/scripts/ensure_project_open.py +0 -154
- package/dist/scripts/find_object_by_path.py +0 -111
- package/dist/scripts/get_pou_code.py +0 -91
- package/dist/scripts/get_project_structure.py +0 -72
- package/dist/scripts/open_project.py +0 -25
- package/dist/scripts/save_project.py +0 -29
- package/dist/scripts/session_status.py +0 -281
- package/dist/scripts/set_pou_code.py +0 -109
- package/dist/scripts/start_session.py +0 -809
- package/dist/scripts/stop_session.py +0 -324
- package/dist/sessionManager.js +0 -798
- package/docs/configuration.md +0 -141
- package/docs/index.md +0 -26
- package/docs/installation.md +0 -84
- package/docs/session_management.md +0 -110
- package/examples/README.md +0 -78
- package/examples/sample_config.json +0 -32
- package/replacements_session_status.txt +0 -16
- package/scriptDoc.txt +0 -8679
- package/scripts/build.js +0 -25
- package/scripts/fix_fstrings.py +0 -76
package/docs/configuration.md
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
# Configuration Guide
|
|
2
|
-
|
|
3
|
-
This guide explains how to configure the CODESYS MCP Toolkit for use with MCP clients, specifically focusing on Claude Desktop.
|
|
4
|
-
|
|
5
|
-
## Claude Desktop Configuration
|
|
6
|
-
|
|
7
|
-
Claude Desktop is a popular MCP client that can use the CODESYS MCP Toolkit.
|
|
8
|
-
|
|
9
|
-
### Finding the Configuration File
|
|
10
|
-
|
|
11
|
-
The configuration file is typically located at:
|
|
12
|
-
* **Windows:** `C:\Users\<YourUsername>\AppData\Roaming\Claude\settings.json` (or `claude_desktop_config.json` in older versions)
|
|
13
|
-
* **macOS:** `~/Library/Application Support/Claude/settings.json` (or `claude_desktop_config.json`)
|
|
14
|
-
* **Linux:** `~/.config/Claude/settings.json` (or `claude_desktop_config.json`)
|
|
15
|
-
|
|
16
|
-
*(If you can't find `settings.json`, look for `claude_desktop_config.json`)*
|
|
17
|
-
|
|
18
|
-
### Recommended Configuration: Direct Command
|
|
19
|
-
|
|
20
|
-
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 Claude Desktop to run the installed command `codesys-mcp-tool` **directly**.
|
|
21
|
-
|
|
22
|
-
Edit the configuration file and add the CODESYS MCP server to the `mcpServers` object:
|
|
23
|
-
|
|
24
|
-
```json
|
|
25
|
-
{
|
|
26
|
-
"mcpServers": {
|
|
27
|
-
// ... other servers ...
|
|
28
|
-
"codesys_local": {
|
|
29
|
-
"command": "codesys-mcp-tool", // <<< Use the direct command name
|
|
30
|
-
"args": [
|
|
31
|
-
// Pass arguments directly to the tool using flags
|
|
32
|
-
"--codesys-path", "C:\\Program Files\\Path\\To\\Your\\CODESYS\\Common\\CODESYS.exe", // Customize this path!
|
|
33
|
-
"--codesys-profile", "Your CODESYS Profile Name" // Customize this profile name!
|
|
34
|
-
// Optional: Add --workspace "/path/to/your/projects" if needed
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
|
-
// ... other servers ...
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Why Direct Command is Recommended
|
|
43
|
-
|
|
44
|
-
Launching with `npx` (`"command": "npx"`) has been observed to cause errors (`'C:\Program' is not recognized...` or profile errors) when run from within applications like Claude Desktop. This is likely due to `npx` altering the execution environment (like the `PATH` variable) in a way that interferes with how CODESYS finds its own components or parses arguments when run non-interactively. Using the globally installed `codesys-mcp-tool` command directly avoids this interference.
|
|
45
|
-
|
|
46
|
-
### Customizing for Your Environment
|
|
47
|
-
|
|
48
|
-
You **must** customize:
|
|
49
|
-
1. `--codesys-path`: Set this value to the **full and correct path** of your specific `CODESYS.exe` executable file.
|
|
50
|
-
2. `--codesys-profile`: Set this value to the **exact name** of the CODESYS profile you want to use (this name is visible in the CODESYS UI or start menu).
|
|
51
|
-
|
|
52
|
-
**Important Notes:**
|
|
53
|
-
* Use double backslashes (`\\`) for paths in the JSON file if you are on Windows.
|
|
54
|
-
* The profile name must match *exactly*, including capitalization and spacing.
|
|
55
|
-
* Ensure `codesys-mcp-tool` is accessible in the system PATH where Claude Desktop runs. Global installation via `npm install -g` usually handles this.
|
|
56
|
-
|
|
57
|
-
### Applying Changes
|
|
58
|
-
|
|
59
|
-
After modifying the configuration:
|
|
60
|
-
1. Save the `settings.json` file.
|
|
61
|
-
2. **Restart Claude Desktop completely** (ensure it's fully closed and reopened).
|
|
62
|
-
3. Claude should now attempt to connect to the CODESYS MCP server using the direct command.
|
|
63
|
-
|
|
64
|
-
### Alternative (Not Recommended): Using `npx`
|
|
65
|
-
|
|
66
|
-
If you cannot use the direct command method for some reason, you can try `npx`, but be aware of the potential issues mentioned above.
|
|
67
|
-
|
|
68
|
-
```json
|
|
69
|
-
// Example using npx (POTENTIALLY PROBLEMATIC - USE WITH CAUTION):
|
|
70
|
-
{
|
|
71
|
-
"mcpServers": {
|
|
72
|
-
"codesys_local": {
|
|
73
|
-
"command": "npx",
|
|
74
|
-
"args": [
|
|
75
|
-
"-y", // Tells npx to install temporarily if not found globally
|
|
76
|
-
"@codesys/mcp-toolkit",
|
|
77
|
-
// Arguments for the tool MUST come AFTER the package name
|
|
78
|
-
"--codesys-path", "C:\\Program Files\\Path\\To\\Your\\CODESYS\\Common\\CODESYS.exe",
|
|
79
|
-
"--codesys-profile", "Your CODESYS Profile Name"
|
|
80
|
-
// Optional: "--workspace", "/path/to/your/projects"
|
|
81
|
-
]
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
*If you encounter errors with `npx`, switch to the recommended Direct Command method.*
|
|
87
|
-
|
|
88
|
-
## Command-Line Options (for `codesys-mcp-tool`)
|
|
89
|
-
|
|
90
|
-
When running `codesys-mcp-tool` directly or configuring it in your MCP client, you can use these arguments:
|
|
91
|
-
|
|
92
|
-
* `-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).
|
|
93
|
-
* `-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).
|
|
94
|
-
* `-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.
|
|
95
|
-
* `-V, --version`: Output the version number.
|
|
96
|
-
* `-h, --help`: Display help for command.
|
|
97
|
-
|
|
98
|
-
## Verifying Configuration
|
|
99
|
-
|
|
100
|
-
To verify your configuration within Claude Desktop:
|
|
101
|
-
|
|
102
|
-
1. After restarting Claude with the correct configuration, wait for the server to connect (check logs if needed).
|
|
103
|
-
2. Ask Claude:
|
|
104
|
-
```
|
|
105
|
-
Can you please check the status of the CODESYS Local server?
|
|
106
|
-
```
|
|
107
|
-
(Replace `CODESYS Local` if you used a different key in `mcpServers`).
|
|
108
|
-
|
|
109
|
-
3. Claude should use the `codesys://project/status` resource. A successful response will show information like `Scripting OK: true`, `Project Open: ...`, etc. An error indicates a problem with the connection, CODESYS setup, or the script execution itself (check logs).
|
|
110
|
-
|
|
111
|
-
## Multiple CODESYS Installations
|
|
112
|
-
|
|
113
|
-
If you have multiple CODESYS installations, you can create multiple server entries in `mcpServers` with different keys (names) and point each to the specific installation:
|
|
114
|
-
|
|
115
|
-
```json
|
|
116
|
-
{
|
|
117
|
-
"mcpServers": {
|
|
118
|
-
"codesys_sp21": { // Unique key for this server
|
|
119
|
-
"command": "codesys-mcp-tool", // Direct command
|
|
120
|
-
"args": [
|
|
121
|
-
"--codesys-path", "C:\\Program Files\\CODESYS 3.5.21.0\\CODESYS\\Common\\CODESYS.exe",
|
|
122
|
-
"--codesys-profile", "CODESYS V3.5 SP21"
|
|
123
|
-
]
|
|
124
|
-
},
|
|
125
|
-
"codesys_sp19": { // Unique key for this server
|
|
126
|
-
"command": "codesys-mcp-tool", // Direct command
|
|
127
|
-
"args": [
|
|
128
|
-
"--codesys-path", "C:\\Program Files\\CODESYS 3.5.19.0\\CODESYS\\Common\\CODESYS.exe",
|
|
129
|
-
"--codesys-profile", "CODESYS V3.5 SP19"
|
|
130
|
-
]
|
|
131
|
-
}
|
|
132
|
-
// ... other servers ...
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
## Next Steps
|
|
138
|
-
|
|
139
|
-
* Try some [basic examples](examples.md)
|
|
140
|
-
* Learn about the [available tools and resources](api.md)
|
|
141
|
-
* Check the [troubleshooting guide](troubleshooting.md) if you encounter issues
|
package/docs/index.md
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# CODESYS MCP Toolkit Documentation
|
|
2
|
-
|
|
3
|
-
Welcome to the documentation for the CODESYS MCP Toolkit!
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
The CODESYS MCP Toolkit provides a bridge between Model Context Protocol (MCP) clients and CODESYS V3 programming environments. This toolkit enables seamless interaction for automating project management, POU creation, code editing, and compilation tasks.
|
|
8
|
-
|
|
9
|
-
## Components
|
|
10
|
-
|
|
11
|
-
- **MCP Server**: Core component that handles MCP protocol communication
|
|
12
|
-
- **CODESYS Script Integration**: Interface with CODESYS scripting engine
|
|
13
|
-
- **Command-Line Interface**: For direct usage and configuration
|
|
14
|
-
|
|
15
|
-
## Getting Started
|
|
16
|
-
|
|
17
|
-
- [Installation](installation.md)
|
|
18
|
-
- [Configuration](configuration.md)
|
|
19
|
-
- [Usage Examples](examples.md)
|
|
20
|
-
- [API Reference](api.md)
|
|
21
|
-
|
|
22
|
-
## Advanced Topics
|
|
23
|
-
|
|
24
|
-
- [Contributing Guidelines](../CONTRIBUTING.md)
|
|
25
|
-
- [Troubleshooting](troubleshooting.md)
|
|
26
|
-
- [Custom Extensions](extensions.md)
|
package/docs/installation.md
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# Installation Guide
|
|
2
|
-
|
|
3
|
-
This guide covers how to install the CODESYS MCP Toolkit on your system.
|
|
4
|
-
|
|
5
|
-
## Prerequisites
|
|
6
|
-
|
|
7
|
-
Before installing, ensure you have:
|
|
8
|
-
|
|
9
|
-
1. **Node.js**: Version 18 or later
|
|
10
|
-
- Download from [nodejs.org](https://nodejs.org/)
|
|
11
|
-
- Verify installation with `node --version`
|
|
12
|
-
|
|
13
|
-
2. **CODESYS V3**: A working CODESYS V3 installation
|
|
14
|
-
- Tested with version 3.5 SP21
|
|
15
|
-
- Must have the **Scripting Engine** component enabled
|
|
16
|
-
- Verify by opening CODESYS and checking if scripting commands are available
|
|
17
|
-
|
|
18
|
-
3. **MCP Client**: An MCP-enabled application (e.g., Claude Desktop)
|
|
19
|
-
|
|
20
|
-
## Installation Methods
|
|
21
|
-
|
|
22
|
-
### Method 1: Install from npm (Recommended)
|
|
23
|
-
|
|
24
|
-
The simplest way to install is directly from npm:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npm install -g @codesys/mcp-toolkit
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
This installs the package globally on your system, making the `codesys-mcp-toolkit` command available in your terminal.
|
|
31
|
-
|
|
32
|
-
Verify the installation by running:
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
codesys-mcp-toolkit --version
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### Method 2: Install from Source
|
|
39
|
-
|
|
40
|
-
For development or to get the latest unreleased changes:
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
# Clone the repository
|
|
44
|
-
git clone https://github.com/yourusername/codesys-mcp-toolkit.git
|
|
45
|
-
cd codesys-mcp-toolkit
|
|
46
|
-
|
|
47
|
-
# Install dependencies
|
|
48
|
-
npm install
|
|
49
|
-
|
|
50
|
-
# Build the project
|
|
51
|
-
npm run build
|
|
52
|
-
|
|
53
|
-
# Install globally
|
|
54
|
-
npm install -g .
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Verify the installation using the same command as above.
|
|
58
|
-
|
|
59
|
-
## Next Steps
|
|
60
|
-
|
|
61
|
-
After installation:
|
|
62
|
-
|
|
63
|
-
1. [Configure your MCP client](configuration.md) to use the CODESYS MCP Toolkit
|
|
64
|
-
2. Try some [basic examples](examples.md)
|
|
65
|
-
3. Learn about the [available tools and resources](api.md)
|
|
66
|
-
|
|
67
|
-
## Troubleshooting Installation Issues
|
|
68
|
-
|
|
69
|
-
### Common Issues
|
|
70
|
-
|
|
71
|
-
- **Permission errors**: You may need to run npm with administrative privileges
|
|
72
|
-
```bash
|
|
73
|
-
sudo npm install -g @codesys/mcp-toolkit # On Linux/macOS
|
|
74
|
-
# or use PowerShell as Administrator on Windows
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
- **Path issues**: Ensure the npm global bin directory is in your PATH
|
|
78
|
-
|
|
79
|
-
- **Node.js version**: Verify you have Node.js 18 or later
|
|
80
|
-
```bash
|
|
81
|
-
node --version
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
If you encounter other issues, please check the [troubleshooting guide](troubleshooting.md) or [open an issue](https://github.com/yourusername/codesys-mcp-toolkit/issues) on GitHub.
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
# Session Management in CODESYS MCP Toolkit
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Starting from version 1.4.0, the CODESYS MCP Toolkit supports persistent sessions. This feature significantly improves performance by allowing a single instance of CODESYS to stay open while multiple commands are executed, then closing it when explicitly requested or after a period of inactivity.
|
|
6
|
-
|
|
7
|
-
## Benefits
|
|
8
|
-
|
|
9
|
-
- **Faster execution**: Eliminates the overhead of starting and stopping CODESYS for each command
|
|
10
|
-
- **Shared context**: Commands executed in the same session share the same CODESYS runtime context
|
|
11
|
-
- **Resource efficiency**: Reduces CPU and memory usage by avoiding repeated process creation
|
|
12
|
-
- **Automatic timeout**: Sessions automatically shut down after a period of inactivity (10 minutes by default)
|
|
13
|
-
|
|
14
|
-
## Session Management Commands
|
|
15
|
-
|
|
16
|
-
The toolkit provides three specific commands for managing sessions:
|
|
17
|
-
|
|
18
|
-
### 1. `start_session`
|
|
19
|
-
|
|
20
|
-
Starts a new persistent CODESYS session. If a session is already running, this command reports that fact without starting another.
|
|
21
|
-
|
|
22
|
-
**Example**:
|
|
23
|
-
```
|
|
24
|
-
/mcp codesys_local start_session
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### 2. `session_status`
|
|
28
|
-
|
|
29
|
-
Checks if a session is currently active and returns information about it, including:
|
|
30
|
-
- Current state (running, busy, stopped, etc.)
|
|
31
|
-
- How long the session has been running
|
|
32
|
-
- Which project is open in the session (if any)
|
|
33
|
-
|
|
34
|
-
**Example**:
|
|
35
|
-
```
|
|
36
|
-
/mcp codesys_local session_status
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### 3. `stop_session`
|
|
40
|
-
|
|
41
|
-
Stops an active session and cleans up session resources. If no session is running, this command reports that fact without taking any action.
|
|
42
|
-
|
|
43
|
-
**Example**:
|
|
44
|
-
```
|
|
45
|
-
/mcp codesys_local stop_session
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## How to Use Session Management
|
|
49
|
-
|
|
50
|
-
### Recommended Workflow
|
|
51
|
-
|
|
52
|
-
1. Start a session at the beginning of your work:
|
|
53
|
-
```
|
|
54
|
-
/mcp codesys_local start_session
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
2. Execute all your commands normally - they will automatically use the active session:
|
|
58
|
-
```
|
|
59
|
-
/mcp codesys_local open_project --filePath "C:/path/to/project.project"
|
|
60
|
-
/mcp codesys_local create_pou --projectFilePath "C:/path/to/project.project" --name "MyPOU" --type "FunctionBlock" --language "ST" --parentPath "Application"
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
3. When you're done working, stop the session:
|
|
64
|
-
```
|
|
65
|
-
/mcp codesys_local stop_session
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
If you forget to stop the session, it will automatically time out after 10 minutes of inactivity.
|
|
69
|
-
|
|
70
|
-
### Session Behavior
|
|
71
|
-
|
|
72
|
-
- All commands automatically use an active session if one exists
|
|
73
|
-
- If no session exists when a command is run, it will execute without a session (traditional mode)
|
|
74
|
-
- You can explicitly start a session before running commands to improve performance
|
|
75
|
-
- Sessions maintain state between commands, including open projects
|
|
76
|
-
|
|
77
|
-
## Troubleshooting
|
|
78
|
-
|
|
79
|
-
### Common Issues
|
|
80
|
-
|
|
81
|
-
#### Session Won't Start
|
|
82
|
-
|
|
83
|
-
If you can't start a session, check:
|
|
84
|
-
- Make sure CODESYS is properly installed and accessible at the path specified in your configuration
|
|
85
|
-
- Verify that the CODESYS profile exists and is valid
|
|
86
|
-
- Check if there are any error messages in the client's output
|
|
87
|
-
|
|
88
|
-
#### Session Appears Unresponsive
|
|
89
|
-
|
|
90
|
-
If a session seems stuck:
|
|
91
|
-
1. Check its status: `/mcp codesys_local session_status`
|
|
92
|
-
2. If it reports as active but not responding, try stopping it: `/mcp codesys_local stop_session`
|
|
93
|
-
3. If it still doesn't respond, the toolkit includes a forced cleanup mechanism that will activate automatically when you try to stop a non-responsive session
|
|
94
|
-
|
|
95
|
-
#### Session Files Remain After Stopping
|
|
96
|
-
|
|
97
|
-
Session state is stored in a temporary directory (`[temp]/codesys_session/`). These files should be cleaned up automatically when a session stops, but in rare cases (like if the process is killed abruptly), they might remain. The toolkit will clean up old files when starting a new session.
|
|
98
|
-
|
|
99
|
-
## Technical Details
|
|
100
|
-
|
|
101
|
-
The session management system works by:
|
|
102
|
-
|
|
103
|
-
1. Starting a CODESYS instance with a special Python script that enters a command loop
|
|
104
|
-
2. Maintaining session state in files within a temporary directory
|
|
105
|
-
3. Communicating with the running session via file-based IPC (Inter-Process Communication)
|
|
106
|
-
4. Executing scripts within the context of the running CODESYS instance
|
|
107
|
-
5. Automatically detecting and handling session health issues
|
|
108
|
-
|
|
109
|
-
Session files are stored in the system's temporary directory in a subfolder called `codesys_session`.
|
|
110
|
-
EOF < /dev/null
|
package/examples/README.md
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# CODESYS MCP Toolkit Examples
|
|
2
|
-
|
|
3
|
-
This directory contains examples of how to use the CODESYS MCP toolkit effectively.
|
|
4
|
-
|
|
5
|
-
## Example Configuration Files
|
|
6
|
-
|
|
7
|
-
### Basic MCP Configuration
|
|
8
|
-
|
|
9
|
-
`claude_desktop_config.json` - Example configuration for Claude Desktop:
|
|
10
|
-
|
|
11
|
-
```json
|
|
12
|
-
{
|
|
13
|
-
"mcpServers": {
|
|
14
|
-
"codesys_local": {
|
|
15
|
-
"command": "npx",
|
|
16
|
-
"args": [
|
|
17
|
-
"-y",
|
|
18
|
-
"@codesys/mcp-toolkit",
|
|
19
|
-
"--codesys-path", "C:\\Program Files\\CODESYS 3.5.21.0\\CODESYS\\Common\\CODESYS.exe",
|
|
20
|
-
"--codesys-profile", "CODESYS V3.5 SP21"
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Example Prompts
|
|
28
|
-
|
|
29
|
-
Here are some example prompts you can use with Claude Desktop:
|
|
30
|
-
|
|
31
|
-
### Create a Motor Controller Function Block
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
Using the CODESYS Local server, please create a MotorController function block with the following:
|
|
35
|
-
|
|
36
|
-
1. Properties:
|
|
37
|
-
- SpeedSetpoint (INT)
|
|
38
|
-
- ActualSpeed (INT)
|
|
39
|
-
- IsRunning (BOOL)
|
|
40
|
-
|
|
41
|
-
2. Methods:
|
|
42
|
-
- Start() - Sets IsRunning to TRUE
|
|
43
|
-
- Stop() - Sets IsRunning to FALSE
|
|
44
|
-
- SetSpeed(speed: INT) - Sets SpeedSetpoint to the given value
|
|
45
|
-
|
|
46
|
-
Create this in a new project at C:/MyProjects/MotorControl.project
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Open and Analyze an Existing Project
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
Using the CODESYS Local server, please open the project at C:/MyProjects/ExistingProject.project and show me its structure. Then, show me the code for the main POU.
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Compile a Project
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
Using the CODESYS Local server, please open the project at C:/MyProjects/MyProject.project and compile it. Let me know if there are any errors.
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Programmatic Usage Examples
|
|
62
|
-
|
|
63
|
-
If you're integrating directly with the server code, here are some examples:
|
|
64
|
-
|
|
65
|
-
### CLI Usage
|
|
66
|
-
|
|
67
|
-
Run the server directly:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
codesys-mcp-toolkit --codesys-path "C:\Program Files\CODESYS 3.5.21.0\CODESYS\Common\CODESYS.exe" --codesys-profile "CODESYS V3.5 SP21"
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Use Cases
|
|
74
|
-
|
|
75
|
-
* Automated PLC project creation
|
|
76
|
-
* Standardized Function Block library management
|
|
77
|
-
* Continuous integration for CODESYS projects
|
|
78
|
-
* Documentation generation from CODESYS projects
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mcpServers": {
|
|
3
|
-
"codesys_local": {
|
|
4
|
-
"command": "npx",
|
|
5
|
-
"args": [
|
|
6
|
-
"-y",
|
|
7
|
-
"@codesys/mcp-toolkit",
|
|
8
|
-
"--codesys-path", "C:\\Program Files\\CODESYS 3.5.21.0\\CODESYS\\Common\\CODESYS.exe",
|
|
9
|
-
"--codesys-profile", "CODESYS V3.5 SP21"
|
|
10
|
-
]
|
|
11
|
-
},
|
|
12
|
-
"filesystem": {
|
|
13
|
-
"command": "npx",
|
|
14
|
-
"args": [
|
|
15
|
-
"-y",
|
|
16
|
-
"@modelcontextprotocol/server-filesystem",
|
|
17
|
-
"C:/MyProjects"
|
|
18
|
-
]
|
|
19
|
-
},
|
|
20
|
-
"memory": {
|
|
21
|
-
"command": "npx",
|
|
22
|
-
"args": [
|
|
23
|
-
"-y",
|
|
24
|
-
"@modelcontextprotocol/server-memory"
|
|
25
|
-
]
|
|
26
|
-
},
|
|
27
|
-
"puppeteer": {
|
|
28
|
-
"command": "npx",
|
|
29
|
-
"args": ["-y", "@modelcontextprotocol/server-puppeteer"]
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
f"{SCRIPT_ERROR_MARKER}: Invalid session state file" | "{0}: Invalid session state file".format(SCRIPT_ERROR_MARKER)
|
|
2
|
-
f"{SCRIPT_SUCCESS_MARKER}: Session is not active (Status: {status})" | "{0}: Session is not active (Status: {1})".format(SCRIPT_SUCCESS_MARKER, status)
|
|
3
|
-
f"WARNING: Session lock file is stale by {time_diff:.1f} seconds" | "WARNING: Session lock file is stale by {0:.1f} seconds".format(time_diff)
|
|
4
|
-
f"Error reading lock file: {e}" | "Error reading result: {0}".format(e)
|
|
5
|
-
f"ping_{int(time.time())}" | "ping_{0}".format(int(time.time()))
|
|
6
|
-
f"WARNING: Session did not respond to ping within {timeout} seconds" | "WARNING: Session did not respond to ping within {0} seconds".format(timeout)
|
|
7
|
-
f"Error resetting command file: {e}" | "Error resetting command file: {0}".format(e)
|
|
8
|
-
f"Error during ping test: {e}" | "Error during ping test: {0}".format(e)
|
|
9
|
-
f", Project: {project_name} ({project_path})" | ", Project: {0} ({1})".format(project_name, project_path)
|
|
10
|
-
f"{uptime:.0f} seconds" | "{0:.0f} seconds".format(uptime)
|
|
11
|
-
f"{uptime/60:.1f} minutes" | "{0:.1f} minutes".format(uptime/60)
|
|
12
|
-
f"{SCRIPT_SUCCESS_MARKER}: Session is active (ID: {session_id}, Status: {status}, Uptime: {uptime_str}{project_info})" | "{0}: Session is active (ID: {1}, Status: {2}, Uptime: {3}{4})".format(SCRIPT_SUCCESS_MARKER, session_id, status, uptime_str, project_info)
|
|
13
|
-
f"{SCRIPT_SUCCESS_MARKER}: Session appears to be zombie (ID: {session_id}, Status: {status} but unresponsive)" | "{0}: Session appears to be zombie (ID: {1}, Status: {2} but unresponsive)".format(SCRIPT_SUCCESS_MARKER, session_id, status)
|
|
14
|
-
f"Error updating session state: {e}" | "Error updating session state: {0}".format(e)
|
|
15
|
-
f"{SCRIPT_SUCCESS_MARKER}: Session is not active (Status: {status})" | "{0}: Session is not active (Status: {1})".format(SCRIPT_SUCCESS_MARKER, status)
|
|
16
|
-
f"{SCRIPT_ERROR_MARKER}: Error checking session status - {str(e)}" | "{0}: Error checking session status - {1}".format(SCRIPT_ERROR_MARKER, str(e))
|