Comfy.org_MCP-Server

yogocomfyorg/Comfy.org_MCP-Server

3.2

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.

Tools
  1. run_workflow_with_parameters

    Execute workflows with dynamic parameter injection

  2. fetch_latest_image

    Smart image detection and routing

  3. install_customnodes

    Intelligent custom node installation

  4. download_huggingface_model

    HuggingFace model downloads

  5. monitor_system_resources

    Real-time system monitoring

๐ŸŽจ ComfyUI MCP Server

License: MIT Node.js TypeScript ComfyUI

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

  1. Clone the repository:

    git clone https://github.com/your-org/comfyui-mcp-server.git
    cd comfyui-mcp-server
    
  2. 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
  3. Install MCP Server dependencies:

    npm install
    npm run build
    
  4. Start the MCP Server:

    npm start
    # or
    start-comfyui-mcp.bat
    

Option 2: MCP Server Only

If you already have ComfyUI installed:

  1. Clone and setup:

    git clone https://github.com/your-org/comfyui-mcp-server.git
    cd comfyui-mcp-server
    npm install
    npm run build
    
  2. Configure ComfyUI path in augment-mcp-config.json

  3. 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

ToolDescriptionKey Features
run_workflow_with_parametersExecute workflows with dynamic parameter injectionโœ… Parameter modification, โœ… Preset configurations
run_workflowBasic workflow execution from workflows folderโœ… Simple execution, โœ… API format support
create_workflow_chainCreate complex workflow orchestration chainsโœ… Dependencies, โœ… Error handling, โœ… Conditional execution
execute_workflow_chainExecute workflow chains with monitoringโœ… Progress tracking, โœ… Dry run mode
load_workflowLoad and validate workflow filesโœ… Structure validation, โœ… Error detection
optimize_workflowAI-powered workflow optimizationโœ… Performance tuning, โœ… Resource optimization

๐Ÿ–ผ๏ธ Intelligent Image Routing

ToolDescriptionKey Features
fetch_latest_imageSmart image detection and routingโœ… Auto-detection, โœ… Node routing, โœ… Path resolution
smart_route_imageML-like image routing with confidence scoringโœ… Confidence thresholds, โœ… Learning mode
batch_route_imagesBatch image processing and routingโœ… Pattern matching, โœ… Multi-workflow support
orchestrate_workflow_with_imagesComplete workflow orchestration with image bridgingโœ… Automatic chaining, โœ… Image flow management
analyze_output_imagesImage analysis with metadata extractionโœ… Metadata parsing, โœ… Workflow grouping

๐Ÿ”ง Custom Node Ecosystem

ToolDescriptionKey Features
install_customnodes๐ŸŒŸ FEATURED Intelligent custom node installationโœ… Git clone, โœ… Dependency resolution, โœ… README parsing
list_custom_nodesComprehensive custom node inventoryโœ… Detailed info, โœ… Status checking
update_custom_nodeSmart custom node updatesโœ… Git pull, โœ… Dependency updates
remove_custom_nodeSafe custom node removalโœ… Complete cleanup, โœ… Confirmation prompts
install_requirementsIntelligent dependency installationโœ… README analysis, โœ… Environment detection

๐Ÿ“ฆ Model Management

ToolDescriptionKey Features
download_huggingface_modelHuggingFace model downloadsโœ… Authentication, โœ… Progress tracking
list_installed_modelsModel inventory and organizationโœ… Type filtering, โœ… Size information
check_disk_spaceStorage monitoringโœ… Space analysis, โœ… Cleanup suggestions

๐Ÿš€ ComfyUI Server Management

ToolDescriptionKey Features
start_comfyui_in_terminalIntelligent ComfyUI startupโœ… Auto-detection, โœ… Multiple methods
get_server_statusServer health monitoringโœ… API status, โœ… Performance metrics
queue_workflowWorkflow queue managementโœ… Priority handling, โœ… Client tracking
clear_queueQueue management and cleanupโœ… Selective clearing, โœ… Process termination
kill_comfyui_processesProcess and port cleanupโœ… Force termination, โœ… Port cleanup

๐Ÿ” System Monitoring & Diagnostics

ToolDescriptionKey Features
monitor_system_resourcesReal-time system monitoringโœ… CPU/RAM/GPU tracking, โœ… Performance alerts
health_checkComprehensive system health analysisโœ… Multi-component checking, โœ… Issue detection
execute_commandSafe command executionโœ… Timeout handling, โœ… Output capture

๐ŸŽ›๏ธ Configuration & Settings

ToolDescriptionKey Features
get_comfyui_configConfiguration managementโœ… Settings retrieval, โœ… Validation
api_key_managementAPI key and credential managementโœ… Secure storage, โœ… Validation

๐Ÿ”„ Batch Operations & Automation

ToolDescriptionKey Features
batch_workflow_executionMulti-workflow batch processingโœ… Concurrent execution, โœ… Progress tracking
create_directoryDirectory managementโœ… Recursive creation, โœ… Permission handling
list_directoryFile 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

CommandDescriptionUsage
npm run devDevelopment mode with TypeScript watchingReal-time development
npm run buildCompile TypeScript to JavaScriptProduction builds
npm testRun Jest test suiteQuality assurance
npm run lintESLint code analysisCode quality
npm run formatPrettier code formattingCode 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 VersionCompatibilityPerformanceRecommended For
CUDA 12.6Latest GPUsโญโญโญโญโญRTX 40 series, Latest hardware
CUDA 12.4Modern GPUsโญโญโญโญRTX 30/40 series
CUDA 12.1BalancedโญโญโญMost modern GPUs
CUDA 11.8Wide compatibilityโญโญOlder GPUs, Stability
CPU OnlyUniversalโญ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

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Implement your changes with tests
  4. Ensure all tests pass: npm test
  5. 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
IssueSolution
ComfyUI not startingCheck CUDA installation and Python environment
Models not downloadingVerify internet connection and API keys
Workflows failingValidate workflow JSON format and node compatibility
Performance issuesEnable 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