ComfyUI MCP

ComfyUI MCP Setup for Claude Code and Codex

Connect AI coding agents to ComfyUI-style image workflows with a small MCP setup, local safety checks, and reusable workflow templates.

最后更新: 2026年6月30日

功能对比

OptionBest forSetup shapeWatch before usingGood internal link
Local ComfyUI MCPPrivate assets, custom nodes, local GPUs, repeatable workflowsLocal ComfyUI plus an MCP server or bridgePath, Python, custom node, and port mismatchesClaude Code MCP
Comfy Cloud workflowHosted execution, sharing, and less local setupCloud workspace plus workflow export/importPlan limits, asset handling, and privacy rulesAI coding tutorials
Claude Code + ComfyUIAgent-written workflow docs, prompt variants, and local checksCLAUDE.md plus MCP config and workflow templatesDo not let hooks run image jobs unexpectedlyCLAUDE.md generator
Codex + ComfyUITask-based workflow updates and repo documentationAGENTS.md plus scoped MCP instructionsKeep task scope narrow and review generated JSONAGENTS.md generator

Direct Answer

ComfyUI MCP is best treated as a bridge between coding agents and image workflow automation. The agent should help set up workflows, explain node graphs, generate prompt variants, and verify files; humans should still review generated images, model licenses, and asset privacy.

Setup For Claude Code

For Claude Code, document the ComfyUI command, local URL, workflow directory, and safe actions in CLAUDE.md before adding the MCP bridge.

CLAUDE.md note:
- ComfyUI runs locally at http://127.0.0.1:8188.
- Workflow files live in workflows/comfyui/.
- Do not start long image jobs without user approval.
- Validate JSON before saving workflow changes.

mcp.json:
{
  "mcpServers": {
    "comfyui": {
      "command": "node",
      "args": ["scripts/comfyui-mcp.js"]
    }
  }
}

Setup For Codex

For Codex, keep the instructions portable. Put workflow directories, validation commands, and forbidden actions into AGENTS.md so delegated tasks do not depend on one chat transcript.

  • Name the local ComfyUI endpoint and whether it is allowed to run jobs.
  • Describe the workflow JSON schema and where examples live.
  • Ask Codex to edit one workflow at a time and summarize node changes.
  • Require a human check before publishing generated image assets.

Local ComfyUI Vs Comfy Cloud

Choose local ComfyUI when custom nodes, local models, private assets, and GPU control matter. Choose Comfy Cloud when hosted execution, sharing, and easier onboarding matter more than local control.

  • Local-first: best for private client assets, experimental nodes, and repeatable studio pipelines.
  • Cloud-first: best for collaborators who should not manage Python, GPU drivers, or model folders.
  • Hybrid: keep workflow templates in Git, then run locally or in cloud depending on asset sensitivity.

Workflow Templates

Start with templates that are easy for an agent to explain and modify. Each template should include a plain-English purpose, required inputs, output folder, model assumptions, and a manual review step.

templates:
  product-icon-variations.json
  ui-hero-image.json
  transparent-background-pass.json
  image-upscale-and-cleanup.json
  prompt-ab-test-grid.json

review:
  check prompt, seed, model, dimensions, license, output path

Common Failure Points

Most ComfyUI MCP failures are environment and workflow-shape issues rather than model quality issues.

  • ComfyUI is not running or the agent is pointing at the wrong port.
  • The MCP server runs under a different Node or Python environment than the terminal.
  • Custom nodes are missing on one machine but present on another.
  • Workflow JSON references model files that are not installed locally.
  • The agent edits workflow JSON without preserving required node IDs or links.

AI Image Workflow Safety

Image workflows often touch private prompts, reference images, and generated assets. Keep those boundaries explicit in the repo instructions and MCP config.

  • Do not upload private reference images to cloud services without review.
  • Record model license assumptions near workflow templates.
  • Keep generated assets out of source control unless they are meant to ship.
  • Use browser or visual checks for final UI assets after generation.

常见问题

What is ComfyUI MCP?

It is a workflow pattern where an MCP server or bridge lets an AI coding agent interact with ComfyUI-related workflow files, local endpoints, or automation tasks.

Should I use ComfyUI MCP with Claude Code or Codex?

Use Claude Code when the work is local and command-heavy. Use Codex when the task is a scoped workflow or documentation update that should be reviewed like a code change.

Is local ComfyUI safer than Comfy Cloud?

Local ComfyUI gives more control over private assets and custom nodes. Comfy Cloud can be easier to share, but teams should review asset privacy and plan limits first.

Can an agent run image generation automatically?

Technically it may be possible, but the safer default is to require human approval before long-running or asset-publishing image jobs.

What should a ComfyUI workflow template include?

Include purpose, inputs, output path, model assumptions, required custom nodes, validation steps, and a manual review checklist.