Skip to main content
Glama
ilhankilic

YaparAI MCP Server

by ilhankilic

execute_template

Generate content by running a pre-built AI workflow with your text prompt, optional image, and template-specific inputs.

Instructions

Execute a ComfyUI template to generate content.

Runs a pre-built AI workflow with your inputs. Each template has different capabilities — use get_template_detail() first to see what inputs are accepted. Credits are deducted based on the template.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
slugYesTemplate slug (e.g., "flux-logo-generator", "product-photo-enhancer")
promptYesMain text prompt for the template
image_urlNoInput image URL (required for image-based templates)
widthNoOutput width in pixels (64-2048)
heightNoOutput height in pixels (64-2048)
extra_inputsNoAdditional template-specific inputs (see get_template_detail). e.g., {"brand_color": "#FF0000", "logo_text": "ACME Corp"}

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main tool handler: async function execute_template that builds a payload, calls the client, and optionally polls for results.
    async def execute_template(
        slug: str,
        prompt: str,
        image_url: str | None = None,
        width: int = 512,
        height: int = 512,
        extra_inputs: dict | None = None,
    ) -> dict:
        """
        Execute a ComfyUI template to generate content.
    
        Runs a pre-built AI workflow with your inputs. Each template has
        different capabilities — use get_template_detail() first to see
        what inputs are accepted. Credits are deducted based on the template.
    
        Args:
            slug: Template slug (e.g., "flux-logo-generator", "product-photo-enhancer")
            prompt: Main text prompt for the template
            image_url: Input image URL (required for image-based templates)
            width: Output width in pixels (64-2048)
            height: Output height in pixels (64-2048)
            extra_inputs: Additional template-specific inputs (see get_template_detail).
                          e.g., {"brand_color": "#FF0000", "logo_text": "ACME Corp"}
    
        Returns:
            Dict with job_id, status, and result info.
        """
        client = YaparAIClient()
        payload: dict = {
            "prompt": prompt,
            "width": width,
            "height": height,
        }
        if image_url:
            payload["image_url"] = image_url
        if extra_inputs:
            payload.update(extra_inputs)
    
        result = await client.execute_template(slug, payload)
    
        # If the template returns a job_id, poll for result
        job_id = result.get("job_id")
        if job_id:
            final = await client.wait_for_result(job_id, timeout=120)
            return {
                "status": "success",
                "result_url": final.get("result_url"),
                "job_id": job_id,
                "credits_used": result.get("credits_used"),
                "balance_remaining": result.get("balance_remaining"),
            }
    
        return result
  • The docstring serves as the tool's schema/description, defining inputs (slug, prompt, image_url, width, height, extra_inputs) and return type.
    ) -> dict:
        """
        Execute a ComfyUI template to generate content.
    
        Runs a pre-built AI workflow with your inputs. Each template has
        different capabilities — use get_template_detail() first to see
        what inputs are accepted. Credits are deducted based on the template.
    
        Args:
            slug: Template slug (e.g., "flux-logo-generator", "product-photo-enhancer")
            prompt: Main text prompt for the template
            image_url: Input image URL (required for image-based templates)
            width: Output width in pixels (64-2048)
            height: Output height in pixels (64-2048)
            extra_inputs: Additional template-specific inputs (see get_template_detail).
                          e.g., {"brand_color": "#FF0000", "logo_text": "ACME Corp"}
    
        Returns:
            Dict with job_id, status, and result info.
        """
  • Registration of the execute_template function as an MCP tool via mcp.tool(execute_template).
    mcp.tool(execute_template)
  • Import of execute_template from yaparai.tools.templates into the server module.
        execute_template,
    )
  • The HTTP client method that sends the POST request to /v1/comfy-templates/{slug}/execute with the payload.
    async def execute_template(self, slug: str, payload: dict) -> dict:
        """Execute a ComfyUI template."""
        return await self._request("POST", f"/v1/comfy-templates/{slug}/execute", json=payload)
Behavior3/5

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

Without annotations, the description adds context about credit deduction and prerequisite but omits key behaviors like synchronous vs. asynchronous execution, return value structure, or error handling, making it adequate but not rich.

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 relatively concise with three sentences, though the first line is somewhat redundant with the tool name. Information is front-loaded effectively.

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

Completeness3/5

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

Given the presence of an output schema, the description provides basic context but lacks information about execution time, job status checks, or error scenarios, leaving gaps for a complex tool.

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 input schema has 100% coverage with clear descriptions, and the description adds value by noting that extra_inputs varies by template, but does not expand on other parameters beyond schema defaults.

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 tool executes a ComfyUI template to generate content, distinguishing it from other generation tools by emphasizing pre-built workflows and referencing get_template_detail for input details.

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 advises using get_template_detail first to understand template-specific inputs, providing clear context on when to use the tool but lacks explicit exclusions or comparisons to alternative tools.

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/ilhankilic/yaparai-mcp'

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