More Efficiency for Programmers Faster to the Codesys Project with the 'AI colleague'

By Roland Wagner | Translated by AI 6 min Reading Time

Related Vendors

The Model Context Protocol integrates AI into Codesys for automating PLC engineering, increases efficiency through automated code generation, and improves debugging. It enables secure local solutions and supports developers with AI-assisted tasks such as test scripts or improvement suggestions, while version control ensures traceable changes.

(Image: Codesys)
(Image: Codesys)

SPS projects are becoming increasingly complex while also needing to be implemented faster. The Codesys Development System, as the leading IEC-61131-3 platform, offers numerous integrated functions for rapid project development, which simultaneously ensure high code quality, such as automatic syntax completion (similar to Microsoft's 'IntelliSense') or the productivity enhancement tools of the Professional Developer Edition. Additionally, with the Application Composer, complete application code can even be generated based on predefined modules. Whether with or without assistance, it is ultimately the SPS programmer who implements the logic task based on their experience and the available code pool from libraries.

Generative AI as an 'artificial colleague' promises relief from repetitive tasks, but integrating such systems into existing engineering tools has so far been complex and proprietary. Each provider followed their own approach, and unified interfaces were lacking. This is exactly where the Model Context Protocol (MCP) comes into play: Originally developed by Anthropic, the maker of the AI Claude, MCP defines a standardized protocol for data exchange between large language models (LLMs) and external applications. Codesys leverages this protocol with an integrated MCP server. This allows the Development System to be remotely operated by AI systems, creating a new level of human-machine collaboration in the automation environment: the automation task is formulated in natural language, and the AI takes over its implementation directly in the project—visible, traceable, and always adjustable.

Gallery

MCP as a Bridge between Language Model and Control Technology

To understand why the Model Context Protocol (MCP) is relevant to the automation world, it’s worth examining the fundamental limitations of large language models (LLMs). LLMs like GPT or Claude are trained on publicly available data. Their knowledge is limited to a specific cutoff date and does not include current project structures or proprietary libraries. While this suffices for generic questions, a model lacks the necessary context as soon as it is tasked with generating or analyzing PLC code within an active project. MCP addresses this issue through a universal protocol that standardizes information exchange: an MCP server provides defined tools and data access, an MCP client within the language model handles requests and forwards them, and an MCP host—such as Claude Desktop—interacts with the tool. This tripartite structure decouples the AI model from the specific data source, allowing users to switch the underlying LLM without having to rewrite the integration logic.

For Codesys, this means: The integrated MCP server connects the Development System to AI systems in a standardized way. The already existing command interface enables access to project structures, program blocks, libraries, and compiler messages. Complex tasks that a human would otherwise manually code step by step can be delegated via plain text command.

An example: The command ‘Create a function block for a two-point control with hysteresis and instantiate it in the main program’ prompts the AI to generate the block, populate the declaration, insert the instance call, and compile the project—all observable in the open editor. The AI independently identifies compiler errors, develops correction suggestions, and recompiles. This iterative cycle of generating, checking, and correcting runs automatically while the programmer retains control and can intervene at any time. The Codesys MCP server is already successfully communicating with Claude Desktop and OpenAI GPT-5. The prototype for Codesys V3.5 SP22 is currently achieving product status and will be available as a product add-on after its release in spring 2026.

Practical Benefits in Daily Engineering Tasks

The strength of AI usage via MCP does not lie in spectacular individual functions but in the accumulation of small reliefs that add up to noticeable time savings over a workday. It takes over monotonous tasks such as creating program blocks with instances, manually completing variable declarations, or writing test code. For less experienced developers, this significantly shortens the time to achieve a first runnable result. Instead of looking up syntax and library calls, they can focus on the logic task. Conversely, the AI can explain existing project code, identify structural weaknesses ("code smells"), and suggest improvements—which is also valuable for experienced users. Another use case: Codesys provides an integrated tool for automated testing with the Test Manager, but creating test scripts is time-consuming. The AI can independently generate test cases based on the project structure and library documentation, thereby implicitly contributing to code quality.

The same principles apply to AI as to human users: clear variable names, consistent coding guidelines, comprehensible comments, and clean documentation of the functions and libraries used measurably improve the results. Conversely, the language model can serve as a benchmark: if it doesn’t understand a project, new team members or external service providers will likely struggle as well. While the AI can assist in debugging, it does not replace professional validation before code is deployed to a machine. Version control tools such as Codesys Git document who made what changes and when—an important aspect as increasingly larger portions of an application are generated by machines.

Subscribe to the newsletter now

Don't Miss out on Our Best Content

By clicking on „Subscribe to Newsletter“ I agree to the processing and use of my data according to the consent form (please expand for details) and accept the Terms of Use. For more information, please see our Privacy Policy. The consent declaration relates, among other things, to the sending of editorial newsletters by email and to data matching for marketing purposes with selected advertising partners (e.g., LinkedIn, Google, Meta)

Unfold for details of your consent

Security and Local Alternatives

The exchange of data with cloud-based LLMs raises legitimate questions about information security. Companies whose machines and systems must operate offline or whose source code cannot leave the premises require different solutions. In collaboration with Intel, Codesys is working on a research project: using the OpenVINOTM AI runtime, locally optimized language models for PLC code generation are being fine-tuned. These models run without a cloud connection on local Intel processors. They leverage hybrid architectures with discrete GPUs as well as integrated AI acceleration through iGPU and NPU. New Intel CPUs, which are nearing release, significantly reduce hardware requirements, allowing them to be used on mid-performance systems. The advantage: prompts and source code remain fully within the company, while programming assistance is still available. Since the Codesys Development System also uses the MCP interface, public and local models can be easily switched. The technology is currently in a late research phase, with products expected to be available soon. Regardless of whether an external or local model is used, the explainability of AI suggestions remains a central issue. Generative language models can explain their decision processes in natural language, making it easier to assess their quality and usefulness. The challenge lies in maintaining oversight when a model autonomously makes changes to a project. This ties back to version control: with consistent commit logs, it can always be traced which changes were made manually and which were machine-generated.

Outlook: From Tool to Virtual Colleague

The development of AI-supported engineering functions is still in its early stages. Already available is the chatbot for the Codesys online help, which answers technical application questions based on official documentation and avoids hallucinations. This means: if it doesn’t find relevant information, it returns no result. Parallel research projects are underway for context-based code completion for Structured Text. By considering up to 200 lines of program context, its results go well beyond the aforementioned 'IntelliSense' functionality. External partners such as KS Solutions complement the ecosystem with AI-based code conversion between different PLC standards, such as AWL/SCL and ST according to IEC 61131-3.

In the future, highly qualified application specialists will continue to handle the exciting core tasks—but they will work more efficiently and creatively because the 'AI colleague' takes over tedious routine tasks. The focus is shifting from pure implementation to structuring into functional units and their precise problem description. The more accurately the task is formulated, the better the result. Incidentally, this is already true today, independent of AI, when using the aforementioned Codesys Application Composer: clearly described modules are also helpful here. In any case, automated testing and versioning will gain even more importance through AI, increasingly relieving PLC programmers—just like a helpful colleague.