CODESYS MCP server

Integrates with CODESYS V3 automation programming environments through Python scripting to enable project management, POU creation and editing, code manipulation, and compilation tasks for PLC development workflows.
Back to servers
Setup instructions
Provider
johannesPettersson80
Release date
May 28, 2025
Language
JavaScript
Stats
5 stars

This toolkit enables MCP clients like Claude Desktop to interact with CODESYS V3 programming environments. It allows you to automate project management, POU creation, code editing, and compilation tasks through the CODESYS Scripting Engine.

Installation

Install the toolkit globally using npm:

npm install -g @codesys/mcp-toolkit

This makes the codesys-mcp-tool command available in your system's terminal PATH.

Prerequisites

Before using the toolkit, ensure you have:

  • CODESYS V3 (tested with 3.5 SP21) with the Scripting Engine component enabled
  • Node.js version 18.0.0 or later
  • An MCP-enabled application (e.g., Claude Desktop)

Configuration

Recommended Configuration Method

Configure your MCP client (like Claude Desktop) to run the installed command directly.

Example for Claude Desktop (settings.json -> mcpServers):

{
  "mcpServers": {
    "codesys_local": {
      "command": "codesys-mcp-tool",
      "args": [
        "--codesys-path", "C:\\Program Files\\Path\\To\\Your\\CODESYS\\Common\\CODESYS.exe",
        "--codesys-profile", "Your CODESYS Profile Name"
        // Optional: Add --workspace "/path/to/your/projects" if needed
      ]
    }
  }
}

Important steps:

  1. Replace the CODESYS.exe path with your actual installation path
  2. Replace the profile name with your CODESYS profile name
  3. Restart your MCP client application after configuration

Alternative Configuration (Not Recommended)

Using npx can cause errors in some environments:

{
  "mcpServers": {
    "codesys_local": {
      "command": "npx",
      "args": [
        "-y",
        "@codesys/mcp-toolkit",
        "--codesys-path", "C:\\Program Files\\Path\\To\\Your\\CODESYS\\Common\\CODESYS.exe",
        "--codesys-profile", "Your CODESYS Profile Name"
      ]
    }
  }
}

Command-Line Arguments

Available arguments for codesys-mcp-tool:

  • -p, --codesys-path <path>: Full path to CODESYS.exe (required)
  • -f, --codesys-profile <profile>: Name of the CODESYS profile (required)
  • -w, --workspace <dir>: Workspace directory for resolving relative paths
  • -h, --help: Show help message
  • --version: Show package version

Features

Project Management

  • Open existing CODESYS projects (open_project)
  • Create new projects from 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
  • codesys://project/{+project_path}/structure: Retrieve project structure
  • codesys://project/{+project_path}/pou/{+pou_path}/code: Read code for a specified POU, Method, or Property

Troubleshooting

Common Issues

  • 'C:\Program' is not recognized... error:

    • Configure your MCP client to run the command directly rather than using npx
  • Tool fails or errors in output:

    • Check MCP client logs for INTEROP: messages or Python DEBUG: / ERROR: messages
    • Verify correct paths and arguments
    • Ensure no other CODESYS instances are running in conflicting ways
  • command not found: codesys-mcp-tool:

    • Verify global installation (npm install -g @codesys/mcp-toolkit)
    • Ensure npm global bin directory is in your system's PATH
  • Check logs:

    • Claude Desktop logs on Windows: C:\Users\<YourUsername>\AppData\Roaming\Claude\logs\

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "codesys_local" '{"command":"codesys-mcp-tool","args":["--codesys-path","C:\\Program Files\\Path\\To\\Your\\CODESYS\\Common\\CODESYS.exe","--codesys-profile","Your CODESYS Profile Name"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "codesys_local": {
            "command": "codesys-mcp-tool",
            "args": [
                "--codesys-path",
                "C:\\Program Files\\Path\\To\\Your\\CODESYS\\Common\\CODESYS.exe",
                "--codesys-profile",
                "Your CODESYS Profile Name"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "codesys_local": {
            "command": "codesys-mcp-tool",
            "args": [
                "--codesys-path",
                "C:\\Program Files\\Path\\To\\Your\\CODESYS\\Common\\CODESYS.exe",
                "--codesys-profile",
                "Your CODESYS Profile Name"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later