Skip to main content
Glama
CODESYS MCP Server
by lm200000

CODESYS MCP Server (standalone)

English | 简体中文

A standalone MCP server for official CODESYS engineering through the vendor ScriptEngine. It is spawn-only: every request starts a private CODESYS.exe --runscript process, edits a .project file on disk, and exits. There is no IDE plugin, no attach mode, no named pipe, and no online/PLC access.

This build supports the official CODESYS.exe only. OEM editions such as InoProShop are not supported by this package.

Requirements

Item

Requirement

OS

Windows 10/11 x64

Node.js

18 or newer

CODESYS

Official CODESYS installed and activated on the same machine

Tested baseline

CODESYS V3.5 SP21 Patch 6. Other V3.5 releases may work but are not verified

Related MCP server: inoproshop

Install

cd C:\Tools\codesys-mcp-standalone
npm install

Or use the package directly from a release archive; only the node_modules dependencies are needed at runtime.

Required configuration

The MCP server process must receive these two environment variables. They are read on every tool call, so the client configuration below is the recommended place to set them.

Variable

Required

Meaning

Example

CODESYS_EXE

yes

Absolute path to the official CODESYS.exe

C:\Program Files\CODESYS 3.5.21.60\CODESYS\Common\CODESYS.exe

CODESYS_PROFILE

yes

Exact profile name installed next to CODESYS

CODESYS V3.5 SP21 Patch 6

CODESYS_EXE must point to a file named CODESYS.exe. The server derives the profile directory from it:

<install>\CODESYS\Common\CODESYS.exe
<install>\CODESYS\Profiles\<CODESYS_PROFILE>.profile.xml

Optional configuration

Variable

Default

Meaning

CODESYS_TIMEOUT_MS

660000

Timeout for one request. On timeout the IDE is not killed automatically; the error contains the run directory to inspect

CODESYS_DATA_DIR

%LOCALAPPDATA%\CodesysMcp\standalone

Request temp folders and the engineering.lock file

CODESYS_NOUI

not set

1 adds --noUI. Do not enable on SP21: scripts may not run

Attach-related variables (CODESYS_MODE=attach, CODESYS_ATTACH_*, CODESYS_PID, CODESYS_PROJECT, instance) do not exist in this package. Setting CODESYS_MODE to anything other than spawn is reported as a configuration error.

Find the executable and profile

# Change this to your CODESYS installation
$exe = "C:\Program Files\CODESYS 3.5.21.60\CODESYS\Common\CODESYS.exe"

# The executable must exist and be CODESYS.exe
Test-Path $exe

# Available profile names
$profiles = Join-Path (Split-Path (Split-Path $exe -Parent) -Parent) "Profiles"
Get-ChildItem "$profiles\*.profile.xml" |
  ForEach-Object { $_.Name -replace '\.profile\.xml$', '' }

Validate the configuration

$env:CODESYS_EXE = "C:\Program Files\CODESYS 3.5.21.60\CODESYS\Common\CODESYS.exe"
$env:CODESYS_PROFILE = "CODESYS V3.5 SP21 Patch 6"
node tools/check-config.mjs

Expected output:

CODESYS_EXE      = C:\Program Files\CODESYS 3.5.21.60\CODESYS\Common\CODESYS.exe
CODESYS_PROFILE  = CODESYS V3.5 SP21 Patch 6
CODESYS_TIMEOUT_MS = 660000
CODESYS_DATA_DIR = C:\Users\<user>\AppData\Local\CodesysMcp\standalone
Profiles dir     = C:\Program Files\CODESYS 3.5.21.60\CODESYS\Profiles

Available profiles:
  - CODESYS V3.5 SP21 Patch 6

Data directory: writable
Configuration OK.

On failure the command lists every problem and exits with code 1.

MCP client configuration

Claude Desktop, Cursor, or any MCP client that supports stdio:

{
  "mcpServers": {
    "codesys": {
      "command": "node",
      "args": ["C:/Tools/codesys-mcp-standalone/server.mjs"],
      "env": {
        "CODESYS_EXE": "C:/Program Files/CODESYS 3.5.21.60/CODESYS/Common/CODESYS.exe",
        "CODESYS_PROFILE": "CODESYS V3.5 SP21 Patch 6"
      }
    }
  }
}

Forward slashes work on Windows. If you use backslashes, double them in JSON (C:\\Program Files\\...). A ready-to-edit file is included at examples/mcp-config.json.

Tool

The server exposes exactly one tool: codesys_engineering.

Field

Type

Meaning

action

create_empty or batch

Create a new empty project container, or run steps

project

string

Absolute path to a .project file

isolated

boolean

Optional: use an isolated user profile so an already-open IDE does not block the run

steps

array

1..200 { "op": "...", "args": { ... } } objects; only for batch

batch stops on the first error. Compiler errors also stop the remaining steps. Failed batches are not retried.

Create an empty project

{
  "action": "create_empty",
  "project": "C:/work/demo.project"
}

create_empty creates only the project container (no controller). Add devices with the add_device operation.

Read and edit

{
  "action": "batch",
  "project": "C:/work/demo.project",
  "steps": [
    { "op": "tree", "args": {} },
    { "op": "read", "args": { "path": "Application/PLC_PRG" } },
    { "op": "write", "args": { "path": "Application/PLC_PRG", "implementation": "n := n + 1;" } },
    { "op": "compile", "args": {} },
    { "op": "save", "args": {} }
  ]
}

Only save (or save: true on a step) writes the project back to its current path. save_as, convert, and open_archive write to the paths you specify; export/build operations write only the output file you pass.

Operations

Group

Operations

Read

tree list find list_device_types list_libraries project_info device_parameters symbol_config task_config read read_lines text_list image_pool trace

Edit

edit_text patch write create add_device rename move delete set_text_list set_image_pool set_trace

Build

compile rebuild clean generate_code create_boot_application is_uptodate is_online_change_possible

Project/files

save save_as save_archive open_archive convert export_xml export_native import_xml compare_to

Device/config

set_build_properties add_task update_task configure_device set_device_parameter export_io_mappings import_io_mappings add_library remove_library add_library_placeholder set_library_options set_symbol_config

Full parameters and return shapes: docs/operations.md.

Behavior and safety

  • One request at a time. A second concurrent request is rejected; requests are not queued.

  • A lock file prevents two server processes from running CODESYS at the same time. If a run crashes, inspect the lock file shown in the error before deleting it.

  • delete requires recursive: true when the target has children.

  • open_archive and convert depend on the local CODESYS installation, converters, and licenses. They return a clear error when the environment cannot satisfy them.

  • isolated: true creates a temporary user profile. CODESYS may ask for activation or start with default settings in that profile.

  • No login, download, online value access, gateway, or PLC file transfer is implemented.

Troubleshooting

Message

Fix

CODESYS_EXE is not set

Add it to the MCP client env block

CODESYS_EXE does not exist

Check the absolute path and Test-Path

Only the official CODESYS.exe is supported

Point to the official executable; OEM editions are not supported

CODESYS_PROFILE not found

Use one of the names printed by check-config.mjs

Another CODESYS instance is open

Close it, or pass isolated: true

Engineering session locked

Another run is active or crashed; inspect the lock path in the message

Timeout

Inspect the run directory in the error; check the IDE window and license state

License

MIT. See LICENSE.

Available Tools

1 tool
codesys_engineeringA

Official CODESYS engineering through the ScriptEngine, spawn-only. Launches a private CODESYS.exe --runscript process, edits the given .project file, and exits. Without save=true nothing is written to disk. No attach mode, no plugin, no online/PLC access. Requires CODESYS_EXE and CODESYS_PROFILE environment variables; run "node tools/check-config.mjs" to validate them. create_empty creates a new empty .project container (no controller). batch runs 1..200 steps and stops on the first failure. Close other CODESYS instances first, or pass isolated=true for a separate user profile.

Inputs: action (required), project (required), steps, isolated.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 1 tool

    Disambiguation5/5

    There is only one tool, so an agent cannot misselect between competing options. The internal sub-operations (create_empty, batch, save) are documented within the single description rather than exposed as separate confusable tools.

    Naming Consistency4/5

    With a single tool there is nothing to be inconsistent with, and codesys_engineering is clear and snake_case. It is a noun/domain name rather than the verb_noun convention, which is a minor deviation but not confusing.

    Tool Count3/5

    A single monolithic tool covering an entire CODESYS engineering domain feels thin, essentially a dispatcher hiding create/batch/save operations behind one entry point. It is defensible as a deliberately minimal spawn-only wrapper, but offers no granular surface.

    Completeness3/5

    The offline project-file editing scope is coherent (create empty container, batch edits, optional save), but notable gaps exist: no read/inspect operations, no listing or deleting project objects, and explicitly no online/PLC or attach access. Agents can do write workflows but have limited introspection.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables local stdio-based MCP integration with InoProShop/CODESYS for project structure reading, POU editing with verified writes, compilation, task configuration, and persistent session recovery.
      6
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables driving any installed CODESYS 3.5 version (SP18–SP22) from a single MCP server, automatically selecting the right install from each project file's saved version. Exposes 127 tools covering project and POU authoring, compile, online/runtime control, devices and tasks, symbol configuration, multi-device projects, and a version plus git release pipeline.
      7
      MIT