Skip to main content
Glama

get_template_dsl

Retrieve DSL content for ComfyUI templates to modify or execute workflows. Specify template name and source to access custom or official workflow definitions.

Instructions

Get DSL content for any template (custom or official).

Retrieves the DSL representation of a template, which can then be modified or executed directly.

Args: template_name: Name of the template source: Template source ("custom", "official", or "auto")

Returns: Template DSL content and metadata

Examples: get_template_dsl("text2img_basic") get_template_dsl("openai_dalle_3_text_to_image", "official")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
template_nameYes
sourceNoauto

Implementation Reference

  • The core handler function for the 'get_template_dsl' MCP tool, decorated with @mcp.tool. It generates DSL workflow content from a template using template_manager and returns it with metadata.
    @mcp.tool
    def get_template_dsl(template_name: str, source: str = "auto") -> dict:
        """Get DSL content for any template (custom or official).
        
        Retrieves the DSL representation of a template, which can then
        be modified or executed directly.
        
        Args:
            template_name: Name of the template
            source: Template source ("custom", "official", or "auto")
        
        Returns:
            Template DSL content and metadata
        
        Examples:
            get_template_dsl("text2img_basic")
            get_template_dsl("openai_dalle_3_text_to_image", "official")
        """
        try:
            # Try to get DSL content
            dsl_content = template_manager.generate_workflow(
                template_name, 
                parameters=None,
                source=source
            )
            
            if dsl_content is None:
                raise ToolError(f"Template '{template_name}' not found or has no DSL content")
            
            # Get template metadata
            template_info = None
            if source in ["auto", "custom"]:
                template_info = template_manager.get_template_info(template_name)
            
            if not template_info and source in ["auto", "official"]:
                official_template = template_manager.get_official_template(template_name)
                if official_template:
                    template_info = {
                        "name": template_name,
                        "display_name": official_template.name,
                        "description": official_template.description,
                        "category": official_template.category,
                        "source": "official",
                        "source_url": official_template.source_url,
                        "preview_images": official_template.preview_images or []
                    }
            
            return {
                "template_name": template_name,
                "dsl_content": dsl_content,
                "metadata": template_info or {},
                "source": source
            }
            
        except Exception as e:
            raise ToolError(f"Error getting template DSL: {e}")

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