Generates an image using ComfyUI from a text prompt, auto-downloading a suitable model like SDXL if none available, enqueuing workflow, and monitoring progress.
From comfynpx claudepluginhub artokun/comfyui-mcp --plugin comfyA text description of the image to generate/genGenerates an image directly from the provided prompt. Auto-enhances short prompts (<10 words), delegates to image generator agent, and adds a one-line creative comment.
/genExecutes the `/gene` command with all arguments provided to `/gen`, serving as a direct alias for alternative invocation.
/gen**Your response MUST be written in the language specified by the locale code (default: en-US).**
The user wants to generate an image using ComfyUI. Their prompt is provided as the argument to this command.
Parse the user's prompt. The argument after /comfy-gen is the image description: $ARGUMENTS
If no argument was provided, ask the user what they'd like to generate.
Check available models. Use the list_local_models tool with model_type: "checkpoints" to see what checkpoints are installed.
If no checkpoints are installed — acquire one automatically.
Do NOT ask the user to download a model. Instead, find and download one yourself:
Option A — CivitAI (preferred if CIVITAI_API_TOKEN is set):
https://civitai.com/api/v1/models?query=SDXL&types=Checkpoint&sort=Most+Downloaded&limit=5https://civitai.com/api/download/models/{modelVersionId}?token={CIVITAI_API_TOKEN}download_model with target_subfolder: "checkpoints" to download itOption B — HuggingFace (default):
search_models to find a suitable checkpoint (e.g., query "SDXL" or "stable diffusion xl").safetensors download URL from the model page (typically https://huggingface.co/{repo}/resolve/main/{filename})download_model with target_subfolder: "checkpoints" to download itSensible defaults by category:
stabilityai/stable-diffusion-xl-base-1.0)Tell the user what you're downloading and why. Large checkpoints can be 2-7 GB.
Create the workflow. Use the create_workflow tool with:
template: "txt2img"params: Include positive_prompt from the user's input. Set checkpoint to the model filename. Use sensible defaults (1024x1024 for SDXL, 20 steps, cfg 8).Enqueue the workflow. Pass the workflow JSON from step 3 to enqueue_workflow. This returns immediately with a prompt_id.
Monitor progress in background. Start a background task to track the job:
Bash(run_in_background: true):
node "${CLAUDE_PLUGIN_ROOT}/scripts/monitor-progress.mjs" <prompt_id>
This connects to ComfyUI's WebSocket and prints real-time step progress (e.g., step 3/14 (21%)), then reports completion with output filenames. You do NOT need to poll get_job_status — the background task handles everything.
Continue the conversation while waiting. Check the background task output when notified it completed.
If the job fails, the monitor prints error details (node, message). Use get_history for the full traceback if needed.
Fallback: If the background script is unavailable, use get_job_status to poll until done is true.
Show the result. Once the background monitor reports completion, use list_output_images (limit 1) to find the newest image. Read it with the Read tool to display it to the user.
Open the image. Open the image so the user can see it immediately without navigating to the output folder. Use the Bash tool with the appropriate command for the OS:
open /path/to/image.pngxdg-open /path/to/image.pngstart "" "/path/to/image.png"The image will be saved to ComfyUI's output directory (check get_system_stats for the --output-directory arg, or default to ~/Documents/ComfyUI/output/).
When choosing a checkpoint, consider:
get_system_stats. Flux needs ~12GB. SDXL needs ~6GB. SD 1.5 works on ~4GB.If the environment variable CIVITAI_API_TOKEN is available, prefer CivitAI for model discovery because it has:
CivitAI REST API endpoints:
GET https://civitai.com/api/v1/models?query={query}&types=Checkpoint&sort=Most+Downloaded&limit=5GET https://civitai.com/api/v1/models/{modelId}GET https://civitai.com/api/download/models/{modelVersionId}?token={token}Always include the token query parameter when downloading.
User: /comfy-gen a beautiful sunset over mountains with golden light
Steps:
stabilityai/stable-diffusion-xl-base-1.0sd_xl_base_1.0.safetensors to checkpoints foldercreate_workflow