comfyui-workflow-editor-mcp
comfyui-workflow-editor-mcp
A lightweight MCP (Model Context Protocol) server that bridges AI agents (like Cursor, Claude, etc.) with a local ComfyUI instance. It enables AI agents to generate and iteratively refine images, audio, and video through conversational tool calls — with a graph-based workflow editor for safe, validated modifications.
Features
Workflow Graph Editor: Safe, validated editing of ComfyUI workflows as directed graphs
Add, remove, replace, and insert nodes with automatic type-checking and cycle detection
Search available node types from the ComfyUI
/object_infocatalogValidate workflows before execution (type mismatches, cycles, orphans, missing inputs)
Compare workflows, convert between API and frontend formats, generate workflows from templates
Quick Start
Option 1: Via npx (for MCP clients)
No local clone needed. Add to your MCP client configuration (Cursor, Claude, etc.):
"comfyui": {
"command": "npx",
"args": ["-y", "comfyui-workflow-editor-mcp"],
"env": {
"COMFYUI_URL": "http://localhost:8188",
"COMFY_MCP_WORKFLOW_DIR": "/path/to/workflows",
"COMFY_MCP_ASSET_TTL_HOURS": "24"
}
}Note: ComfyUI must be running at
COMFYUI_URLbefore the MCP client connects.
Option 2: Local development
git clone https://github.com/yar3333/comfyui-workflow-editor-mcp.git
cd comfyui-workflow-editor-mcp
npm install
npm run buildThen start:
Command | Mode |
| stdio (for MCP clients) |
| stdio with ts-node |
Configuration
Environment Variables
Variable | Description | Default |
| ComfyUI base URL |
|
| Path to workflow directory |
|
| Asset time-to-live in hours |
|
API Tools
Generation Tools
Tool | Description |
| Available workflows automatically published as tools |
| Regenerate a previously generated asset |
Viewing Tools
Tool | Description |
| View a generated image inline in chat |
Job Management Tools
Tool | Description |
| Get current queue status from ComfyUI |
| Get job status by prompt_id |
| Wait for a job to complete with timeout |
| List generated assets with optional filtering |
| Get full metadata for a specific asset |
| Cancel a running job by prompt_id |
Configuration Tools
Tool | Description |
| List available checkpoint models from ComfyUI |
| List available UNet models in standard (safetensors) format |
| List available UNet models in GGUF format |
Workflow Tools
Tool | Description |
| List available workflows in the workflow directory |
| Run a specific workflow with parameter overrides |
Workflow Graph Editor Tools
Graph-based tools for safe, validated editing of ComfyUI workflows. All mutations validate type compatibility, detect cycles, and report orphan nodes.
Tool | Description |
| Get workflow structure as a graph with nodes, links, chains |
| Search available node types from the ComfyUI catalog |
| Get detailed schema for a node type (inputs, outputs, defaults) |
| Add a node with validation (type-check, cycle detection) |
| Remove a node, reporting affected connections and orphans |
| Create a connection between node outputs and inputs |
| Disconnect an input from a node |
| Change a primitive input value on a node |
| Insert a node into an existing link (break-and-reconnect) |
| Replace a node type, preserving compatible connections |
| Full validation: types, cycles, orphans, missing inputs |
| Find the dependency path between two nodes |
| Generate a workflow from a template (txt2img, img2img, etc.) |
| Convert between ComfyUI API format and frontend JSON format |
| Compare two workflows, showing added/removed/modified nodes |
Workflow Graph Editor
The workflow graph editor represents ComfyUI workflows as directed graphs, enabling safe modifications with automatic validation.
How It Works
WorkflowGraph— in-memory graph representation of a workflow (nodes, connections, execution order)NodeTypesCatalog— cached catalog of available node types loaded from ComfyUI's/object_infoAPIValidation rules — every mutation is checked against the same rules ComfyUI uses internally:
Check | Description |
Required inputs | All mandatory inputs must be provided |
Link targets | Links reference existing nodes and valid slot indices |
Type compatibility | Output types match input type expectations (supports unions and wildcards) |
Cycle detection | DFS-based cycle detection prevents invalid dependency graphs |
Orphan detection | Nodes unreachable from any output node are flagged |
Output node check | At least one output node (SaveImage, SaveAudio, etc.) must exist |
Built-in Templates
build_basic_workflow supports the following templates:
Template | Description | Nodes |
| Basic text-to-image | CheckpointLoader, 2×CLIPTextEncode, EmptyLatent, KSampler, VAEDecode, SaveImage |
| Image-to-image | CheckpointLoader, LoadImage, VAEEncode, 2×CLIPTextEncode, KSampler, VAEDecode, SaveImage |
| Text-to-image + ControlNet | Basic + ControlNetLoader, LoadImage, ControlNetApply |
| SDXL text-to-image | CheckpointLoader, CLIPTextEncode (4×), EmptyLatent, KSampler (2×), VAEDecode, SaveImage |
| Upscale pipeline | CheckpointLoader, ImageUpscaleWithModel, VAEEncode, KSampler, VAEDecode, SaveImage |
Format Conversion
ComfyUI uses two JSON formats:
API format — flat
{node_id: NodeData}map used by the backend (what the MCP server works with)Frontend format — structured
{nodes, links, groups}format exported from the ComfyUI UI
Use convert_workflow_format to convert between them.
Workflow System
Workflows are stored as JSON files in the workflows/ directory. The system automatically discovers workflows and exposes them as MCP tools. Parameters are defined using the PARAM_* placeholder system:
PARAM_INT_SEED- Integer parameter for seedPARAM_FLOAT_CFG- Float parameter for CFG scalePARAM_STR_SAMPLER_NAME- String parameter for sampler namePARAM_PROMPT- String parameter for prompt
Test
Prerequisites: ComfyUI running at http://localhost:8188, server built and started.
# Run the test client
npx ts-node test_client.ts
# With custom prompt
npx ts-node test_client.ts -p "a beautiful sunset over mountains"# Run unit tests
npm testProject Structure
comfyui-workflow-editor-mcp/
├── src/
│ ├── comfyui_client.ts # HTTP client for ComfyUI API
│ ├── asset_processor.ts # Image processing utilities
│ ├── server.ts # Main entry point
│ ├── models/ # Data models
│ │ ├── asset.ts
│ │ ├── workflow.ts
│ │ ├── workflow_graph.ts # WorkflowGraph — in-memory graph representation
│ │ └── node_types.ts # NodeTypeSchema and related interfaces
│ ├── managers/ # Manager classes
│ │ ├── workflow_manager.ts
│ │ ├── asset_registry.ts
│ │ └── node_types_catalog.ts # NodeTypesCatalog — cached /object_info catalog
│ └── tools/ # MCP tool implementations
│ ├── helpers.ts
│ ├── generation.ts
│ ├── asset.ts
│ ├── job.ts
│ ├── configuration.ts
│ ├── workflow.ts # list_workflows, run_workflow
│ └── workflow_edit.ts # Graph editor tools (add, remove, connect, validate, etc.)
├── workflows/ # Workflow JSON files
├── test_client.ts # Test client
├── package.json
├── tsconfig.json
└── README.mdLicense
MIT