comfyui-mcp-server
Enables AI assistants to generate images using ComfyUI by exposing tools for image generation, batch processing, and status checking through the Model Context Protocol.
README
ComfyUI MCP Server
An MCP (Model Context Protocol) server that enables AI assistants like Claude to generate images using ComfyUI.
Features
- Generate Images: Create images from text prompts using your ComfyUI workflow
- Automatic File Handling: Optionally copy generated images directly to your project
- Status Checking: Verify ComfyUI is running before generating
- List Images: Browse previously generated images
Prerequisites
- ComfyUI running locally on
http://127.0.0.1:8188 - Z-Image Turbo model (or modify
workflow.jsonfor your model) - Python 3.10+
- Claude Code or another MCP-compatible client
Installation
1. Clone the repository
git clone https://github.com/sumitchatterjee13/comfyui-mcp-server.git
2. Install dependencies
cd path/to/comfyui-mcp
pip install -r requirements.txt
Or with uv (recommended):
uv pip install -r requirements.txt
3. Configure your MCP client
Add this server to your MCP client configuration. Examples for popular clients below.
Claude Code — global config (~/.claude.json):
{
"mcpServers": {
"comfyui": {
"command": "python",
"args": [
"C:/Users/YourName/mcp-servers/comfyui-mcp/server.py",
"--comfyui-url", "http://127.0.0.1:8188"
]
}
}
}
Claude Code — project-level config (.mcp.json in your project root):
{
"mcpServers": {
"comfyui": {
"command": "python",
"args": [
"C:/Users/YourName/mcp-servers/comfyui-mcp/server.py",
"--comfyui-url", "http://127.0.0.1:8188"
]
}
}
}
Cursor / Kilo Code / Cline / Roo Code — MCP settings JSON:
{
"mcpServers": {
"comfyui": {
"command": "python",
"args": [
"server.py",
"--comfyui-url", "http://127.0.0.1:8188"
],
"cwd": "C:/Users/YourName/mcp-servers/comfyui-mcp",
"alwaysAllow": [
"generate_image",
"batch_generate_images",
"check_batch_status",
"list_generated_images",
"check_comfyui_status",
"convert_to_webp",
"batch_convert_to_webp"
]
}
}
}
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"comfyui": {
"command": "python",
"args": [
"C:/Users/YourName/mcp-servers/comfyui-mcp/server.py",
"--comfyui-url", "http://127.0.0.1:8188"
]
}
}
}
Notes:
- Replace the paths with the actual location of your
comfyui-mcpfolder.--comfyui-urlis optional (defaults tohttp://127.0.0.1:8188). Use it to point to ComfyUI on a different port, a LAN machine (http://192.168.1.50:8188), or a cloud instance.- The URL can also be set via the
COMFYUI_URLenvironment variable.alwaysAllowis supported by Cursor/Kilo Code/Cline/Roo Code to auto-approve tool calls without prompting each time.cwdlets you use a relative path forserver.pyinstead of an absolute one.
Usage
Once configured, you can ask Claude to generate images naturally:
Basic generation
"Generate an image of a sunset over mountains"
With specific dimensions
"Create a 1920x1080 hero banner image of a modern tech office"
Save to project
"Generate a product mockup image and save it to ./public/images/product.png"
Check status
"Is ComfyUI running?"
List previous images
"Show me the last 5 images I generated"
Available Tools
generate_image
Generate an image from a text prompt.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
prompt |
string | required | Description of the image to generate |
save_path |
string | required | Full output path (no extension, forward slashes) |
width |
int | 1024 | Image width in pixels (256-4096) |
height |
int | 1024 | Image height in pixels (256-4096) |
seed |
int | random | Seed for reproducible generation |
file_format |
string | "jpg" | Output format: jpg, webp, or png |
batch_generate_images
Queue multiple images (up to 100) for generation. This tool is non-blocking — it queues all images to ComfyUI and returns a batch_id immediately. Use check_batch_status to monitor progress.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
images |
list | required | Array of 1-100 image requests (see below) |
Each image request:
| Parameter | Type | Default | Description |
|---|---|---|---|
prompt |
string | required | Description of the image |
save_path |
string | required | Unique output path (no extension) |
width |
int | 1024 | Image width in pixels (256-4096) |
height |
int | 1024 | Image height in pixels (256-4096) |
seed |
int | random | Seed for reproducible generation |
file_format |
string | "jpg" | Output format: jpg, webp, or png |
Two-step workflow:
- Call
batch_generate_images→ returnsbatch_idimmediately - Call
check_batch_statuswith thebatch_id→ returns progress - Repeat step 2 until status is
"completed"
Example usage:
"Generate 5 product images for the e-commerce site: a leather bag, sneakers, a watch, sunglasses, and a jacket"
check_batch_status
Check the progress of a batch image generation job. Returns current status, completed count, pending count, and results of finished images.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
batch_id |
string | required | The batch_id from batch_generate_images |
list_generated_images
List recently generated images.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
directory |
string | required | Directory path to list images from |
limit |
int | 10 | Maximum images to return |
check_comfyui_status
Check if ComfyUI is running and accessible. No parameters needed.
Workflow Customization
The included workflow.json is configured for the Z-Image Turbo model. To use a different workflow:
- Export your workflow from ComfyUI (Save → API Format)
- Replace
workflow.json - Update the node mappings in
server.pyif needed:- Node 7: Positive prompt (
textfield) - Node 11: Dimensions (
width,heightfields) - Node 6: Seed (
seedfield) - Node 12: Output (
filename_prefixfield)
- Node 7: Positive prompt (
Troubleshooting
"Cannot connect to ComfyUI"
- Ensure ComfyUI is running
- Check it's accessible at http://127.0.0.1:8188
- Verify no firewall is blocking the connection
"Image file not found"
- Check that the save_path directory exists or is writable
- Verify ComfyUI has write permissions to the output folder
Generation seems stuck
- Check ComfyUI's web interface for errors
- Verify your model and VAE are loaded correctly
- The default timeout is 300 seconds (5 minutes)
Tips for Better Results
The Z-Image Turbo model responds well to:
-
Detailed descriptions: "A serene mountain lake at golden hour, snow-capped peaks reflected in still water, photorealistic"
-
Style specifications: "...in the style of watercolor illustration" or "...digital art, trending on artstation"
-
Composition guidance: "wide angle shot", "close-up portrait", "bird's eye view"
-
Lighting details: "dramatic lighting", "soft diffused light", "backlit silhouette"
Since this model doesn't use negative prompts, focus on describing what you want rather than what you don't want.
License
MIT License - feel free to modify and share.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器