ComfyMCP

ComfyMCP

Enables Claude to generate images via ComfyUI from natural language requests, automating workflow construction and execution.

Category
访问服务器

README

ComfyMCP

Give Claude the ability to generate images with ComfyUI. Just ask for what you want in natural language.

You: "Generate an image of a robot painting a sunset"

Claude: I'll create that image for you.
        [builds 7-node workflow, executes it]
        Done! Generated robot_painting_00001.png in 2.3 seconds.

What You Can Ask

Once installed, Claude can handle requests like:

Image Generation

  • "Generate an image of a cat astronaut floating in space"
  • "Create a 1024x1024 fantasy landscape using SDXL"
  • "Make a portrait with negative prompt 'blurry, low quality'"

Model & System Info

  • "What checkpoint models do I have?"
  • "Show me the available samplers"
  • "What's my GPU memory usage?"

Workflow Control

  • "Use 30 steps instead of 20 for better quality"
  • "Generate 4 variations with different seeds"
  • "What's the status of my last generation?"

Claude handles all the complexity—discovering nodes, building connections, validating the workflow, and monitoring execution.

How It Works

When you ask Claude to generate an image, it builds a complete ComfyUI workflow:

[1] CheckpointLoaderSimple ─────────────────────────────┐
     ├── MODEL ──────────────────────────────────────────┤
     ├── CLIP ───┬──→ [3] CLIPTextEncode (positive) ────┤
     │           └──→ [4] CLIPTextEncode (negative) ────┤
     └── VAE ────────────────────────────────────────────┤
                                                         ▼
[2] EmptyLatentImage ──────────────────────────→ [5] KSampler
                                                         │
                                                         ▼
                                                 [6] VAEDecode
                                                         │
                                                         ▼
                                                 [7] SaveImage

This happens automatically. Claude:

  1. Discovers available nodes and their inputs/outputs
  2. Builds the workflow with proper connections
  3. Validates everything before execution
  4. Queues the job and monitors completion
  5. Reports the output filename

Installation

Prerequisites

  • ComfyUI running (default: localhost:8188)
  • uv package manager
# Install uv if needed
curl -LsSf https://astral.sh/uv/install.sh | sh

Claude Code (CLI)

claude mcp add comfyui \
  --transport stdio \
  --env COMFYUI_HOST=127.0.0.1 \
  --env COMFYUI_PORT=8188 \
  -- uvx --from git+https://github.com/hernantech/comfymcp comfymcp

Claude Desktop

Add to your config file:

  • Linux: ~/.config/claude/claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "comfyui": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/hernantech/comfymcp", "comfymcp"],
      "env": {
        "COMFYUI_HOST": "127.0.0.1",
        "COMFYUI_PORT": "8188"
      }
    }
  }
}

Verify Installation

Ask Claude: "Check if ComfyUI is connected"

You should see confirmation that the server is online with GPU info.

Configuration

Environment Variable Description Default
COMFYUI_HOST ComfyUI server address 127.0.0.1
COMFYUI_PORT ComfyUI server port 8188
COMFYUI_API_KEY API key (if required) None

For remote ComfyUI servers, update the host:

claude mcp add comfyui \
  --env COMFYUI_HOST=192.168.1.100 \
  ...

Reference

Available MCP Tools

<details> <summary><strong>Workflow Execution</strong></summary>

Tool Description
queue_prompt Submit a workflow for execution
get_queue_status Check running/pending jobs
get_job_status Get status of a specific job
get_history View execution history
interrupt_execution Stop current generation
clear_queue Clear pending jobs

</details>

<details> <summary><strong>Workflow Building</strong></summary>

Tool Description
create_workflow Start a new workflow session
add_node Add a node with inputs
build_workflow Finalize and validate
validate_workflow Check for errors
list_nodes Search available nodes
get_node_info Get node specifications
refresh_nodes Reload node definitions

</details>

<details> <summary><strong>Assets & Models</strong></summary>

Tool Description
list_models List checkpoints, LoRAs, VAEs, etc.
list_embeddings List textual inversions
list_output_images List generated images
get_image Retrieve an image
upload_image Upload for img2img

</details>

<details> <summary><strong>System</strong></summary>

Tool Description
check_connection Verify ComfyUI is reachable
get_system_stats GPU memory, system info
free_memory Unload models, clear cache
get_extensions List installed extensions

</details>

MCP Resources

URI Description
comfyui://nodes All available nodes
comfyui://nodes/categories Node categories
comfyui://nodes/{class_type} Specific node definition
comfyui://outputs Recent outputs
comfyui://images/{filename} Retrieve image

Python API

For programmatic use outside of MCP:

from comfymcp.workflow import WorkflowBuilder

builder = WorkflowBuilder()

# Nodes return refs with named outputs
checkpoint = builder.add_node("CheckpointLoaderSimple",
    ckpt_name="sd_turbo.safetensors")

latent = builder.add_node("EmptyLatentImage",
    width=512, height=512, batch_size=1)

positive = builder.add_node("CLIPTextEncode",
    clip=checkpoint.CLIP,  # Named output connection
    text="a beautiful sunset")

negative = builder.add_node("CLIPTextEncode",
    clip=checkpoint.CLIP,
    text="ugly, blurry")

sampler = builder.add_node("KSampler",
    model=checkpoint.MODEL,
    positive=positive.CONDITIONING,
    negative=negative.CONDITIONING,
    latent_image=latent.LATENT,
    seed=42, steps=4, cfg=1.0,
    sampler_name="euler", scheduler="normal", denoise=1.0)

decode = builder.add_node("VAEDecode",
    samples=sampler.LATENT,
    vae=checkpoint.VAE)

builder.add_node("SaveImage",
    images=decode.IMAGE,
    filename_prefix="output")

workflow = builder.build()

Templates

from comfymcp.templates import Text2ImgTemplate, Img2ImgTemplate

# Text to image
txt2img = Text2ImgTemplate(
    checkpoint="sd_turbo.safetensors",
    positive_prompt="a majestic mountain",
    negative_prompt="ugly, blurry",
    width=512, height=512,
    steps=4, cfg=1.0
)
workflow = txt2img.build()

# Image to image
img2img = Img2ImgTemplate(
    checkpoint="sd_turbo.safetensors",
    image="input.png",
    positive_prompt="enhance details",
    denoise=0.6
)
workflow = img2img.build()

Direct Client Usage

from comfymcp.client import ComfyUIClient

async with ComfyUIClient(host="127.0.0.1", port=8188) as client:
    # Queue workflow
    result = await client.queue_prompt(workflow)

    # Check status
    history = await client.get_history(prompt_id=result.prompt_id)

    # List models
    checkpoints = await client.get_models("checkpoints")

Requirements

  • Python 3.10+
  • ComfyUI server running
  • MCP-compatible client (Claude Code, Claude Desktop, Cursor, etc.)

License

MIT License - see LICENSE for details.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选