MCP Tools and Resources
Tools perform actions in the CODESYS project or on the device and return results. Reading tools have no impact on the project or device. Writing tools permanently change the contents or structure of the project and are marked accordingly in the table.
Development tools
Development tools edit the CODESYS project without establishing a connection to the controller.
The development tools are used for the following tasks:
Programming in Structured Text
Managing the project structure and libraries
Checking the project
Tool | Description | Effect |
|---|---|---|
| Adds a library reference to the project or removes it. | Change of library references in the Library Manager |
| Assigns a program to a task so that it is executed in the runtime cycle. The tool is used after a new program has been created. The tool can also remove program calls from tasks. | Change of the program calls of tasks |
| Displays the structure of the project tree or a specific subtree. Methods, properties, and actions are optionally shown below their parent POUs. | Read only |
| Checks the project for errors and returns diagnostic messages with source paths and line numbers. In standard mode, the tool refers to precompile rules. Optionally, a full compilation can be triggered. | Read only. Optionally, the tool can trigger the compilation of the project. |
| Creates a new folder in the project tree. This tool is used to organize POUs into logical groups. | A new folder will be created in the project. |
| Creates new Structured Text objects or completely rewrites existing ones. A complete POU with nested sub-POUs can be created in a single call. Sub-POUs which are not explicitly included will be retained. | Existing objects at the same path will be overwritten. |
| Returns the path of the currently loaded project. | Read only |
| Returns the path of the active selection in CODESYS. When code is selected, line numbers and the selected text are also returned. | Read only |
| Returns a list of all libraries available in CODESYS. | Read only |
| Returns detailed documentation for specific functions of a library. Includes parameters, return type, and other relevant details. | Read only |
| Provides a concise overview of the contents of a library. Contains all functions, types, and their top-level signatures. | Read only |
| Returns a list of all libraries referenced in the application. | Read only |
| Returns the Structured Text source code of an object at the specified path. Nested sub-objects (e.g. methods, actions, properties, and transitions) are included in the output by default. Also supports the restriction of output by using a start and end line | Read only |
| Removes an object from the project. The tool is also used to remove individual subordinate POUs from a function block. | The object will be irrevocably deleted. |
| Renames an object and updates all references to that object. If a reference cannot be adjusted, then the renaming will not be done. | Complete renaming with a change to all references |
| Performs targeted text replacements in a Structured Text object. | The specified text will be replaced in the target object. |
| Searches the entire project code for a text pattern. Matches are returned and grouped by object path with line numbers. | Read only |
| Searches for a type or function by name over all available libraries. Returns the library name and element type. | Read only |
| Uses glob patterns to find objects in the project tree. In the case of many results with a common ancestor, the output is displayed in a group. | Read only |
Device tools
Device tools edit the device tree of the CODESYS project and manage the device repository.
The device tools are used for the following tasks:
Scanning for, adding, replacing, and configuring devices
Mapping variables to I/O channels
Managing device descriptions in the device repository
The device tools do not establish a connection to the controller. Changed configurations reach the controller only with the next download or online change.
Tool | Description | Effect |
|---|---|---|
| Acknowledges the diagnostic messages of a device on the controller. Optionally, the tool also acknowledges the diagnostic messages of all subordinate devices. The tool corresponds to the Acknowledge Diagnosis, Acknowledge Diagnosis for Subtree commands in CODESYS. The application must be in online mode. | Writing. Writes a value to the acknowledgment parameter of the device on the controller. The device driver determines how the device responds. |
| Adds a device from the device repository to the device tree. The tool adds the device as a top-level device or below a device or connector. A top-level device is a controller, for example. For slots, | Writing. Adds a device to the project. If an application of the controller is in online mode, the tool is not available. |
| Scans for the devices on the fieldbus below a master, scanner, or controller and adds the devices to the project. The tool corresponds to the Scan for Devices command in CODESYS and then copies the devices to the project. If no devices are selected, the tool adds all responding devices for which a device description is installed. For fieldbuses that assign devices by their identity, the tool also adds individual devices from the result of | Writing. Changes the project. For fieldbuses that assign devices by their position, the tool replaces an existing configuration below the master only with the |
| Enables or disables a device, a module, or a plugged slot. The tool corresponds to the and commands in CODESYS. | Writing. Changes the device in the project. When a device is disabled, its subordinate devices are also disabled. The tool cannot be executed while an application of the controller is logged in. |
| Reads the online status of a device and all subordinate devices. The online status corresponds to the status icons in the device tree, for example:
With the | Read only. |
| Installs device description files to the device repository, for example | Writing. Changes the device repository of the installation. Overwrites existing descriptions with the same version. |
| Lists all devices, connectors, and slots with the type, ID, version, and module ID of their device description. The tool is used to reproduce a configuration or to check the revision used. | Read only. |
| Lists the I/O channels of a device with the data type and mapped variables. The output corresponds to the page in the device editor. | Read only. |
| Maps variables to I/O channels or removes the mapping. A single call can also process multiple devices. The tool checks all entries in advance. | Writing. Replaces the previous mapping. If the tool rejects an entry, the project remains unchanged. |
| Plugs a device into an empty slot or port. For example, the tool plugs a module into a bus coupler or a device into an IO-Link port. | Writing. A device is plugged in the project. If an application of the controller is in online mode, the tool is not available. |
| Reads the parameters of a device with the value, default value, data type, and access. The output corresponds to the parameter pages of the device editor in offline mode. | Read only. The tool does not read any online values. |
| Scans for the devices that are connected to the fieldbus below a master, controller, or scanner. The controller must be reachable. For most fieldbuses, the application with the fieldbus configuration must also be running. | Read only. Existing devices are retained. The tool includes every responding device, including a device of another machine on the same network. Therefore, check the result. CODESYS is blocked during the scan. The scan usually takes a few seconds. If the controller does not respond, the scan takes about |
| The tool adds the devices that were found with | Writing. Adds the found devices to the project. Existing devices are retained. The tool adds every responding device. |
| Uses a regular expression to search the installed device descriptions by name, vendor, and order number. Optionally, the tool restricts the search to devices that fit below a specific device or into a slot. | Read only. |
| Irrevocably uninstalls device descriptions from the device repository. The tool also uninstalls descriptions that depend on them. | Writing. The uninstallation is irrevocable and affects all projects, including currently open projects. The tool does not check open projects. Afterwards, the devices in these projects are missing their description. |
| Removes the device from a slot or port. The slot remains empty in the device tree. | Writing. Removes the device and all subordinate elements. |
| Replaces the device description of a device. The tool corresponds to the command in CODESYS. If no description is specified, the tool uses the latest installed version. | Writing. The device keeps its name and position. Where possible, the device also keeps its subnodes and settings. |
| Changes values of device parameters in the project. The tool checks the values in the same way as the device editor. | Writing. Changes only the project. The tool cannot be executed while an application of the controller is logged in. |
Online tools
With real hardware, the online tools act on the application of the physical plant. Reading online tools have no impact on the application and device. Writing online tools change the state of the application or device.
Caution
Use these security functions to protect the controller from unintended actions of an AI assistant:
Confirmed Online Mode: If Confirmed Online Mode is enabled for the device, the following tools do not perform any action and report an error:
logout_applicationreset_applicationset_online_valuesstart_applicationstop_applicationexecute_single_cycle_or_step
PLC-UserManagement: With PLC-UserManagement, you define in fine detail who is allowed to perform which actions. On the controller, create a user who has only the rights intended for the AI assistant. Log in to the device as this user.
Operating Modes: The Operating Modes generally protect the controller against unintended access, including tools executed by mistake.
Tool | Description | Effect |
|---|---|---|
| Executes one cycle or one step of the logged-in application and then halts. | Writing. The controller reads inputs, executes the program, and writes outputs. In this process, a machine may move. |
| Returns whether the application is logged in. The tool also returns whether the application is running, is stopped, or is halted at a breakpoint. | Read only. |
| Reads the runtime log of the device. If an online operation has failed, the log contains the cause. | Read only. |
| Reads current values of variables of a logged-in application. | Read only. |
| Lists all forced variables of a logged-in application. | Read only. |
| Logs the user in to the application on the device. If required, the tool compiles the project and downloads it to the device. | Writing. Establishes a connection to the device and downloads code to the device if required. |
| Logs the user in to the application on the device if the application has not changed. This login variant is more cautious and does not transfer any project changes to the device. WarningSubsequent tool calls may reset the logged-in application or write and force individual variables. | Writing. The tool compiles the application in order to compare it with the application on the device. The application on the device remains unchanged. |
| Logs the user out of the application. Optionally, the tool unforces the variables first. | Writing. Terminates the online connection. |
| Resets the application. The possible types are warm, cold, and origin. | Writing. Stops program execution and resets variable values. When resetting to origin, the tool deletes the application on the controller. |
| Writes variable values, forces them, or unforces them. | Writing. Forcing persists beyond the session. |
| Starts the specified application. The application must be logged in. First log in the application with | Writing. Executes code on the target device. With real hardware, the code runs on the physical plant. |
| Stops the specified application. The application must be logged in. First log in the application with | Writing. Stops the code on the target device. |
Project management tools
Project management tools open, save, and close the CODESYS project and return the project status. Only one project can be open at a time. Reading project management tools have no impact on the project. Writing project management tools change the open project or the project file.
Important
The following access restrictions apply to the project management tools:
Directory whitelist: The tools work only with project files in folders that the user has approved in Tools → Options → MCP Server → File Access. After installation, no folder is approved. Installation folders, repository folders, and Windows folders are always blocked.
User management: The rights of the CODESYS user management also apply to the tools. If the logged-in user does not have the right for a command, the tool does not execute the command and reports an error.
Tool | Description | Effect |
|---|---|---|
| Closes the open project. If the project contains unsaved changes, the tool reports an error. With the | Writing. With |
| Returns the status of the open project. The status includes the file path, project type, unsaved changes, and write protection. Optionally, the tool also returns the project information. | Read only. |
| Opens a project, a library, or an FBS project. Optionally, the tool opens the project as read-only. | Writing. Loads the project. For large projects, opening may take several minutes. |
| Saves the open project to its storage location. | Writing. Overwrites the project file. |
| Saves the open project to a new path. The new project remains open. | Writing. Creates a new file. With the |
Resources
Resources are read-only context data such as templates and syntax references. Unlike tools, resources do not perform actions, but provide static contents. Resources can be referenced directly in prompts, for example: "Create a test case according to the test case template".
Resource | Description |
|---|---|
CODESYS Structured Text Dialect Description | Syntax reference for the dialect of CODESYS ST with explanations and examples of the IEC 61131-3 standard and CODESYS-specific extensions. The reference comprises syntax rules, data types and literals, variable sections, operators, control flow, calling conventions, interfaces, inheritance, and common sources of errors. This resource can be used during code generation and code checking to avoid syntax errors caused by dialect-specific peculiarities. |
CODESYS IEC UnitTest Testcase Template | Test case template following the pattern
This resource is used when creating new unit tests so that test cases are generated according to the recommended pattern of the CODESYS Test Manager. |