SamuraiBuddha/mcp-comfyui
If you are the rightful owner of mcp-comfyui and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
ComfyUI MCP Server - Enhanced Edition is a Model Context Protocol server that facilitates interaction between Claude and ComfyUI for AI image generation using Stable Diffusion.
generate_image
Generate an image with full control over all parameters.
build_workflow
Create a custom workflow programmatically.
save_workflow
Save a workflow for future use.
execute_workflow
Run a saved ComfyUI workflow with custom inputs.
list_models
Get all available model checkpoints.
ComfyUI MCP Server - Advanced Workflow Edition
A Model Context Protocol (MCP) server that enables Claude to interact with ComfyUI for AI image generation using Stable Diffusion - now with full workflow creation, advanced settings management, and complete API control!
Overview
This enhanced MCP server provides a comprehensive bridge between Claude and ComfyUI, allowing you to:
- Generate images with full control over models, samplers, and schedulers
- Build custom workflows programmatically
- Execute and manage saved ComfyUI workflows
- Upload images for img2img workflows
- List and use LoRAs, embeddings, and custom nodes
- Manage the generation queue
- Retrieve generated images
Special Focus: Optimized workflows for Crisis Corps logo and branding generation!
New Features in v0.3.0
- Advanced Workflow Builder: Full node-based workflow creation with validation
- Settings Manager: Comprehensive settings presets and model optimizations
- 100+ Node Types: Support for all common ComfyUI nodes
- Workflow Templates: Pre-built templates for common tasks
- Batch Processing: Generate multiple variations efficiently
- Import/Export: Share and modify existing ComfyUI workflows
- Quality Presets: One-click quality settings (draft to extreme)
- Style Presets: Optimized settings for different art styles
- Model Auto-Optimization: Automatic optimal settings per model
- Connection Validation: Ensures workflows are valid before execution
Features
- Platform Agnostic: Works with any ComfyUI installation (local, remote, containerized)
- Full API Access: Complete control over ComfyUI's capabilities
- Workflow Support: Load, execute, build, and save complex workflows
- Queue Management: Monitor and control generation progress
- Flexible Output: Return images as base64 or file paths
- Logo Optimized: Includes pre-built workflows for logo generation
Prerequisites
- ComfyUI installed and running (see )
- Python 3.10+
- MCP SDK
Installation
# Clone the repository
git clone https://github.com/SamuraiBuddha/mcp-comfyui.git
cd mcp-comfyui
# Install dependencies
pip install -e .
Quick Start
1. Start ComfyUI
# If installed locally
cd /path/to/ComfyUI
python main.py --listen
# Or use Docker
docker-compose up -d
2. Configure MCP
# Copy example config
cp .env.example .env
# Edit .env with your settings
# COMFYUI_HOST=localhost
# COMFYUI_PORT=8188
3. Add to Claude Desktop
{
"mcpServers": {
"comfyui": {
"command": "python",
"args": ["-m", "mcp_comfyui"],
"cwd": "/path/to/mcp-comfyui",
"env": {
"COMFYUI_HOST": "localhost",
"COMFYUI_PORT": "8188"
}
}
}
}
Available Tools
generate_image
Generate an image with full control over all parameters.
generate_image(
prompt="A futuristic robot logo for Crisis Corps",
negative_prompt="blurry, low quality",
width=512,
height=512,
steps=20,
cfg_scale=7.0,
seed=-1, # Random seed
model="sd_xl_base_1.0.safetensors",
sampler="euler",
scheduler="normal"
)
build_workflow
Create a custom workflow programmatically.
build_workflow(
nodes=[
{
"id": "1",
"type": "CheckpointLoaderSimple",
"inputs": {"ckpt_name": "sd_xl_base_1.0.safetensors"}
},
{
"id": "2",
"type": "CLIPTextEncode",
"inputs": {"text": "robot logo", "clip": ["1", 1]}
},
{
"id": "3",
"type": "KSampler",
"inputs": {
"model": ["1", 0],
"positive": ["2", 0],
"seed": 42,
"steps": 20
}
}
]
)
save_workflow
Save a workflow for future use.
save_workflow(
name="my_logo_workflow",
workflow=built_workflow,
description="Custom workflow for Crisis Corps logos"
)
execute_workflow
Run a saved ComfyUI workflow with custom inputs.
execute_workflow(
workflow_name="logo_generator",
inputs={
"prompt": "Crisis Corps emblem",
"style": "military insignia"
}
)
list_models
Get all available model checkpoints.
list_models()
# Returns: ["sd_xl_base_1.0.safetensors", "dreamshaper_8.safetensors", ...]
list_samplers
Get available sampling methods.
list_samplers()
# Returns: ["euler", "euler_ancestral", "dpm_2", "dpm_2_ancestral", ...]
list_schedulers
Get available noise schedulers.
list_schedulers()
# Returns: ["normal", "karras", "exponential", "sgm_uniform", ...]
get_node_types
Discover all available ComfyUI nodes.
get_node_types()
# Returns complete node definitions with inputs/outputs
upload_image
Upload an image for img2img workflows.
upload_image(
image_path="/path/to/image.png",
name="reference_image"
)
list_workflows
Get all available workflow files.
list_workflows()
# Returns: ["logo_generator.json", "crisis_corps_logo.json", ...]
get_queue_status
Check the current generation queue.
get_queue_status()
# Returns: {"queue_remaining": 2, "currently_processing": "prompt_123"}
get_history
Retrieve recent generation history.
get_history(limit=10)
# Returns list of recent generations with IDs and parameters
get_image
Retrieve a generated image by ID.
get_image(prompt_id="abc123")
# Returns: base64 encoded image or filepath
interrupt_generation
Stop the current generation.
interrupt_generation()
clear_queue
Clear all pending generations.
clear_queue()
create_workflow_advanced
Create advanced workflows using templates or custom nodes.
create_workflow_advanced(
template="txt2img_basic", # or "txt2img_with_lora", "upscale_workflow", "custom"
settings={
"prompt": "your prompt",
"model": "model_name.safetensors",
# ... other settings
}
)
add_workflow_node
Add nodes to a custom workflow.
add_workflow_node(
node_type="KSampler",
inputs={
"seed": 42,
"steps": 20,
"cfg": 7.0
},
node_id="sampler_1" # optional
)
connect_nodes
Connect nodes in your workflow.
connect_nodes(
from_node="1",
from_output=0,
to_node="2",
to_input="model"
)
apply_quality_preset
Apply quality presets for quick configuration.
apply_quality_preset(
quality="balanced" # "draft", "fast", "balanced", "quality", "extreme"
)
apply_style_preset
Apply artistic style presets.
apply_style_preset(
style="photorealistic" # "artistic", "anime", "digital_art", "oil_painting"
)
batch_generate
Generate multiple variations efficiently.
batch_generate(
base_prompt="tech company logo",
variations=[
{"prompt_suffix": "blue theme", "seed": 100},
{"prompt_suffix": "minimalist", "seed": 200, "style": "digital_art"},
{"prompt_suffix": "3D render", "seed": 300, "cfg_scale": 9.0}
],
base_settings={"model": "sd_xl_base_1.0.safetensors"}
)
Logo Generation Examples
Generate Crisis Corps Logo with Different Models
# SDXL for high quality
result = await generate_image(
prompt="Crisis Corps logo, heroic robot emblem, orange and blue",
model="sd_xl_base_1.0.safetensors",
width=1024,
height=1024,
steps=35
)
# DreamShaper for stylized look
result = await generate_image(
prompt="Crisis Corps logo, heroic robot emblem, orange and blue",
model="dreamshaper_8.safetensors",
sampler="dpm_2_ancestral",
scheduler="karras"
)
Build Custom Logo Workflow
# Create a workflow with LoRA for consistent style
workflow = await build_workflow(
nodes=[
{"id": "1", "type": "CheckpointLoaderSimple",
"inputs": {"ckpt_name": "sd_xl_base_1.0.safetensors"}},
{"id": "2", "type": "LoraLoader",
"inputs": {"model": ["1", 0], "clip": ["1", 1],
"lora_name": "logo_style.safetensors",
"strength_model": 0.8, "strength_clip": 0.8}},
{"id": "3", "type": "CLIPTextEncode",
"inputs": {"text": "Crisis Corps emblem", "clip": ["2", 1]}},
# ... rest of workflow
]
)
# Save for reuse
await save_workflow(
name="crisis_corps_lora_workflow",
workflow=workflow,
description="Logo generation with consistent style LoRA"
)
Advanced Workflow Examples
Custom Multi-Stage Workflow
# Create a complex workflow with multiple models and processing stages
await create_workflow_advanced(template="custom")
# Stage 1: Base generation
await add_workflow_node("CheckpointLoaderSimple", {"ckpt_name": "sd_xl_base_1.0.safetensors"}, "1")
await add_workflow_node("CLIPTextEncode", {"text": "detailed portrait"}, "2")
await add_workflow_node("KSampler", {"steps": 30, "cfg": 7.5}, "3")
# Stage 2: Enhancement
await add_workflow_node("FreeU", {"b1": 1.1, "b2": 1.2}, "4")
await add_workflow_node("UpscaleModelLoader", {"model_name": "4x-UltraSharp.pth"}, "5")
# Connect everything
await connect_nodes("1", 0, "4", "model") # checkpoint -> FreeU
await connect_nodes("4", 0, "3", "model") # FreeU -> sampler
# ... more connections
workflow = await get_workflow_json()
Settings Optimization
# Get optimal settings for any model
optimal = await get_optimal_settings("sd3.5_large.safetensors")
# Returns: {"sampling": {"steps": 28, "cfg_scale": 4.5, "scheduler": "simple"}}
# Apply quality presets
await apply_quality_preset("extreme") # 50 steps, high quality
await apply_style_preset("photorealistic") # Optimized for realism
# Save your configuration
await save_settings_preset("my_portrait_settings")
Pre-Built Workflows
The workflows/
directory contains optimized workflows for Crisis Corps branding:
- logo_generator.json - General purpose logo creation
- crisis_corps_logo.json - Specific Crisis Corps branding (4 variations)
- robot_emblem.json - Military-style badges and emblems (6 variations)
- text_logo_variations.json - Typography-focused designs
See for detailed documentation.
Brand Guidelines
For consistent Crisis Corps branding, see which includes:
- Color codes (#FF6B35 orange, #004E98 blue)
- Typography guidelines
- Prompt engineering tips
- Style references
Architecture
Claude ↔ MCP Server ↔ ComfyUI API
↓ ↓
Configuration WebSocket
↓ ↓
Return Data ← Generated Images
Error Handling
The server includes comprehensive error handling:
- Connection errors to ComfyUI
- Invalid workflow specifications
- Generation failures
- Timeout handling
- Model/sampler validation
Security Notes
- Never expose ComfyUI directly to the internet
- Use API keys if implementing authentication
- Validate all inputs before passing to ComfyUI
- Consider rate limiting for production use
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
TODO
- Advanced workflow builder with 100+ node types
- Settings manager with presets and optimizations
- Batch processing implementation
- Import/export workflow functionality
- Model-specific auto-optimization
- Quality and style presets
- Real-time workflow preview
- Auto-background removal for logos
- SVG conversion support
- Workflow version control
- Cloud workflow sharing
- Performance profiling tools
License
MIT License - see LICENSE file for details
Acknowledgments
- ComfyUI by comfyanonymous
- Model Context Protocol by Anthropic
- Crisis Corps branding examples included with permission