---
description: Setup, verify, and repair MCP-ComfyUI-FLUX Docker installation with automated hook configuration
argument-hint: [verify|install|repair|validate] [--project-name <name>] [--dry-run] [--force] [--verbose]
---
# MCP-ComfyUI Setup Command
Orchestrates the mcp-comfyui-setup-guardian agent to ensure proper installation, configuration, and maintenance of the MCP-ComfyUI-FLUX system with consistent container naming and Claude Desktop integration.
## Command Argument Parsing
Parse the `$ARGUMENTS` variable to extract the action and options:
1. **Extract the action** (first non-flag argument):
- `verify` - Perform comprehensive verification of current setup without making changes
- `install` - Complete installation from scratch with hook configuration
- `repair` - Fix existing installation issues while preserving customizations
- `validate` - Test end-to-end functionality of the system
- If no action is provided, default to `verify`
2. **Parse optional flags** (can appear in any order):
- `--project-name <name>` - Extract the next token as the project name to use instead of directory name
- `--dry-run` - Set flag to show proposed changes without applying them
- `--force` - Set flag to skip user confirmations and backup creation
- `--verbose` - Set flag to enable detailed debugging output
3. **Handle edge cases**:
- If `$ARGUMENTS` is empty, run `verify` action with default options
- If unknown action is provided, show error and list valid actions
- If `--project-name` is provided without a value, show error
- Ignore extra whitespace and handle quoted project names properly
## Execution Process
When the user invokes `/mcp-setup`, execute the following methodical process using the mcp-comfyui-setup-guardian agent:
### Phase 1: Discovery & Assessment
1. **Environment Detection**
- Detect current working directory and derive project name
- Check for existing .env file and COMPOSE_PROJECT_NAME
- Identify OS platform (Windows/WSL2/Linux)
- Locate Claude Desktop config path
2. **Container State Analysis**
- Run `docker ps -a --filter "name=comfyui" --filter "name=mcp"`
- Extract actual container names and states
- Compare against expected naming patterns
- Document any discrepancies
3. **Configuration Inventory**
- Read docker-compose.yml to understand service names
- Check build.sh, install.sh for PROJECT_NAME references
- Examine claude_desktop_config.json for existing hooks
- Review .env for environment variables
### Phase 2: Validation & Diagnosis
1. **Naming Consistency Check**
- Expected project name vs actual Docker project name
- Container names in running state vs configuration files
- Hook references vs actual container names
2. **Hook Functionality Test**
- If hooks exist, test with: `docker exec -i [container-name] echo "test"`
- Verify WSL path resolution if on Windows
- Check MCP server accessibility
3. **Generate Diagnostic Report**
```
MCP-ComfyUI Setup Diagnostic Report
====================================
Project Directory: [path]
Expected Project Name: [name]
Actual Docker Project: [name]
Container Status:
- ComfyUI: [name] [running/stopped]
- MCP Server: [name] [running/stopped]
Configuration Issues:
- [ ] Container name mismatch
- [ ] Hook configuration incorrect
- [ ] Environment variables missing
```
### Phase 3: Remediation Planning
1. **Create Change Plan**
- List all files requiring updates
- Show before/after for each change
- Identify dependencies and order of operations
2. **Backup Strategy**
- Create .backup directory
- Copy all files to be modified
- Generate restore script
### Phase 4: Implementation
1. **Update Environment Configuration**
```bash
# Ensure .env has correct project name
echo "COMPOSE_PROJECT_NAME=mcp-comfyui-flux" >> .env
```
2. **Fix Script References**
- Update PROJECT_NAME in build.sh, install.sh
- Ensure Makefile uses consistent naming
- Update any documentation references
3. **Configure Claude Desktop Hook**
- **For Windows (WSL2)**:
```json
{
"mcpServers": {
"comfyui-flux": {
"command": "wsl.exe",
"args": [
"bash", "-c",
"cd /home/[user]/projects/tools/mcp-comfyui-flux && docker exec -i [container-name] node /app/src/index.js"
]
}
}
}
```
- **For Linux/Native WSL**:
```json
{
"mcpServers": {
"comfyui-flux": {
"command": "docker",
"args": [
"exec",
"-i",
"[container-name]",
"node",
"/app/src/index.js"
]
}
}
}
```
4. **Container Management**
- If containers exist with wrong names, stop and recreate
- Use `docker-compose -p [project-name] up -d`
- Verify new containers have correct names
### Phase 5: Verification
1. **Post-Implementation Tests**
- Verify containers running with correct names
- Test hook execution from Claude Desktop perspective
- Validate MCP server connects to ComfyUI
- Attempt test image generation
2. **Generate Success Report**
```
MCP-ComfyUI Setup Complete
==========================
✓ Container names consistent
✓ Claude Desktop hook configured
✓ MCP server accessible
✓ ComfyUI connection verified
Test with: /mcp "generate_image"
```
## Error Handling Procedures
### Container Name Conflicts
- Stop conflicting containers
- Remove old containers if safe
- Recreate with correct project name
### Permission Issues
- Check Docker group membership
- Verify WSL2 user permissions
- Ensure claude_desktop_config.json is writable
### Network Problems
- Verify Docker network exists
- Check port 8188 availability
- Test WebSocket connectivity
## Edge Case Handling
- **Multiple Claude Installations**: Check both %APPDATA% and %LOCALAPPDATA%
- **Spaces in Paths**: Quote all paths in hook configuration
- **Existing Hooks**: Merge new configuration without losing others
- **Partial Failures**: Provide rollback commands for each step
- **WSL1 vs WSL2**: Detect version and adjust networking approach
- **Directory-based Project Names**: Handle special characters and spaces
- **Docker Desktop vs Docker Engine**: Adjust commands based on installation type
## Rollback Procedure
If any step fails:
1. Stop modified containers
2. Restore backed-up files from .backup directory
3. Restart original containers with original project name
4. Provide detailed error log with specific failure point
5. Suggest manual remediation steps
## Action-Specific Behaviors
### `/mcp-setup verify`
- Read-only operation
- Generates comprehensive diagnostic report
- No changes made to system
- Highlights all inconsistencies found
### `/mcp-setup install`
- Full installation from scratch
- Downloads models if missing
- Builds containers with optimal settings
- Configures Claude Desktop hook
- Performs end-to-end validation
### `/mcp-setup repair`
- Fixes existing installation
- Preserves user customizations where possible
- Updates only inconsistent configurations
- Maintains container state if healthy
### `/mcp-setup validate`
- Tests MCP server accessibility
- Verifies ComfyUI connection
- Attempts test image generation
- Reports on system health
## Implementation Notes for Agent
When implementing this command:
1. **Always use Task tool** to invoke mcp-comfyui-setup-guardian agent
2. **Provide detailed context** including:
- Current working directory
- Detected OS and environment
- User's requested action and options
- Any existing error messages
3. **Request structured output** from agent:
- Diagnostic findings
- Proposed changes
- Implementation results
- Verification status
4. **Handle agent responses** by:
- Parsing diagnostic reports
- Confirming with user before applying changes (unless --force)
- Providing clear success/failure feedback
- Offering next steps
## Example Invocations
```bash
# First-time setup
/mcp-setup install
# Check current configuration
/mcp-setup verify
# Fix hook configuration after directory rename
/mcp-setup repair --project-name mcp-comfyui-flux
# Test without making changes
/mcp-setup repair --dry-run
# Validate after manual changes
/mcp-setup validate
```
## Success Criteria
The command is successful when:
1. Container names are consistent across all configurations
2. Claude Desktop can invoke the MCP server
3. MCP server connects to ComfyUI
4. Test image generation succeeds
5. All configuration files use the same project name
6. No manual intervention required for basic operations