ComfyUI Skills for OpenClaw

repository·main·Indexed 43 days ago

https://github.com/huangyuchuh/comfyui_skills_openclaw

A bridge that transforms complex ComfyUI workflows into simplified, parameter-driven 'skills' for AI agents. It provides the `comfyui-skill` CLI for executing registered workflows and batch jobs, and integrates with the official Local Comfy MCP for dynamic discovery of templates, nodes, and models. The system uses a schema layer (`schema.json`) to map agent inputs to ComfyUI API-format workflows, ensuring reliable execution and predictable interfaces.

Tokens
19.3K
Snippets
54
Records
92
Agent score
52%

What's inside ComfyUI Skills for OpenClaw

  1. Overview of ComfyUI Skills for OpenClaw

    main

    ComfyUI Skills for OpenClaw is an agent-friendly bridge that transforms ComfyUI workflows into callable skills. Instead of agents manipulating raw ComfyUI graphs, this project provides a clean, schema-based interface via a CLI and an optional Web UI. It is compatible with OpenClaw, Hermes Agent, Codex, Claude Code, and follows the agentskills.io open standard.

    Key capabilities include:

    • Schema-based parameter mapping: Expose only specific fields with clear aliases, types, and descriptions.
    • Workflow Import: Automatically detect formats and create mapping layers from ComfyUI JSON files.
    • Multi-server routing: Manage local and remote ComfyUI servers under a single namespace.
    • Dependency management: Check for missing nodes or models before execution.
    • Agent-friendly CLI: Designed for reliable interaction by shell-capable agents.
  2. Core Capabilities of ComfyUI Skills for OpenClaw

    main

    ComfyUI Skills provides a bridge between ComfyUI workflows and AI agents. Key features include:

    • Agent-native CLI: Provides structured JSON output and is pipe-friendly for tools like Claude Code, Codex, and OpenClaw.
    • Multi-server routing: Allows managing multiple ComfyUI instances under a single namespace.
    • Schema-based parameters: Exposes clean parameter contracts instead of exposing raw, complex graph nodes to the agent.
    • Full lifecycle management: Tools to discover, import, execute, and manage workflows and their dependencies.
    • Official local Comfy MCP: Provides live template, node, model, validation, and orchestration capabilities.
    • Web UI: An optional local dashboard for visual management of workflows.
  3. Why the Schema Layer is used

    main

    Because ComfyUI graphs are highly flexible and contain many internal fields, the schema layer acts as a contract for agents. It narrows the complex graph surface into a predictable interface by providing:

    • Aliases
    • Descriptions
    • Required flags
    • Defined types

    This ensures agent calls are reliable and easier to maintain compared to interacting with raw node fields.

  4. How CLI and Comfy MCP differ in usage

    main

    The project provides two distinct interfaces depending on the task requirements:

    • comfyui-skill CLI: Best for high-efficiency, repetitive, or automated tasks. Use this for running registered workflows, batch processing, uploading files, and accessing execution history.
    • Official Local Comfy MCP: Best for discovery and management. Use this when you need to find available templates, inspect installed nodes/models, validate unfamiliar workflows, or manage the ComfyUI server itself.

    If an Agent host has already integrated the official MCP, the Skill layer will call its tools directly. For Agents with only Shell capabilities, you can use the built-in connection bridge via scripts:

    python ./scripts/comfy_mcp.py probe
    python ./scripts/comfy_mcp.py call search_templates --arguments '{"query":"upscale"}'
  5. Use schemas to standardize agent interactions with ComfyUI

    main

    To prevent an LLM from having to reason about every individual node in a complex ComfyUI graph, you can use a schema layer. This layer acts as a safety and abstraction contract that defines:

    • Which parameters are visible to the agent.
    • Which parameters are required.
    • The expected data types.
    • How these parameters map into specific node fields.
  6. How the workflow execution layer works

    main

    The project acts as a controlled execution layer between an Agent and ComfyUI. This provides a stable calling contract so the Agent doesn't need to understand the raw ComfyUI graph nodes.

    The workflow lifecycle:

    1. Export a workflow from ComfyUI in API format.
    2. Import the workflow and define exposed parameters.
    3. Save the mapping in a schema.json file.
    4. Call the workflow via the comfyui-skill CLI using structured parameters.
    5. The CLI submits the task to the target ComfyUI server and returns the result.

    Data Flow: ComfyUI workflow.json $\rightarrow$ schema.json (mapping) $\rightarrow$ comfyui-skill CLI $\rightarrow$ ComfyUI server $\rightarrow$ Generated output.

  7. How the CLI and Comfy MCP work together in ComfyUI Skill

    main

    The project integrates both the comfyui-skill CLI and the official local Comfy MCP within the same Skill application layer, but they serve different purposes based on the user's intent:

    • comfyui-skill CLI: Best for executing standardized, stable, and repetitive production tasks. Use this for running registered workflows, repeating tasks, or performing batch operations.
    • Official Local Comfy MCP: Best for real-time discovery and complex orchestration. Use this when the user needs to find templates, nodes, or models, validate/modify unfamiliar workflows, or query task statuses and retrieve files.

    Decision Matrix:

    User NeedRecommended Entry Point
    Run existing <server>/<workflow>comfyui-skill CLI
    Repetitive generation or batch executioncomfyui-skill CLI
    Find available templates, nodes, or modelsOfficial MCP
    Validate or modify unfamiliar workflowsOfficial MCP
    Query MCP task status and fetch filesOfficial MCP
    Install, update, restart, switch versions, or handle billingOfficial MCP (after user confirmation)
  8. Route jobs across different ComfyUI servers

    main

    The project supports managing multiple ComfyUI generation targets (e.g., a local GPU, a remote workstation, or a high-memory A100 instance) under a single skill system. You can use server-level and workflow-level enable switches to manage these targets. This allows you to create organized namespaces, such as:

    • local/sdxl-base
    • remote-a100/sdxl-base

    This keeps your workflow identities consistent while routing them to the appropriate hardware.

  9. How CLI and MCP work together

    main

    The project distinguishes between two primary tools for different use cases:

    1. comfyui-skill (CLI): Best for registered workflows, repeated execution, batch jobs, uploads, and managing history.
    2. Official Local Comfy MCP: Best when an agent needs to discover current templates, nodes, or models, validate raw workflows, adapt templates, or manage the local ComfyUI lifecycle.

    If the Agent host already exposes official MCP tools, the Skill calls them directly. For shell-only hosts, a bridge is provided via comfy_mcp.py.

    python ./scripts/comfy_mcp.py probe
    python ./scripts/comfy_mcp.py call search_templates --arguments '{"query":"upscale"}'
  10. Workflow requirements for OpenClaw

    main

    To ensure reliable operation with OpenClaw, every ComfyUI workflow must meet the following criteria:

    • API Format: The workflow must be exported from ComfyUI in API format (not standard JSON).
    • Output Node: The workflow must include an output node such as Save Image.
    • Schema Mapping: A schema.json mapping is required so the agent can interact with a clean parameter interface.
    • Dependencies: The target ComfyUI server must have all required custom nodes and models pre-installed.

    Note: Using the comfyui-skill workflow import command can help generate the necessary mapping and verify dependencies before execution.

  11. How the CLI and MCP interfaces work together

    main

    The project provides two distinct interfaces for interacting with ComfyUI:

    1. CLI (Command Line Interface): The efficient, high-performance path for executing known, registered workflows. Use this for repeated, batch, or latency-sensitive tasks where the workflow ID is already known.
    2. Official Local Comfy MCP: The adaptive path for discovery and orchestration. Use MCP when you need to discover currently installed templates, nodes, models, or hardware capabilities, or when performing complex lifecycle tasks like installing nodes or downloading models.

    Routing Invariants:

    • Prefer the CLI for a known <server_id>/<workflow_id>.
    • Prefer MCP when the answer depends on the live state of the ComfyUI ecosystem (installed nodes, models, etc.).
    • Once a prompt_id is returned by either path, continue polling that specific path. Do not switch between CLI and MCP for the same job.
  12. Define Workflow Parameters in schema.json

    main

    To expose specific ComfyUI nodes to an agent, create a schema.json file in the workflow directory (data/<server_id>/<workflow_id>/schema.json). This maps agent-friendly parameter names to specific ComfyUI node IDs and fields.

    Each parameter object requires:

    • node_id: The ID of the node in the ComfyUI graph.
    • field: The specific field name within that node.
    • required: Boolean indicating if the parameter is mandatory.
    • type: The data type (e.g., string).
    • description: A human-readable description for the agent.

    Example schema.json:

    {
      "description": "My workflow",
      "enabled": true,
      "parameters": {
        "prompt": {
          "node_id": 10,
          "field": "prompt",
          "required": true,
          "type": "string",
          "description": "Prompt text"
        }
      }
    }