generate_skeleton
Generate canonical TwinCAT XML skeleton files for automation projects. Create structured templates for .TcPOU, .TcDUT, .TcGVL, or .TcIO file types with proper IEC 61131-3 formatting.
Instructions
Generate canonical deterministic TwinCAT XML skeleton for a file type.
Args: file_type: .TcPOU, .TcDUT, .TcGVL, or .TcIO (with or without leading dot) subtype: For .TcPOU only: function_block, function, or program
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_type | Yes | ||
| subtype | No | ||
| enforcement_mode | No | strict |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The 'generate_skeleton' function serves as an MCP tool handler, responsible for generating a standard TwinCAT XML skeleton based on the provided file type and optional subtype. It validates inputs, invokes a helper to build the skeleton, and returns the result with metadata.
def generate_skeleton( file_type: str, subtype: Optional[str] = None, enforcement_mode: str = DEFAULT_ENFORCEMENT_MODE, ) -> str: """Generate canonical deterministic TwinCAT XML skeleton for a file type. Args: file_type: .TcPOU, .TcDUT, .TcGVL, or .TcIO (with or without leading dot) subtype: For .TcPOU only: function_block, function, or program """ _t0 = time.monotonic() ctx = None try: mode_error = _validate_enforcement_mode(enforcement_mode, start_time=_t0) if mode_error: return mode_error ctx = _resolve_execution_context("", enforcement_mode=enforcement_mode) except Exception as exc: return _tool_error( str(exc), start_time=_t0, **unresolved_policy_fields(enforcement_mode), ) skeleton, error = _build_contract_skeleton(file_type, subtype) if error: return _tool_error( error, start_time=_t0, execution_context=ctx, supported_file_types=config.supported_extensions, supported_pou_subtypes=list(SUPPORTED_POU_SUBTYPES), ) normalized = _normalize_file_type(file_type) result = { "success": True, "file_type": normalized, "subtype": subtype.lower() if subtype and normalized == ".TcPOU" else None, "contract_version": config.get_generation_contract().get("version", "unknown"), "skeleton": skeleton, "note": ( "Fill placeholders (name/GUID/declaration/ST body), " "then run autofix_file with strict_contract=true." ), } return _with_meta(result, _t0, execution_context=ctx)