mcp protocol translation to codesys scripting engine operations
Implements a Model Context Protocol server that translates standardized MCP requests into CODESYS Scripting Engine operations through a layered architecture. The McpServer class from the MCP SDK handles protocol negotiation and request routing, while a Python script execution layer bridges MCP tool calls to CODESYS automation APIs. This enables AI clients (like Claude Desktop) to programmatically control CODESYS V3 environments without direct API knowledge.
Unique: Implements MCP as a bridge to CODESYS Scripting Engine rather than wrapping REST APIs, enabling direct automation environment control. Uses Python script templating to generate and execute CODESYS-specific automation scripts, avoiding the need for compiled CODESYS plugins.
vs alternatives: Provides standardized MCP protocol access to CODESYS where no native MCP server existed, enabling AI integration without custom REST API development or CODESYS plugin compilation.
codesys project lifecycle management via mcp tools
Exposes MCP tools for complete project lifecycle operations: open_project, create_project, save_project, and compile_project. Each tool translates MCP parameters into Python scripts that invoke CODESYS Scripting Engine APIs to manipulate project files, manage in-memory project state, and trigger compilation with error reporting. The toolkit maintains awareness of the currently open project context across multiple tool invocations within a single MCP session.
Unique: Manages CODESYS project state across multiple MCP tool invocations within a single session, maintaining context of the currently open project. Uses Python script generation to invoke CODESYS Scripting Engine APIs directly, avoiding the need for external build tools or command-line compilers.
vs alternatives: Provides programmatic project management without requiring CODESYS GUI interaction or external build system integration, enabling seamless AI-driven automation workflows.
pou (program organization unit) code generation and manipulation
Implements MCP tools for creating and modifying POUs (Programs, Function Blocks, Functions) with separate declaration and implementation code sections. The create_pou tool generates new POUs with specified type and initial code, while set_pou_code updates existing POU code. The toolkit reads POU code through MCP resources (codesys://project/{path}/pou/{pou_path}/code) that parse CODESYS project XML to extract declaration and implementation sections separately, enabling AI systems to understand and modify POU structure.
Unique: Separates POU declaration and implementation code into distinct read/write operations, enabling AI systems to understand and modify POU interfaces independently from implementation logic. Uses CODESYS project XML parsing to extract code sections without requiring CODESYS GUI interaction.
vs alternatives: Provides structured POU code access and generation where CODESYS GUI requires manual editing, enabling programmatic code generation and analysis for AI-assisted development.
function block property and method generation
Exposes MCP tools create_property and create_method for adding properties and methods to Function Blocks. These tools generate Python scripts that invoke CODESYS Scripting Engine APIs to add typed properties (with getter/setter code) and methods (with parameters and return types) to existing Function Blocks. The toolkit handles the code generation for property accessors and method stubs, reducing boilerplate for AI-assisted development.
Unique: Automates property and method stub generation for Function Blocks through MCP tools, reducing manual boilerplate while maintaining CODESYS Scripting Engine compatibility. Generates getter/setter code patterns automatically rather than requiring manual implementation.
vs alternatives: Provides programmatic Function Block interface scaffolding where CODESYS GUI requires manual property/method creation, enabling faster AI-assisted development of complex Function Block hierarchies.
project structure introspection via mcp resources
Implements MCP resource endpoints (codesys://project/{path}/structure) that parse CODESYS project XML files to expose hierarchical project structure as queryable resources. The toolkit extracts object metadata (POUs, properties, methods, variables) from the project file and returns structured JSON representations without requiring CODESYS GUI interaction. This enables AI clients to understand project topology for code generation, refactoring, or analysis tasks.
Unique: Parses CODESYS project XML directly to expose structure as MCP resources without requiring CODESYS GUI or Scripting Engine execution, enabling fast read-only access to project metadata. Returns hierarchical JSON representation suitable for AI context and code generation planning.
vs alternatives: Provides fast, read-only project structure access without CODESYS process overhead, enabling AI systems to understand project topology for informed code generation decisions.
codesys scripting engine status monitoring via mcp resources
Implements MCP resource endpoint (codesys://project/status) that queries CODESYS Scripting Engine state and returns current project status, including whether a project is open, the current project file path, unsaved changes flag, and scripting engine availability. This resource is generated by executing a Python script that invokes CODESYS Scripting Engine APIs to introspect runtime state, enabling MCP clients to determine system readiness before executing project operations.
Unique: Provides real-time CODESYS Scripting Engine status through MCP resources by executing Python scripts that query engine APIs, enabling clients to detect system readiness without direct CODESYS process access. Returns structured status object suitable for conditional workflow logic.
vs alternatives: Enables MCP clients to verify CODESYS availability and project state before executing operations, preventing failed automation attempts and improving error handling in CI/CD pipelines.
python script template generation and execution for codesys automation
Implements a Python script templating system that generates CODESYS Scripting Engine automation scripts from MCP tool parameters. The toolkit maintains Python script templates for each operation (project management, POU creation, compilation) that are populated with parameters and executed via subprocess calls. This approach decouples MCP protocol handling from CODESYS-specific logic, enabling easy extension with new operations and version-specific script variants.
Unique: Uses Python script templating to generate and execute CODESYS Scripting Engine operations, enabling version-specific automation without modifying core MCP server code. Decouples protocol handling from CODESYS-specific logic through subprocess-based execution.
vs alternatives: Provides extensible automation through script templates rather than compiled plugins, enabling rapid addition of new CODESYS capabilities and support for multiple CODESYS versions without recompilation.
multi-installation codesys environment management
Supports configuration and management of multiple CODESYS installations through environment variables and configuration files. The toolkit can target different CODESYS versions or instances by specifying installation paths, enabling users to work with multiple CODESYS environments through a single MCP server. Configuration is managed via command-line options and environment variables that are passed to Python scripts for installation-specific scripting engine access.
Unique: Enables single MCP server to target multiple CODESYS installations through configuration-based installation path management, allowing teams to work with heterogeneous CODESYS environments without separate server instances per version.
vs alternatives: Provides flexible multi-installation support through configuration rather than requiring separate MCP server instances, simplifying deployment for teams with multiple CODESYS versions.
+2 more capabilities