Skip to main content

MCP Tools and Resources

Tools perform actions in the CODESYS project and return results. Reading tools have no impact on the project. Writing tools permanently change the contents or structure of the project and are marked accordingly in the table.

Tool

Description

Effect

add_or_remove_library

Adds a library reference to the project or removes it.

Change of library references in the Library Manager

add_or_remove_program_call_in_task

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

browse_project_tree

Displays the structure of the project tree or a specific subtree. Methods, properties, and actions are optionally shown below their parent POUs.

Read only

check_for_errors

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.

create_folder

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.

create_or_replace_structured_text_object

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.

get_active_app_as_path

Returns the path of the currently loaded project.

Read only

get_active_path_and_selection

Returns the path of the active selection in CODESYS. When code is selected, line numbers and the selected text are also returned.

Read only

get_available_libraries_list

Returns a list of all libraries available in CODESYS.

Read only

get_detailed_library_documentation

Returns detailed documentation for specific functions of a library. Includes parameters, return type, and other relevant details.

Read only

get_device_and_io_configuration

Returns the full device tree and I/O configuration of all devices in the project. Includes connectors, I/O channels, mappings to variables, and device information.

Read only

get_library_documentation

Provides a concise overview of the contents of a library. Contains all functions, types, and their top-level signatures.

Read only

get_libraries_referenced_in_application

Returns a list of all libraries referenced in the application.

Read only

get_structured_text_content

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

remove_object

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.

rename_object

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

replace_text_in_structured_text

Performs targeted text replacements in a Structured Text object.

The specified text will be replaced in the target object.

search_in_files_by_regex

Searches the entire project code for a text pattern. Matches are returned and grouped by object path with line numbers.

Read only

search_libraries_for_type

Searches for a type or function by name over all available libraries. Returns the library name and element type.

Read only

search_path_by_glob

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

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 TM.Testcase. The template contains the following methods:

  • Setup: Preparation of the test object

  • Execute: Stimulation and result testing

  • Teardown: Clean up after the test is complete

  • Abort: Cancellation handling of a running test

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.