@bachstudio/comfyui-mcp-server
v2.7.1
Published
Simple Model Context Protocol (MCP) server for ComfyUI: text-to-image, image edit, 换装 (Flux 2 Klein 9B), Wan2.2 image-to-video, and Wan2.2 RemixV2 首尾帧 11s / 32fps 走秀视频 (快速版). Works with a local or remote ComfyUI instance.
Maintainers
Readme
@bachstudio/comfyui-mcp-server
A dead-simple Model Context Protocol (MCP) server for ComfyUI: give it a text prompt, get an image back.
It talks to ComfyUI over HTTP, so it can point at ComfyUI on the same machine or at a ComfyUI exposed on a public URL (via a tunnel) — which is what lets a hosted/online MCP platform drive a ComfyUI running on your own PC.
Tools
| Tool | Input | Purpose |
| --- | --- | --- |
| generate_image | prompt (required), optional width, height, steps, seed | Text-to-image (Z-Image-Turbo). Async: returns a job_id immediately. |
| edit_image | prompt + image1 (required), optional image2, image3, seed | Image editing / combining (Qwen Image Edit 2509 + Lightning 4-step LoRA). Images accepted as http(s) URL, data: URL, or raw base64. Output size follows image1. Async: returns a job_id immediately. |
| generate_wan22_video | image (required), optional prompt, negative_prompt, seed, workflow_path | Video generation using the local Wan2.2 Remix V3 image-to-video ultra-smooth workflow. Images accepted as http(s) URL, data: URL, or raw base64. Async: returns a job_id immediately. |
| dressup_flux2klein | model_image + garment_image (required), optional prompt, max_resolution, seed, workflow_path | 换装 (clothing swap) with the Flux 2 Klein 9B 加速版 (4-step euler, cfg 1.1). Puts the garment onto the model. Images accepted as http(s) URL, data: URL, or raw base64. Async: returns a job_id immediately. |
| generate_walkway_video | front_image + side_image + back_image (required), optional seed, workflow_path | 走秀视频(快速版) — Wan2.2 RemixV2 I2V 首尾帧 · 11 秒 · 32fps · 四段硬切 workflow. Takes three full-body first frames (front / side / back of the dressed model) and produces one 11s runway walkway MP4. 相比旧的 64fps + SeedVR2 版本快得多(4090 上 30+ 分钟 → 5~15 分钟量级)。 Async: returns a job_id immediately. |
| get_result | job_id (required) | Fetch the result of an async job. Returns structured progress while processing, or the public ComfyUI /view URL when done. |
Asynchronous jobs
Image generation can take long enough to exceed an MCP host's request timeout.
All generation tools therefore start a background job and return a job_id right
away. Poll get_result every 10-15s until it returns the image/video public URL. Jobs are kept in
memory for one hour after completion and are lost if the MCP server restarts.
// 1) generate_image/edit_image -> { "job_id": "…", "status": "submitted" }
// 2) get_result { "job_id": "…" } -> { "status": "running", "stage": "...", "elapsed_seconds": 42, "progress": { "comfy_status": "running", ... } } (repeat)
// 3) get_result { "job_id": "…" } -> "https://your-comfy.example/view?filename=...&subfolder=&type=output"Configuration (environment variables)
| Variable | Default | Description |
| --- | --- | --- |
| COMFYUI_BASE_URL | http://127.0.0.1:8188 | ComfyUI HTTP API base URL (local or public tunnel URL). |
| COMFYUI_AUTH | (none) | Optional raw Authorization header value, e.g. Bearer xxxxx. |
| COMFYUI_TIMEOUT_MS | 60000 | Per-request timeout. |
| COMFYUI_JOB_TTL_MS | 3600000 | How long completed jobs remain queryable in memory. |
| COMFYUI_WAN22_WORKFLOW_PATH | bundled workflow | Path to the Wan2.2 Remix V3 ComfyUI UI workflow JSON. If unset or unreadable, the server searches the user's Desktop/Documents, then falls back to the bundled workflow. |
| COMFYUI_FLUX2KLEIN_WORKFLOW_PATH | bundled workflow | Path to the 换装-Flux2Klein API JSON (ComfyUI "Save (API Format)" export). If unset, the bundled workflow is used. |
| COMFYUI_WALKWAY_WORKFLOW_PATH | bundled workflow | Path to the WAN2.2 RemixV2 I2V 首尾帧 11s / 32fps API JSON for generate_walkway_video. If unset, the bundled workflow is used. |
| COMFYUI_PUBLIC_BASE_URL | auto-discover | Public ComfyUI base URL used to build returned /view links. If unset, the server tries ~/.cloudflared/config.yml, then falls back to COMFYUI_BASE_URL when it is not localhost. |
Run
npx -y @bachstudio/comfyui-mcp-serverMCP client / platform config
{
"mcpServers": {
"comfyui": {
"command": "npx",
"args": ["-y", "@bachstudio/comfyui-mcp-server"],
"env": {
"COMFYUI_BASE_URL": "https://<your-public-comfyui-url>"
}
}
}
}Requirements
generate_image targets the Z-Image-Turbo model:
diffusion_models/z_image_turbo_bf16.safetensorstext_encoders/qwen_3_4b.safetensorsvae/ae.safetensors
edit_image targets the Qwen Image Edit 2509 model with the Lightning 4-step LoRA:
diffusion_models/qwen_image_edit_2509_fp8_e4m3fn.safetensorsloras/Qwen-Image-Edit-2509-Lightning-4steps-V1.0-bf16.safetensorstext_encoders/qwen_2.5_vl_7b_fp8_scaled.safetensorsvae/qwen_image_vae.safetensors
generate_wan22_video targets the local Wan2.2+Remix+V3 image-to-video ultra-smooth workflow. By default it uses the bundled workflow copied from:
C:\Users\githu\Desktop\图片素材\Wan2.2+Remix+V3+图生视频超流畅最强版.json
Set COMFYUI_WAN22_WORKFLOW_PATH or pass workflow_path if the workflow moves.
dressup_flux2klein targets the Flux 2 Klein 9B 加速版 workflow. It needs:
diffusion_models/flux-2-klein-9b.safetensorstext_encoders/qwen_3_8b.safetensorsvae/flux2-vae.safetensors- Custom nodes:
LayerUtility: ImageScaleByAspectRatio V2,JjkText,EmptyFlux2LatentImage,Flux2Scheduler,RandomNoise,CFGGuider,ReferenceLatent,SamplerCustomAdvanced,Int
generate_walkway_video targets the 【Work-FIsh】WAN2.2-RemixV2-I2V首尾帧视频_四段11秒界面版 workflow (32fps, 快速版,去掉 SeedVR2 超分与二次 RIFE 补帧). It needs:
- Wan2.2 high-noise / low-noise UNet weights
text_encoders/umt5_xxl_fp16.safetensors- Wan VAE
- Custom nodes:
PathchSageAttentionKJ,ModelPatchTorchSettings,WanFirstLastFrameToVideo,ImagePanZoomSequence,ImagePanSequence,GetImageRangeFromBatch,RIFE VFI,ConcatWithBlackGap,VHS_VideoCombine,LayerUtility: ImageScaleByAspectRatio V2,ImageResizeKJv2,Int,INTConstant,easy cleanGpuUsed
Set COMFYUI_FLUX2KLEIN_WORKFLOW_PATH / COMFYUI_WALKWAY_WORKFLOW_PATH or pass workflow_path to point at a different API-format JSON.
License
MIT © bachstudio
