Skip to main content
Glama

comfy-agent-mcp

Local MCP server and CLI that drive ComfyUI with Qwen Image 2.1 so Cursor (or any MCP client) can generate and edit images on your machine.

Features

  • generate_image — text-to-image with aspect ratio, megapixels, or exact width/height (64–2048)

  • edit_image — edit an existing PNG/JPEG with an instruction (e.g. “remove Chinese text, keep the rest”)

  • Seed reuse as a decimal string for reproducible runs

  • Same capabilities available from the Python CLI (comfy_cli.py)

Related MCP server: comfyui-mcp

Requirements

  • Node.js 18+

  • Python 3.10+ with requests (py -m pip install requests)

  • ComfyUI running locally at http://127.0.0.1:8188

  • Qwen Image 2.1 models loaded in ComfyUI (matching workflow.json)

Setup

npm install
py -m pip install requests

Start ComfyUI, then run the MCP server:

npm start

Cursor MCP config

Point Cursor at server.mjs (adjust the path to your clone):

{
  "mcpServers": {
    "comfyui-local": {
      "command": "node",
      "args": ["E:/path/to/comfy-agent/server.mjs"]
    }
  }
}

On Windows the CLI is invoked with py. Ensure the Python launcher is on your PATH.

MCP tools

generate_image

Parameter

Description

prompt

Image description

count

1–4 images (default 1)

aspect_ratio

1:1, 16:9, or 9:16 (used if size not set)

megapixels

~0.05–4 (used if size not set)

width / height

Exact pixels 64–2048 (both required; rounded to multiples of 8)

seed

Decimal string from a previous result

Size tips: icons ~256–512, UI ~1024, cinematic up to 2048.

edit_image

Parameter

Description

image_path

Path to the source PNG/JPEG

prompt

Edit instruction

count

1–4 variations

seed

Optional decimal string

negative_prompt

Optional (e.g. text, watermarks)

Editing uses the source as a Qwen reference. Reusing a generation seed alone does not edit a picture — use edit_image.

CLI

# Generate
py comfy_cli.py --prompt "cyberpunk city at night" --aspect-ratio "16:9 (Widescreen)" --megapixels 1

# Exact size
py comfy_cli.py --prompt "app icon, flat" --width 256 --height 256

# Edit
py comfy_cli.py --image ./output/photo.png --prompt "Remove all overlaid text" --negative "text, letters"

# Machine-readable output
py comfy_cli.py --prompt "..." --json

Images are written to output/ by default (gitignored).

Project layout

File

Role

server.mjs

MCP server (stdio)

comfy_cli.py

ComfyUI HTTP client / CLI

workflow.json

Qwen Image 2.1 workflow graph

License

MIT — see LICENSE.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    B
    maintenance
    MCP server that wraps ComfyUI for SDXL image generation. It exposes tools for generating images, listing models, and checking ComfyUI health, with presets and GPU resource coordination.
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Generates and edits images using OpenAI GPT Image or Google Gemini models, saving every result to disk and returning local file paths so AI assistants can continue working with the images. It enables prompt-based image creation, editing, inpainting, multi-image composition, and model listing through MCP tools.
    1
    7 npm
    1
    Apache 2.0