yogocomfyorg/Comfy.org_MCP-Server
If you are the rightful owner of Comfy.org_MCP-Server 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 is a comprehensive Model Context Protocol server designed for ComfyUI, offering advanced automation and intelligent workflow orchestration capabilities.
run_workflow_with_parameters
Execute workflows with dynamic parameter injection
fetch_latest_image
Smart image detection and routing
install_customnodes
Intelligent custom node installation
download_huggingface_model
HuggingFace model downloads
monitor_system_resources
Real-time system monitoring
๐จ ComfyUI MCP Server
A comprehensive Model Context Protocol (MCP) server for ComfyUI with automatic agentic controlling capabilities, intelligent workflow orchestration
๐ Key Highlights
- ๐ค Fully Autonomous ComfyUI Control - Complete API automation with intelligent decision making
- ๐ญ Advanced Workflow Orchestration - Chain complex workflows with dependencies and error handling
- ๐ผ๏ธ Intelligent Image Routing - Automatic image bridging between workflows
- ๐ง Smart Custom Node Management - Automated installation with dependency resolution
- ๐ฆ One-Click ComfyUI Installation - Complete setup with CUDA optimization options
- ๐ Performance Optimization - Triton and SageAttention integration
- ๐ Real-time Monitoring - System health and performance tracking
๐ฏ Core Capabilities
๐ค Autonomous AI Control
- Intelligent Workflow Management: AI-driven workflow selection and optimization
- Automatic Error Recovery: Smart error detection and resolution
- Adaptive Performance Tuning: Dynamic optimization based on system capabilities
๐ญ Advanced Workflow System
- Workflow Orchestration: Chain multiple workflows with complex dependencies
- Parameter Injection: Dynamic parameter modification for any workflow type
- Image Routing: Intelligent bridging of images between workflow stages
- Batch Processing: Execute multiple workflows with parallel processing
๐ง Complete ComfyUI Management
- Model Download & Management: HuggingFace, Civitai, and custom model sources
- Custom Node Ecosystem: Automated installation, updates, and dependency management
- Configuration Management: Dynamic ComfyUI settings and optimization
- System Integration: Terminal operations, file management, and monitoring
๐ Performance & Optimization
- CUDA Optimization: Multi-version CUDA support with automatic selection
- Triton Integration: GPU kernel optimization for enhanced performance
- SageAttention: Memory-efficient attention mechanisms
- Resource Monitoring: Real-time CPU, RAM, and GPU utilization tracking
๐ Quick Start
Option 1: Complete Installation (Recommended)
๐ฏ One-Click ComfyUI Setup with MCP Server
-
Clone the repository:
git clone https://github.com/your-org/comfyui-mcp-server.git cd comfyui-mcp-server
-
Install ComfyUI with optimization options:
# Run the comprehensive installer sandbox/Install_ComfyUI_Complete.bat
The installer will guide you through:
- CUDA Version Selection (11.8, 12.1, 12.4, 12.6, or CPU-only)
- Triton & SageAttention optimization options
- Build Tools validation and setup
- Automatic Environment configuration
-
Install MCP Server dependencies:
npm install npm run build
-
Start the MCP Server:
npm start # or start-comfyui-mcp.bat
Option 2: MCP Server Only
If you already have ComfyUI installed:
-
Clone and setup:
git clone https://github.com/your-org/comfyui-mcp-server.git cd comfyui-mcp-server npm install npm run build
-
Configure ComfyUI path in
augment-mcp-config.json
-
Start the server:
npm start
๐ System Requirements
Minimum Requirements
- Node.js: 18.0.0 or higher
- Python: 3.10+ (for ComfyUI)
- RAM: 8GB minimum, 16GB+ recommended
- Storage: 20GB+ free space for models
Recommended for Optimal Performance
- GPU: NVIDIA RTX 3060+ with 8GB+ VRAM
- CUDA: 12.6 (latest) or 11.8+ (compatible)
- RAM: 32GB+ for large models
- Storage: SSD with 100GB+ free space
- Build Tools: Visual Studio 2019/2022 (for Triton/SageAttention)
๐ฎ Usage Guide
๐ Starting the System
Method 1: Complete System Startup
# Start ComfyUI instance (if using our installer)
sandbox/ComfyUI_cuda126/Launch_ComfyUI_CUDA126.bat
# In another terminal, start MCP Server
npm start
# or
start-comfyui-mcp.bat
Method 2: Direct MCP Server
npm start
# or
node build/index.js
๐๏ธ Server Configuration
Environment Variables
Create a .env
file in the project root:
# ComfyUI Configuration
COMFYUI_PATH=C:/path/to/ComfyUI
COMFYUI_URL=http://127.0.0.1:8188
COMFYUI_MODELS_PATH=C:/path/to/ComfyUI/models
# Performance Settings
MAX_CONCURRENT_WORKFLOWS=3
WORKFLOW_TIMEOUT=300000
IMAGE_ROUTING_CONFIDENCE=0.7
# Monitoring
ENABLE_PERFORMANCE_MONITORING=true
LOG_LEVEL=info
# DGM Integration
ENABLE_DGM_OPTIMIZATION=true
RECURSIVE_IMPROVEMENT_CYCLES=5
Advanced Configuration
Modify src/config.ts
for advanced settings:
export const config = {
comfyui: {
defaultUrl: 'http://127.0.0.1:8188',
timeout: 30000,
retryAttempts: 3
},
workflows: {
directory: './workflows',
maxConcurrent: 3,
defaultParameters: {
batch_size: 1,
steps: 20,
cfg: 7.0
}
},
optimization: {
enableTriton: true,
enableSageAttention: true,
autoOptimize: true
}
};
๐ ๏ธ Available Tools
๐ฏ Core Workflow Management
Tool | Description | Key Features |
---|---|---|
run_workflow_with_parameters | Execute workflows with dynamic parameter injection | โ Parameter modification, โ Preset configurations |
run_workflow | Basic workflow execution from workflows folder | โ Simple execution, โ API format support |
create_workflow_chain | Create complex workflow orchestration chains | โ Dependencies, โ Error handling, โ Conditional execution |
execute_workflow_chain | Execute workflow chains with monitoring | โ Progress tracking, โ Dry run mode |
load_workflow | Load and validate workflow files | โ Structure validation, โ Error detection |
optimize_workflow | AI-powered workflow optimization | โ Performance tuning, โ Resource optimization |
๐ผ๏ธ Intelligent Image Routing
Tool | Description | Key Features |
---|---|---|
fetch_latest_image | Smart image detection and routing | โ Auto-detection, โ Node routing, โ Path resolution |
smart_route_image | ML-like image routing with confidence scoring | โ Confidence thresholds, โ Learning mode |
batch_route_images | Batch image processing and routing | โ Pattern matching, โ Multi-workflow support |
orchestrate_workflow_with_images | Complete workflow orchestration with image bridging | โ Automatic chaining, โ Image flow management |
analyze_output_images | Image analysis with metadata extraction | โ Metadata parsing, โ Workflow grouping |
๐ง Custom Node Ecosystem
Tool | Description | Key Features |
---|---|---|
install_customnodes | ๐ FEATURED Intelligent custom node installation | โ Git clone, โ Dependency resolution, โ README parsing |
list_custom_nodes | Comprehensive custom node inventory | โ Detailed info, โ Status checking |
update_custom_node | Smart custom node updates | โ Git pull, โ Dependency updates |
remove_custom_node | Safe custom node removal | โ Complete cleanup, โ Confirmation prompts |
install_requirements | Intelligent dependency installation | โ README analysis, โ Environment detection |
๐ฆ Model Management
Tool | Description | Key Features |
---|---|---|
download_huggingface_model | HuggingFace model downloads | โ Authentication, โ Progress tracking |
list_installed_models | Model inventory and organization | โ Type filtering, โ Size information |
check_disk_space | Storage monitoring | โ Space analysis, โ Cleanup suggestions |
๐ ComfyUI Server Management
Tool | Description | Key Features |
---|---|---|
start_comfyui_in_terminal | Intelligent ComfyUI startup | โ Auto-detection, โ Multiple methods |
get_server_status | Server health monitoring | โ API status, โ Performance metrics |
queue_workflow | Workflow queue management | โ Priority handling, โ Client tracking |
clear_queue | Queue management and cleanup | โ Selective clearing, โ Process termination |
kill_comfyui_processes | Process and port cleanup | โ Force termination, โ Port cleanup |
๐ System Monitoring & Diagnostics
Tool | Description | Key Features |
---|---|---|
monitor_system_resources | Real-time system monitoring | โ CPU/RAM/GPU tracking, โ Performance alerts |
health_check | Comprehensive system health analysis | โ Multi-component checking, โ Issue detection |
execute_command | Safe command execution | โ Timeout handling, โ Output capture |
๐๏ธ Configuration & Settings
Tool | Description | Key Features |
---|---|---|
get_comfyui_config | Configuration management | โ Settings retrieval, โ Validation |
api_key_management | API key and credential management | โ Secure storage, โ Validation |
๐ Batch Operations & Automation
Tool | Description | Key Features |
---|---|---|
batch_workflow_execution | Multi-workflow batch processing | โ Concurrent execution, โ Progress tracking |
create_directory | Directory management | โ Recursive creation, โ Permission handling |
list_directory | File system exploration | โ Detailed listings, โ Hidden file support |
๐ฏ Pro Tip: Use workflow chains with image routing for complete automation pipelines. The system can automatically generate images, route them through upscaling, apply effects, and organize outputs - all with a single command!
๐๏ธ Architecture
๐ง Modular Design
The server follows a clean, modular architecture for maximum maintainability and extensibility:
๐ comfyui-mcp-server/
โโโ ๐ src/
โ โโโ ๐ index.ts # ๐ Main MCP server entry point
โ โโโ ๐ core/
โ โ โโโ ๐ server.ts # Core MCP server implementation
โ โ โโโ ๐ config.ts # Configuration management
โ โ โโโ ๐ utils.ts # Shared utilities
โ โโโ ๐ tools/
โ โโโ ๐ workflowExecution.ts # ๐ญ Workflow orchestration & execution
โ โโโ ๐ imageRouting.ts # ๐ผ๏ธ Intelligent image routing
โ โโโ ๐ customNodes.ts # ๐ง Custom node management
โ โโโ ๐ modelManagement.ts # ๐ฆ Model download & organization
โ โโโ ๐ serverManagement.ts # ๐ ComfyUI server control
โ โโโ ๐ systemMonitoring.ts # ๐ Performance monitoring
โ โโโ ๐ fileOperations.ts # ๐ File & directory operations
โ โโโ ๐ batchOperations.ts # ๐ Batch processing
โโโ ๐ build/ # ๐๏ธ Compiled JavaScript output
โโโ ๐ workflows/ # ๐ญ Workflow templates
โโโ ๐ sandbox/ # ๐ฆ Installation scripts
โโโ ๐ state/ # ๐พ Runtime state management
๐ Data Flow Architecture
graph TD
A[MCP Client] --> B[MCP Server]
B --> C[Tool Router]
C --> D[Workflow Engine]
C --> E[Image Router]
C --> F[Node Manager]
C --> G[Model Manager]
D --> H[ComfyUI API]
E --> H
F --> I[Git Operations]
G --> J[HuggingFace/Civitai]
H --> K[ComfyUI Instance]
K --> L[Generated Images]
L --> E
๐ง Intelligent Systems
Image Routing Intelligence
Image Detection โ Compatibility Analysis โ Confidence Scoring โ Route Selection โ Execution
๐ ๏ธ Development
๐ Quick Development Setup
# Clone and setup
git clone https://github.com/your-org/comfyui-mcp-server.git
cd comfyui-mcp-server
# Install dependencies
npm install
# Development mode with hot reload
npm run dev
# Build for production
npm run build
# Run tests
npm test
# Lint and format
npm run lint
npm run format
๐ง Development Scripts
Command | Description | Usage |
---|---|---|
npm run dev | Development mode with TypeScript watching | Real-time development |
npm run build | Compile TypeScript to JavaScript | Production builds |
npm test | Run Jest test suite | Quality assurance |
npm run lint | ESLint code analysis | Code quality |
npm run format | Prettier code formatting | Code consistency |
๐งช Testing Strategy
# Unit tests
npm run test:unit
# Integration tests
npm run test:integration
# End-to-end tests
npm run test:e2e
# Coverage report
npm run test:coverage
๐ก๏ธ Error Handling & Reliability
๐ Comprehensive Error Management
- Graceful Degradation: System continues operating even when components fail
- Detailed Logging: Comprehensive error tracking with context
- Automatic Recovery: Self-healing mechanisms for common issues
- Performance Monitoring: Real-time system health tracking
- Timeout Handling: Prevents hanging operations
- Resource Cleanup: Automatic cleanup of failed operations
๐ Monitoring & Diagnostics
// Built-in health monitoring
{
"system": {
"status": "healthy",
"uptime": "2h 34m",
"memory": "1.2GB / 16GB",
"cpu": "15%",
"gpu": "45%"
},
"comfyui": {
"status": "running",
"queue": 2,
"processing": true
},
"workflows": {
"completed": 156,
"failed": 3,
"success_rate": "98.1%"
}
}
๐ Performance Optimization
โก CUDA & GPU Acceleration
The installation script provides multiple CUDA options for optimal performance:
CUDA Version | Compatibility | Performance | Recommended For |
---|---|---|---|
CUDA 12.6 | Latest GPUs | โญโญโญโญโญ | RTX 40 series, Latest hardware |
CUDA 12.4 | Modern GPUs | โญโญโญโญ | RTX 30/40 series |
CUDA 12.1 | Balanced | โญโญโญ | Most modern GPUs |
CUDA 11.8 | Wide compatibility | โญโญ | Older GPUs, Stability |
CPU Only | Universal | โญ | Testing, CPU-only systems |
๐ฅ Advanced Optimizations
- Triton Integration: GPU kernel optimization for 20-40% performance boost
- SageAttention: Memory-efficient attention for large models
- Automatic Mixed Precision: Reduces memory usage while maintaining quality
- Dynamic Batching: Optimizes batch sizes based on available VRAM
๐ Examples & Use Cases
๐จ Creative Workflows
// Generate and enhance artwork pipeline
{
"name": "artistic_enhancement_pipeline",
"steps": [
{
"id": "base_generation",
"workflow": "text2img_api",
"parameters": {
"prompt": "digital art, concept art style",
"steps": 30,
"cfg": 8.0
}
},
{
"id": "upscale_enhance",
"workflow": "upscaling_api",
"dependencies": ["base_generation"],
"routeFromPrevious": true
}
]
}
๐ธ Photography Enhancement
// Photo restoration and enhancement
{
"workflow": "photo_enhancement",
"batch_processing": true,
"input_directory": "./photos",
"output_directory": "./enhanced",
"parameters": {
"denoise_strength": 0.7,
"upscale_factor": 2.0,
"color_correction": true
}
}
๐ฌ Video Frame Processing
// Video frame extraction and processing
{
"pipeline": "video_frame_enhancement",
"input": "video.mp4",
"frame_extraction": {
"fps": 24,
"quality": "high"
},
"processing": {
"workflow": "frame_enhancement_api",
"batch_size": 8
}
}
๐ค Contributing
๐ง Development Contribution
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Implement your changes with tests
- Ensure all tests pass:
npm test
- Submit a pull request with detailed description
๐ Documentation Contribution
- Improve README sections
- Add workflow examples
- Create tutorial content
- Update API documentation
๐ Bug Reports
Please include:
- System specifications
- ComfyUI version
- Error logs and stack traces
- Steps to reproduce
๐ก Feature Requests
- Describe the use case
- Explain expected behavior
- Provide implementation suggestions
๐ License
MIT License - see file for details.
This project is open source and welcomes contributions from the community.
๐ Support & Community
๐ Getting Help
- ๐ Documentation: Check this README and tool documentation
- ๐ Issues: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
- ๐ง Email:
๐ง Troubleshooting
Common Issues
Issue | Solution |
---|---|
ComfyUI not starting | Check CUDA installation and Python environment |
Models not downloading | Verify internet connection and API keys |
Workflows failing | Validate workflow JSON format and node compatibility |
Performance issues | Enable Triton/SageAttention optimizations |
Debug Mode
# Enable verbose logging
DEBUG=comfyui:* npm start
# Check system health
npm run health-check
# Validate installation
npm run validate-setup
๐ Community
Join our growing community of AI artists, developers, and researchers using ComfyUI MCP Server for creative and technical projects.
โญ Star this repository if you find it useful!
๐ Watch for updates and new features
๐ค Contribute to make it even better