codesys-mcp-toolkit
Model Context Protocol server for CODESYS automation platform
Documentation
@codesys/mcp-toolkit
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.
๐ Features
- Project Management
- Open existing CODESYS projects (`open_project`)
- Create new projects from standard templates (`create_project`)
- Save project changes (`save_project`)
- POU Management
- Create Programs, Function Blocks, and Functions (`create_pou`)
- Set declaration and implementation code (`set_pou_code`)
- Create properties for Function Blocks (`create_property`)
- Create methods for Function Blocks (`create_method`)
- Compile projects (`compile_project`)
- MCP Resources
- `codesys://project/status`: Check scripting status and currently open project state.
- `codesys://project/{+project_path}/structure`: Retrieve the object structure of a specified project.
- `codesys://project/{+project_path}/pou/{+pou_path}/code`: Read the declaration and implementation code for a specified POU, Method, or Property accessor.
๐ Prerequisites
- CODESYS V3: A working CODESYS V3 installation (tested with 3.5 SP21) with the Scripting Engine component enabled during installation.
- Node.js: Version 18.0.0 or later is recommended.
- MCP Client: An MCP-enabled application (e.g., Claude Desktop).
*(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.)*
๐ Installation
The recommended way to install is globally using npm:
npm install -g @codesys/mcp-toolkitThis installs the package globally, making the `codesys-mcp-tool` command available in your system's terminal PATH.
*(Advanced users can also install from source for development - see CONTRIBUTING.md if available).*
๐ง Configuration (IMPORTANT!)
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).
Recommended Configuration Method (Direct Command)
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.
Example for Claude Desktop (`settings.json` -> `mcpServers`):
{
"mcpServers": {
// ... other servers ...
"codesys_local": {
"command": "codesys-mcp-tool", // `: Full path to `CODESYS.exe`. (Required, overrides `CODESYS_PATH` env var, has a default but relying on it is not recommended).
* `-f, --codesys-profile `: Name of the CODESYS profile. (Required, overrides `CODESYS_PROFILE` env var, has a default but relying on it is not recommended).
* `-w, --workspace `: 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.
* `-h, --help`: Show help message.
* `--version`: Show package version.
## ๐ Troubleshooting
* **`'C:\Program' is not recognized...` error immediately after connection:**
* **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.
* **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.
* **Tool Fails / Errors in Output:**
* 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.
* Ensure the `--codesys-path` and `--codesys-profile` arguments passed to the command are correct and point to a valid CODESYS installation with scripting enabled.
* Verify the project paths and object paths you are passing to tools are correct (use forward slashes `/`).
* Make sure no other CODESYS instances are running in conflicting ways (e.g., holding a lock on the profile).
* **`command not found: codesys-mcp-tool`:**
* Ensure the package was installed globally (`npm install -g @codesys/mcp-toolkit`).
* 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.
* **Check Logs:**
* Claude Desktop logs: `C:\Users\\AppData\Roaming\Claude\logs\` (Windows)
## ๐ค Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page. (Optionally add a CONTRIBUTING.md file with more details).
## ๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
## ๐ Acknowledgements
- The CODESYS GmbH team for the powerful CODESYS platform and its scripting engine.
- The Model Context Protocol project for defining the interaction standard.
- All contributors and users who help improve this toolkit.Frequently asked questions
What is codesys-mcp-toolkit?
codesys-mcp-toolkit is Model Context Protocol server for CODESYS automation platform
How do I install codesys-mcp-toolkit?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is codesys-mcp-toolkit open source?
Yes โ it is hosted on GitHub at https://github.com/johannespettersson80/codesys-mcp-toolkit and has 9 stars.
Related MCP tools
๐ Cherry Studio is a desktop client that supports for multiple LLM providers. Built for the Model Context Protocol to enhance AI capabilities.
Enhanced ChatGPT Clone: Features Agents, MCP, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini...
FastGPT is a knowledge-based platform built on the LLMs, offers a comprehensive suite of out-of-the-box capabilities such as data processing, RAG retrieval, ...
Composio equips your AI agents & LLMs with 100+ high-quality integrations via function calling for the Model Context Protocol. Enhance AI assistants with powerf
๐ฆ Repomix is a powerful tool that packs your entire repository into a single, AI-friendly file. Perfect for when you need to feed your codebase to Large Lan...
AI Agents & MCPs & AI Workflow Automation โข (~400 MCP servers for AI agents) โข AI Automation / AI Agent with MCPs โข AI Workflows & AI Agents โข MCPs for AI Ag...
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP