← All guides

Guide · MCP + Skills

How to use ComfyUI with Claude Code

Generate images on your own GPU just by asking Claude. An MCP server connects Claude to ComfyUI, a skill tells it which model to pick, and one line in CLAUDE.md makes it ask first.

Last updated

Three parts, three jobs. The comfy CLI runs ComfyUI from the terminal, and the optional MCP server gives Claude ComfyUI tools for everything else. The skill is the know-how: start ComfyUI, pick a model, write the prompt, run the workflow. The CLAUDE.md rule decides when it kicks in. You can take the skill as it is: download SKILL.md.

1Install ComfyUI and the comfy CLI

Install ComfyUI and check it runs. Mine is in ~/Documents/ComfyUI. Then install Comfy-Org's command-line tool and the MCP server that wraps it. Both are Python tools, so I use uv:

uv tool install comfy-cli
uv tool install comfy-mcp

The CLI is what does the real work. comfy run --workflow queues a saved workflow and waits for the image, and comfy workflow set-slot changes a value in it (prompt, size, seed) without opening the UI.

2Add the MCP server (optional, but worth it)

The skill below only needs the CLI. The MCP server is for everything outside "make me an image": in any chat you can say "free the GPU memory", "show me the ComfyUI logs", "restart ComfyUI" or "what templates are there?", and Claude has a tool for it. Claude Code loads MCP tools only when they're needed, so it costs almost nothing while you're not using it.

claude mcp add -s user comfy-mcp -e COMFY_BIN=<path to comfy.exe> -- comfy-mcp

-s user makes it available in every project. Check it with claude mcp list; you want comfy-mcp ... ✔ Connected. If you haven't added an MCP server before, Claude + Gemini via MCP walks through the same command step by step.

3Save one workflow per model family

Different models need different node graphs. I keep two, saved from ComfyUI's built-in templates (Workflow → Browse Templates, then Export):

~/.claude/skills/comfyui-image/
  SKILL.md
  workflows/
    checkpoint.json   <- SDXL / SD1.5 template
    netayume.json     <- NetaYume Lumina (anime) template
  • checkpoint.json: the plain SDXL text-to-image template. Works for any single-file checkpoint (SDXL, SD1.5).
  • netayume.json: the NetaYume Lumina template, for anime. It needs its own system-prompt nodes.

The skill never edits these. It copies one to a temp file, fills in the slots and runs the copy.

An exported workflow keeps your last prompt. ComfyUI saves the current values of every node, so the JSON still holds whatever you typed last. I found an old test prompt in mine before sharing. Open the file and clear the prompt text before you publish or commit it.

4Write the skill: let the prompt pick the model

The part Claude can't guess is which of my models suits which request. So that's most of the skill, as a table:

| Prompt is about                       | Model                    | Size      |
|---------------------------------------|--------------------------|-----------|
| anime, manga, chibi, character art    | NetaYume Lumina v3.5     | 1024x1536 |
| photo, realistic, landscape, product  | SDXL base 1.0            | 1024x1024 |
| "quick", "draft", "test"              | SD 1.5                   | 512x512   |

Two rules make it feel smart instead of random:

  • Ask when it's unclear. "A fox illustration" could be anime or painterly, so the skill asks with a multiple-choice question, best guess first.
  • Don't fake it. If nothing installed fits (say, readable text in the image), it names the model, its size, the link, and the exact folder to put it in. Then it asks: download it for me, I'll download it myself, or use the closest model I have.

"Download it for me" is for when you can't be bothered to search. Claude finds the file, checks you have the disk space, and runs the download in the background:

comfy --workspace $HOME\Documents\ComfyUI --skip-prompt model download `
  --url "https://huggingface.co/SG161222/RealVisXL_V5.0/resolve/main/RealVisXL_V5.0_fp16.safetensors" `
  --relative-path "models\checkpoints"

It only downloads .safetensors files, because older .ckpt files can run code when loaded. If a site needs a login token (civitai, some Hugging Face models), it tells you to download it in the browser instead of asking for the token in chat.

Each model also gets its own prompt style: danbooru-style tags for NetaYume, a plain sentence for SDXL. The full file is in the download above. New to skills? Start with how to write Claude Code skills.

5Trigger it from CLAUDE.md

A skill loads when Claude thinks the task matches its description. I wanted something firmer: whenever a task needs an image, Claude should ask whether to use my local ComfyUI or something else. That rule goes in my global ~/.claude/CLAUDE.md:

# Image generation
When a task needs an image generated (picture, illustration, art, asset, mockup image),
first ask the user (AskUserQuestion): "Do you want to use the comfyui-image skill (local
ComfyUI)?" If yes, invoke the `comfyui-image` skill. If no, use whatever other method they
choose. Skip the question when the user already named comfyui-image or ComfyUI.

Now "make a hero image for this page" in any project gets one quick question first, and "draw it with ComfyUI" skips the question. More on what belongs there in CLAUDE.md best practices.

6Try it

Start a new session and ask the way you normally would:

Make a photo-style image of a calm lake at sunrise with ComfyUI.

Claude checks ComfyUI is running (and starts it if not), picks SDXL, runs the workflow, and shows the PNG in the chat with its path, seed and final prompt. Keep the seed if you want to re-run it with small changes.

Big images can run out of VRAM. If a run fails with an out-of-memory or connection error, the image is usually too large for the GPU. The skill offers a smaller size; 1024 on the long side is a safe start for SDXL.

comfy-cli, comfy-mcp and the other tools I use are on my tools page.