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.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.