comfy-agent-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@comfy-agent-mcp Generate a 16:9 cyberpunk city at night image"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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 exactwidth/height(64–2048)edit_image— edit an existing PNG/JPEG with an instruction (e.g. “remove Chinese text, keep the rest”)get_result— wait for queued jobs and return image paths, so slow machines never hit the MCP client timeoutSeed reuse as a decimal string for reproducible runs
Same capabilities available from the Python CLI (
comfy_cli.py)
Related MCP server: ComfyUI Local MCP Server
Requirements
Node.js 18+
Python 3.10+ with
requests(py -m pip install requests)ComfyUI (Desktop or portable) recent enough for Qwen Image 2.1, listening at
http://127.0.0.1:8188The three model files listed below, with exactly those filenames, in the ComfyUI model folders
You do not need to open or reconfigure a workflow in the ComfyUI UI to use this MCP. The repo ships workflow.json with the model names already filled in. The MCP posts that graph to the ComfyUI API. If the files sit in the right folders under those names, ComfyUI loads them automatically.
(The Desktop UI step of picking models in dropdowns is only needed when you build a workflow by hand. After that export, clones of this repo skip that step.)
ComfyUI models
Download from Comfy-Org/Qwen-Image-2.1 and place them as follows (standard ComfyUI layout; Desktop often uses a shared models folder next to the install):
File | Folder |
|
|
|
|
|
|
Those filenames must match workflow.json. If you rename a file, either rename it back or edit workflow.json to match.
ResolutionSelector, SaveImageAdvanced, and TextEncodeQwenImage21 come with recent ComfyUI builds — no extra custom-node pack is required for this workflow.
Quick check in the UI (optional)
Start ComfyUI Desktop / ComfyUI.
Open a Qwen Image 2.1 text-to-image template (or load any graph that uses those loaders).
Confirm the three dropdowns list the files above. If a dropdown is empty, the file is missing or in the wrong folder — fix that before using the MCP.
You still do not need to keep that graph open while the MCP runs.
Setup
git clone https://github.com/jothbc/comfy-agent-mcp.git
cd comfy-agent-mcp
npm install
py -m pip install requestsInstall the models (section above).
Start ComfyUI and wait until
http://127.0.0.1:8188responds.Point Cursor (or another MCP client) at
server.mjs, or runnpm startfor a manual stdio server.
Cursor MCP config
{
"mcpServers": {
"comfyui-local": {
"command": "node",
"args": ["E:/path/to/comfy-agent-mcp/server.mjs"]
}
}
}On Windows the CLI is invoked with py. Ensure the Python launcher is on your PATH.
If generation fails
ComfyUI not running → connection error from the CLI.
Missing model / wrong filename → ComfyUI rejects the prompt (check the ComfyUI console).
Older ComfyUI without Qwen Image 2.1 nodes → unknown
class_typeerrors; update ComfyUI.
MCP tools
Generation is asynchronous. generate_image and edit_image queue the job in ComfyUI and return right away with prompt_ids and seeds. The agent then calls get_result, which waits up to 50 seconds per call and is called again until every job is done. This keeps each call under the MCP client request timeout (60 seconds by default), however long your GPU takes.
generate_image
Parameter | Description |
| Image description |
| 1–4 images (default 1) |
|
|
| ~0.05–4 (used if size not set) |
| Exact pixels 64–2048 (both required; rounded to multiples of 8) |
| Decimal string from a previous result |
Size tips: icons ~256–512, UI ~1024, cinematic up to 2048.
edit_image
Parameter | Description |
| Path to the source PNG/JPEG |
| Edit instruction |
| 1–4 variations |
| Optional decimal string |
| 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.
get_result
Parameter | Description |
| Ids returned by |
| Max wait per call, 0–50 (default 45) |
Each result reports completed (with image paths), running, queued, error, or not_found. When done is false, call it again with the same ids.
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
# Queue without waiting, then fetch later
py comfy_cli.py --prompt "..." --no-wait --json
py comfy_cli.py --result <prompt_id> --wait-seconds 50 --jsonWithout --no-wait, the CLI waits for the image with no time limit.
Images are written to output/ by default (gitignored).
Project layout
File | Role |
| MCP server (stdio) |
| ComfyUI HTTP client / CLI |
| Qwen Image 2.1 workflow graph |
License
MIT — see LICENSE.
Available Tools
3 toolsedit_imageEdit ImageA
Edit an existing local image with Qwen Image 2.1. Pass the file path and an instruction such as 'remove the Chinese text and keep the rest unchanged'. The source image is used as a reference, so the result stays close to the original. Reusing a generation seed does not edit a picture; use this tool instead. Queues the job(s) and returns immediately with prompt_ids and seeds; then call get_result with the prompt_ids to wait for and receive the image paths. The returned seed is a decimal string; pass it back exactly to reproduce the same edit.
Inputs: prompt (required), image_path (required), seed, count, +1 more.
generate_imageGenerate ImageA
Generate one or more images locally using ComfyUI and Qwen Image 2.1. Queues the job(s) and returns immediately with prompt_ids and seeds; then call get_result with the prompt_ids to wait for and receive the image paths. The seed is a decimal string; pass that exact string back to reproduce the same generation. A seed does not edit an existing picture; use edit_image for that. Prefer width+height for exact sizes (icons ~256-512, UI ~1024, cinematic up to 2048). Values are rounded to multiples of 8. If width/height are omitted, aspect_ratio + megapixels are used instead.
Inputs: prompt (required), seed, count, width, +3 more.
get_resultGet Image ResultA
Wait for images queued by generate_image or edit_image and return their file paths. Waits up to wait_seconds (max 50). Each result has a status: completed (images ready), running, queued, error, or not_found. If done is false, some jobs are still generating: call get_result again with the same prompt_ids and keep calling until done is true. Slow machines can need several calls.
Inputs: prompt_ids (required), wait_seconds.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
The three tools map to three clearly distinct steps: queue a generation, queue an edit, and poll for results. Descriptions explicitly disambiguate the trickiest boundary (seed reuse does not edit; use edit_image instead).
All tools follow a clean verb_noun snake_case pattern (get_result, generate_image, edit_image). No stylistic drift or vague single-word verbs.
Three tools is lean but justified for a local ComfyUI image workflow, since the async queue/poll design is folded into one retrieval tool rather than splitting per-operation polling. Slightly thin, but nothing feels redundant.
Core lifecycle is covered: generate, edit, and retrieve results with status states including error and not_found. Gaps are minor conveniences such as cancelling or listing pending jobs, checking available models/checkpoints, or upscaling.
Maintenance
Related MCP Connectors
Generate AI images and videos from any compatible MCP client.
MCP server for Qwen Image 3 AI image generation
Generate and edit images and generate videos with Nanobananana's remote MCP server.
Generate images and videos with Seedance, Veo, Wan, Grok, GPT-Image and Nano Banana via one MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables Claude to generate images through a local ComfyUI instance using Stable Diffusion and SDXL models via natural language. Users can trigger image generation, list available checkpoint models, and monitor the ComfyUI queue status directly from their MCP client.MIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients to generate and edit images using local Stable Diffusion models in ComfyUI, with tools for text-to-image, img2img, ControlNet, UI frames, upscaling, and background removal—no cloud API or API key required.MIT
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients on a local network to generate and edit images with a self-hosted uncensored Qwen-Image-2.1 model over Streamable HTTP. Supports text-to-image at any aspect ratio, multi-image editing, transparent backgrounds, seamless textures with height and normal maps, 360 panoramas, upscaling, and watermark removal.119MIT
- AlicenseNot gradedqualityAmaintenanceEnables generating and editing images from any MCP client by expanding short requests into detailed visual prompts, then saving the results to disk and returning them as resources. Supports Gemini, OpenAI GPT Image, and BytePlus Seedream with quality presets, aspect ratios, up to 4K output, and options for character consistency and Google Search grounding.1,038 npmMIT