Skip to main content
Glama
agenticcontrolio

TwinCAT Validator MCP Server

validate_file

Validate TwinCAT automation project files for code quality, structural integrity, and compliance with IEC 61131-3 standards to ensure safe compilation and import.

Instructions

Validate a single TwinCAT file.

Args: file_path: Path to TwinCAT file validation_level: "all", "critical", or "style" profile: Output profile - "full" (verbose, default) or "llm_strict" (minimal) intent_profile: Programming paradigm intent — "auto" (default), "procedural", or "oop". Controls which check families run: - "procedural": OOP checks are skipped. - "oop": Full OOP check family is enforced. - "auto": Resolved from file content (EXTENDS/IMPLEMENTS → oop, else procedural).

Returns: JSON string with validation results.

Full profile includes: validation_status, checks array, issues with Phase 3
enrichment, metrics, timing.

LLM strict profile includes only: file_path, safe_to_import, safe_to_compile,
blocking_count, blockers (unfixable errors).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
validation_levelNoall
profileNofull
enforcement_modeNostrict
intent_profileNoauto

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function 'validate_file' which validates a single TwinCAT file using the validation_engine.
    def validate_file(
        file_path: str,
        validation_level: str = "all",
        profile: str = "full",
        enforcement_mode: str = DEFAULT_ENFORCEMENT_MODE,
        intent_profile: str = "auto",
    ) -> str:
        """Validate a single TwinCAT file.
    
        Args:
            file_path: Path to TwinCAT file
            validation_level: "all", "critical", or "style"
            profile: Output profile - "full" (verbose, default) or "llm_strict" (minimal)
            intent_profile: Programming paradigm intent — "auto" (default), "procedural",
                or "oop".  Controls which check families run:
                - "procedural": OOP checks are skipped.
                - "oop": Full OOP check family is enforced.
                - "auto": Resolved from file content (EXTENDS/IMPLEMENTS → oop, else procedural).
    
        Returns:
            JSON string with validation results.
    
            Full profile includes: validation_status, checks array, issues with Phase 3
            enrichment, metrics, timing.
    
            LLM strict profile includes only: file_path, safe_to_import, safe_to_compile,
            blocking_count, blockers (unfixable errors).
        """
        _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(file_path, enforcement_mode=enforcement_mode)
            if intent_profile not in _VALID_INTENT_PROFILES:
                return _tool_error(
                    f"Invalid intent_profile: {intent_profile}",
                    file_path=file_path,
                    start_time=_t0,
                    execution_context=ctx,
                    valid_intent_profiles=list(_VALID_INTENT_PROFILES),
                )
            if validation_level not in ["all", "critical", "style"]:
                return _tool_error(
                    f"Invalid validation_level: {validation_level}",
                    file_path=file_path,
                    start_time=_t0,
                    execution_context=ctx,
                    valid_levels=["all", "critical", "style"],
                )
            profile_error = _validate_profile(profile, start_time=_t0, execution_context=ctx)
            if profile_error:
                return profile_error
    
            path, error = _validate_file_path(file_path, start_time=_t0, execution_context=ctx)
            if error:
                return error
    
            file = TwinCATFile.from_path(path)
    
            _intent_resolved = _resolve_intent_profile(file.content, intent_profile)
            _exclude_cats = frozenset({"oop"}) if _intent_resolved == "procedural" else None
    
            engine_start = time.time()
            engine_result = validation_engine.validate(
                file, validation_level, exclude_categories=_exclude_cats
            )
            validation_time = time.time() - engine_start
    
            result = _convert_engine_result_to_mcp_format(
                engine_result, file, validation_time, validation_level, profile
            )
            result["success"] = True
    
            return _with_meta(result, _t0, execution_context=ctx)
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It successfully discloses behavioral traits: it explains the resolution logic for 'auto' intent detection (EXTENDS/IMPLEMENTS → oop), details the differences between output profiles (Full vs LLM strict), and describes the return structure. It does not mention side effects or authorization requirements.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description uses a clear docstring structure (Args/Returns) with good information density. Every sentence earns its place, explaining either parameter semantics or output format. Minor verbosity in the intent_profile bullet points is justified by the complexity of the concept.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 5 parameters (one undocumented) and no annotations, the description is nearly complete. It compensates for the lack of schema descriptions for most parameters and provides detailed output documentation (acting as output schema). Deducted one point for the missing 'enforcement_mode' parameter explanation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, requiring the description to compensate. It provides detailed semantic meaning for 4 of 5 parameters: validation_level options, profile behavior, and extensive detail on intent_profile including resolution rules. However, it completely omits the 'enforcement_mode' parameter present in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb ('Validate') and resource ('TwinCAT file'), clearly stating the tool's function. The word 'single' effectively distinguishes it from the sibling 'validate_batch' tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

While the description explains parameter-specific usage (e.g., when to use 'full' vs 'llm_strict' profiles, or 'procedural' vs 'oop' intent), it lacks explicit guidance on when to choose this tool over siblings like 'validate_for_import' or 'autofix_file'. The 'single' qualifier provides implied context but no explicit alternatives are named.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/agenticcontrolio/twincat-validator-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server