Skip to main content
Glama

validate_template_parameters

Validate ComfyUI workflow template parameters before execution to identify errors and warnings, ensuring compatibility and preventing runtime failures.

Instructions

Validate parameters for a template without generating.

Checks if provided parameters are valid for the template and returns detailed validation results.

Args: template_name: Name of the template parameters: Dictionary of parameters to validate

Returns: Validation results with errors and warnings

Examples: validate_template_parameters("text2img_basic", {"width": "512"})

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
template_nameYes
parametersYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler and registration for validate_template_parameters. Delegates to template_manager for validation logic.
    @mcp.tool
    def validate_template_parameters(
        template_name: str,
        parameters: dict
    ) -> dict:
        """Validate parameters for a template without generating.
        
        Checks if provided parameters are valid for the template
        and returns detailed validation results.
        
        Args:
            template_name: Name of the template
            parameters: Dictionary of parameters to validate
        
        Returns:
            Validation results with errors and warnings
        
        Examples:
            validate_template_parameters("text2img_basic", {"width": "512"})
        """
        try:
            validation = template_manager.validate_parameters(template_name, parameters)
            return validation
            
        except Exception as e:
            raise ToolError(f"Error validating parameters: {e}")
  • Core validation logic in TemplateManager class. Extracts parameters from DSL using regex, checks for missing/extra params, and validates common parameter types (width, steps, cfg, etc.).
    def validate_parameters(
        self, 
        template_name: str, 
        parameters: Dict[str, str],
        source: str = "auto"
    ) -> Dict[str, List[str]]:
        """Validate parameters for a template."""
        # Try to find template in custom or official
        template = None
        if source in ["auto", "custom"]:
            template = self.custom_templates.get(template_name)
        
        if not template and source in ["auto", "official"]:
            official_template = official_manager.get_template(template_name)
            if official_template and official_template.dsl_content:
                # Create minimal template object for validation
                template = type('Template', (), {
                    'parameters': {},
                    'dsl_content': official_template.dsl_content
                })()
        if not template:
            return {
                "valid": False,
                "errors": [f"Template '{template_name}' not found"],
                "warnings": []
            }
        
        errors = []
        warnings = []
        
        # Check for required parameters (those in template but not provided)
        template_params = template.parameters or {}
        required_params = set(self._extract_parameters_from_dsl(template.dsl_content))
        provided_params = set(parameters.keys())
        
        missing_params = required_params - provided_params
        if missing_params:
            errors.append(f"Missing required parameters: {', '.join(missing_params)}")
        
        # Check for extra parameters
        extra_params = provided_params - required_params
        if extra_params:
            warnings.append(f"Extra parameters will be ignored: {', '.join(extra_params)}")
        
        # Validate specific parameter types/constraints
        for param_name, param_value in parameters.items():
            if param_name in template_params:
                validation_errors = self._validate_parameter_value(
                    param_name, param_value, template_name
                )
                errors.extend(validation_errors)
        
        return {
            "valid": len(errors) == 0,
            "errors": errors,
            "warnings": warnings
        }
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses the tool's behavior: it validates parameters and returns detailed results with errors and warnings. However, it does not mention authentication needs, rate limits, side effects, or what constitutes 'valid' parameters. The description adds basic context but lacks depth for a validation tool with no annotation coverage.

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 well-structured with clear sections (purpose, args, returns, examples) and uses only essential sentences. It is front-loaded with the core purpose. Minor improvements could include merging or trimming some lines, but overall it is efficient and easy to scan.

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?

Given 2 parameters, 0% schema coverage, no annotations, but an output schema exists, the description is reasonably complete. It covers purpose, parameters, returns, and includes an example. However, for a validation tool, more details on error formats or validation rules would enhance completeness, though the output schema may cover return values.

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%, so the description must compensate. It explains both parameters: 'template_name' as the name of the template and 'parameters' as a dictionary to validate. The example illustrates usage but does not detail parameter formats or constraints. The description adds meaningful semantics beyond the bare schema, though not exhaustively.

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 clearly states the specific action ('validate parameters for a template without generating'), identifies the resource ('template'), and distinguishes it from siblings like 'generate_from_template' (which would generate) and 'validate_workflow' (which validates workflows, not template parameters). The phrase 'without generating' explicitly differentiates it from generation tools.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool: to check parameter validity before generation. It implies an alternative ('generate_from_template') but does not explicitly state when NOT to use it or compare with other validation tools like 'validate_workflow'. The guidance is helpful but lacks explicit exclusions or detailed comparisons.

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/christian-byrne/comfy-mcp'

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