Skip to main content
Glama
agenticcontrolio

TwinCAT Validator MCP Server

check_specific

Run selected validation checks on TwinCAT files to verify code quality and IEC 61131-3 OOP compliance for industrial automation projects.

Instructions

Run specific validation checks on a TwinCAT file.

Args: file_path: Path to TwinCAT file check_names: List of check IDs to run

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
check_namesYes
enforcement_modeNostrict

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The implementation of the check_specific MCP tool.
    def check_specific(
        file_path: str,
        check_names: list[str],
        enforcement_mode: str = DEFAULT_ENFORCEMENT_MODE,
    ) -> str:
        """Run specific validation checks on a TwinCAT file.
    
        Args:
            file_path: Path to TwinCAT file
            check_names: List of check IDs to run
        """
        _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)
            check_id_map = config.check_id_map
    
            check_ids = []
            for name in check_names:
                check_id = check_id_map.get(name, name)
                check_ids.append(check_id)
    
            valid_checks = set(config.validation_checks.keys())
            invalid = set(check_ids) - valid_checks
            if invalid:
                return _tool_error(
                    f"Invalid check names: {', '.join(invalid)}",
                    file_path=file_path,
                    start_time=_t0,
                    execution_context=ctx,
                    valid_checks=sorted(list(valid_checks)),
                )
    
            path, error = _validate_file_path(file_path, start_time=_t0, execution_context=ctx)
            if error:
                return error
    
            file = TwinCATFile.from_path(path)
    
            all_issues = []
            check_results = []
            for check_id in check_ids:
                if check_id in config.disabled_checks:
                    continue
    
                try:
                    from twincat_validator.exceptions import CheckNotFoundError
    
                    check_class = CheckRegistry.get_check(check_id)
                except CheckNotFoundError:
                    continue
    
                check = check_class()
                if check.should_skip(file):
                    continue
    
                issues = check.run(file)
                if check_id in config.severity_overrides:
                    for issue in issues:
                        issue.severity = config.severity_overrides[check_id]
                for issue in issues:
                    issue.check_id = (
                        check_id  # stamp for dedupe/tracing parity with ValidationEngine
                    )
                    if issue.line_num is not None:
                        _apply_known_limitation_tags(check_id, issue, file)
                        continue
                    line_num, column = infer_issue_location(file.content, check_id, issue.message)
                    issue.line_num = line_num
                    issue.column = column
                    _apply_known_limitation_tags(check_id, issue, file)
    
                all_issues.extend(issues)
                check_config = config.validation_checks.get(check_id, {})
    
                if any(i.severity in ("error", "critical") for i in issues):
                    status = "failed"
                elif any(i.severity == "warning" for i in issues):
                    status = "warning"
                else:
                    status = "passed"
    
                check_results.append(
                    {
                        "id": check_id,
                        "name": check_config.get("name", "Unknown Check"),
                        "status": status,
                        "message": check_config.get("description", ""),
                        "auto_fixable": check_config.get("auto_fixable", False),
                        "severity": check_config.get("severity", "info"),
                    }
                )
    
            passed = sum(1 for c in check_results if c["status"] == "passed")
            failed = sum(1 for c in check_results if c["status"] == "failed")
            warnings = sum(1 for c in check_results if c["status"] == "warning")
    
            validation_status = "passed"
            if failed > 0:
                validation_status = "failed"
            elif warnings > 0:
                validation_status = "warnings"
    
            all_issues = _dedupe_validation_issues(all_issues)
            result = {
                "success": True,
                "file_path": str(path),
                "validation_status": validation_status,
                "checks_requested": len(check_names),
                "summary": {"passed": passed, "failed": failed, "warnings": warnings},
                "checks": check_results,
                "issues": [issue.to_dict() for issue in all_issues],
            }
    
            return _with_meta(result, _t0, execution_context=ctx)
    
        except Exception as e:
            error_kwargs = {"execution_context": ctx}
            if ctx is None:
                error_kwargs.update(unresolved_policy_fields(enforcement_mode))
            return _tool_error(
                str(e),
                file_path=file_path,
                start_time=_t0,
                **error_kwargs,
            )
Behavior2/5

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

With no annotations provided, the description carries the full burden but fails to disclose key behavioral traits. It does not indicate whether the tool modifies the TwinCAT file (though likely read-only given 'autofix' siblings exist), what the output schema contains, or how to interpret the 'enforcement_mode' parameter's behavior.

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 is appropriately concise with a clear imperative sentence followed by an Args section. Structure is front-loaded with the purpose statement first. The only inefficiency is the omission of the 'enforcement_mode' parameter from the Args list.

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

Completeness2/5

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

Given 0% schema coverage and no annotations, the description is insufficient for a 3-parameter tool. It fails to document the 'enforcement_mode' parameter and provides no context on return values (though an output schema exists, the agent still needs to know what the tool conceptually returns) or side effects.

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

Parameters3/5

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

The Args section adds semantic value for 'file_path' (specifying it is a TwinCAT file) and 'check_names' (clarifying they are check IDs), partially compensating for the 0% schema description coverage. However, it completely omits the third parameter 'enforcement_mode' (default: 'strict'), leaving its behavioral impact unexplained.

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

Purpose4/5

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

The description clearly states the tool 'Run[s] specific validation checks on a TwinCAT file,' providing a specific verb and resource. However, it does not explicitly distinguish from sibling tools like 'validate_file' or 'validate_batch,' leaving the agent to infer the distinction from the word 'specific' and the required 'check_names' parameter.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like 'validate_file' (likely full validation) or 'check_specific' (targeted validation). The description does not state prerequisites (e.g., needing valid check IDs) or exclusions.

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