BC

biodigitaljaz/comfyui-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

6 stars 3 forks 质量 53 趋势 14

A robust Model Context Protocol (MCP) server that provides Unity with reliable AI image generation through ComfyUI.

概览

A robust Model Context Protocol (MCP) server that provides Unity with reliable AI image generation through ComfyUI. 🎨 - Queue-based completion detection (no timeouts) - Multiple download fallback methods - Production-grade error handling 🌸 - General image generation with customizable parameters - Flower texture generation optimized for Unity - Support for seamless tileable textures 🔧 - Comprehensive logging and monitoring - Configuration management with environment variables - Robust error handling and recovery - Performance statistics and health monitoring 🎮 - Automatic Unity asset folder management - PNG texture optimization - Material-ready output format 1. running on http://127.0.0.1:8188 2. with required packages 3. with Assets folder structure 2. Configure the MCP client to use this server: 1. - Handles all ComfyUI communication 2. - Creates ComfyUI workflows for different use cases 3. - Manages Unity asset file operations 4. - High-level generation orchestration 5.

README

以下为原文 README 节选,完整内容请查看原文。

ComfyUI MCP Server - Production

A robust Model Context Protocol (MCP) server that provides Unity with reliable AI image generation through ComfyUI.

Features

🎨 Reliable Image Generation

  • Queue-based completion detection (no timeouts)
  • Multiple download fallback methods
  • Production-grade error handling

🌸 Specialized Workflows

  • General image generation with customizable parameters
  • Flower texture generation optimized for Unity
  • Support for seamless tileable textures

🔧 Production Ready

  • Comprehensive logging and monitoring
  • Configuration management with environment variables
  • Robust error handling and recovery
  • Performance statistics and health monitoring

🎮 Unity Integration

  • Automatic Unity asset folder management
  • PNG texture optimization
  • Material-ready output format

Quick Start

Prerequisites

  1. ComfyUI running on http://127.0.0.1:8188
  2. Python 3.8+ with required packages
  3. Unity project with Assets folder structure

Installation

  1. Install dependencies:

    pip install mcp requests
    
  2. Configure the MCP client to use this server:

    {
      "mcpServers": {
        "comfy": {
          "command": "python",
          "args": ["path/to/comfyui-mcp/server.py"],
          "cwd": "path/to/comfyui-mcp"
        }
      }
    }
    
  3. Start using through Unity/Coplay!

Usage

Generate General Images

# Through MCP client
result = await mcp_client.call_tool("generate_image", {
    "client_id": "unity-client",
    "prompt": "beautiful landscape, sunset, high quality",
    "width": 1024,
    "height": 1024,
    "steps": 25,
    "cfg": 7.5
})

Generate Flower Textures

# Through MCP client
result = await mcp_client.call_tool("generate_flower_texture", {
    "client_id": "unity-client", 
    "flower_type": "rose",
    "seamless": True,
    "detail_level": "high"
})

Check Server Status

# Get server health and statistics
status = await mcp_client.call_tool("get_server_status", {
    "client_id": "unity-client"
})

Configuration

Environment Variables

Variable Default Description
COMFYUI_HOST 127.0.0.1 ComfyUI server host
COMFYUI_PORT 8188 ComfyUI server port
UNITY_TEXTURE_PATH Assets/Textures/Generated Unity texture output path
UNITY_MATERIAL_PATH Assets/Materials Unity material path
GENERATION_TIMEOUT 180 Max wait time for generation (seconds)
REQUEST_TIMEOUT 30 HTTP request timeout (seconds)
QUEUE_CHECK_INTERVAL 3 Queue polling interval (seconds)
DEFAULT_WIDTH 512 Default image width
DEFAULT_HEIGHT 512 Default image height
DEFAULT_STEPS 25 Default sampling steps
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "comfy": { "command": "python", "args": ["path/to/comfyui-mcp/server.py"], "cwd": "path/to/comfyui-mcp" } } }