$git clone https://github.com/joenorton/comfyui-mcp-server> Generate and refine AI images/audio/video through natural conversation
| 1 | # ComfyUI MCP Server |
| 2 | |
| 3 | > Generate and refine AI images/audio/video through natural conversation |
| 4 | |
| 5 | A lightweight MCP (Model Context Protocol) server that lets AI agents generate and iteratively refine images, audio, and video using a local ComfyUI instance. |
| 6 | |
| 7 | You run the server, connect a client, and issue tool calls. Everything else is optional depth. |
| 8 | |
| 9 | --- |
| 10 | |
| 11 | ## Quick Start (2–3 minutes) |
| 12 | |
| 13 | This proves everything is working. |
| 14 | |
| 15 | ### 1) Clone and set up |
| 16 | |
| 17 | ```bash |
| 18 | git clone https://github.com/joenorton/comfyui-mcp-server.git |
| 19 | cd comfyui-mcp-server |
| 20 | pip install -r requirements.txt |
| 21 | ``` |
| 22 | |
| 23 | ### 2) Start ComfyUI |
| 24 | |
| 25 | Make sure ComfyUI is installed and running locally. |
| 26 | |
| 27 | ```bash |
| 28 | cd <ComfyUI_dir> |
| 29 | python main.py --port 8188 |
| 30 | ``` |
| 31 | |
| 32 | ### 3) Run the MCP server |
| 33 | |
| 34 | From the repository directory: |
| 35 | |
| 36 | ```bash |
| 37 | python server.py |
| 38 | ``` |
| 39 | |
| 40 | The server listens at: |
| 41 | |
| 42 | ``` |
| 43 | http://127.0.0.1:9000/mcp |
| 44 | ``` |
| 45 | |
| 46 | ### 4) Verify it works (no AI client required) |
| 47 | |
| 48 | Run the included test client: |
| 49 | |
| 50 | ```bash |
| 51 | # Use default prompt |
| 52 | python test_client.py |
| 53 | |
| 54 | # Or provide your own prompt |
| 55 | python test_client.py -p "a beautiful sunset over mountains" |
| 56 | python test_client.py --prompt "a cat on a mat" |
| 57 | ``` |
| 58 | |
| 59 | `test_client.py` will: |
| 60 | |
| 61 | * connect to the MCP server |
| 62 | * list available tools |
| 63 | * fetch and display server defaults (width, height, steps, model, etc.) |
| 64 | * run `generate_image` with your prompt (or a default) |
| 65 | * automatically use server defaults for all other parameters |
| 66 | * print the resulting asset information |
| 67 | |
| 68 | If this step succeeds, the system is working. |
| 69 | |
| 70 | **Note:** The test client respects server defaults configured via config files, environment variables, or `set_defaults` calls. Only the `prompt` parameter is required; all other parameters use server defaults automatically. |
| 71 | |
| 72 | That’s it. |
| 73 | |
| 74 | --- |
| 75 | |
| 76 | ## Use with an AI Agent (Cursor / Claude / n8n) |
| 77 | |
| 78 | Once the server is running, you can connect it to an AI client. |
| 79 | |
| 80 | Create a project-scoped `.mcp.json` file: |
| 81 | |
| 82 | ```json |
| 83 | { |
| 84 | "mcpServers": { |
| 85 | "comfyui-mcp-server": { |
| 86 | "type": "streamable-http", |
| 87 | "url": "http://127.0.0.1:9000/mcp" |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | ``` |
| 92 | |
| 93 | **Note:** Some clients use `"type": "http"` instead of `"streamable-http"`. Both work with this server. If auto-discovery doesn't work, try changing the type field. |
| 94 | |
| 95 | Restart your AI client. You can now call tools such as: |
| 96 | |
| 97 | * `generate_image` |
| 98 | * `view_image` |
| 99 | * `regenerate` |
| 100 | * `get_job` |
| 101 | * `list_assets` |
| 102 | |
| 103 | This is the primary intended usage mode. |
| 104 | |
| 105 | --- |
| 106 | |
| 107 | ## What You Can Do After It Works |
| 108 | |
| 109 | Once you’ve confirmed the server runs and a client can connect, the system supports: |
| 110 | |
| 111 | * Iterative refinement via `regenerate` (no re-prompting) |
| 112 | * Explicit asset identity for reliable follow-ups |
| 113 | * Job polling and cancellation for long-running generations |
| 114 | * Optional image injection into the AI’s context (`view_image`) |
| 115 | * Auto-discovered ComfyUI workflows with parameter exposure |
| 116 | * Configurable defaults to avoid repeating common settings |
| 117 | |
| 118 | Everything below builds on the same basic loop you just tested. |
| 119 | |
| 120 | ## Migration Notes (Previous Versions) |
| 121 | |
| 122 | If you’ve used earlier versions of this project, a few things have changed. |
| 123 | |
| 124 | ### What’s the Same |
| 125 | - You still run a local MCP server that delegates execution to ComfyUI |
| 126 | - Workflows are still JSON files placed in the `workflows/` directory |
| 127 | - Image generation behavior is unchanged at its core |
| 128 | |
| 129 | ### What’s New |
| 130 | - **Streamable HTTP transport** replaces the older WebSocket-based approach |
| 131 | - **Explicit job management** (`get_job`, `get_queue_status`, `cancel_job`) |
| 132 | - **Asset identity** instead of ad-hoc URLs (stable across hostname changes) |
| 133 | - **Iteration support** via `regenerate` (replay with parameter overrides) |
| 134 | - **Optional visual feedback** for agents via `view_image` |
| 135 | - **Configurable defaults** to avoid repeating common parameters |
| 136 | |
| 137 | ### What Changed Conceptually |
| 138 | Earlier versions were a thin request/response bridge. |
| 139 | The current version is built around **iteration** and **stateful control loops**. |
| 140 | |
| 141 | You can still generate an image with a single call, but you now have the option to: |
| 142 | - refer back to specific outputs |
| 143 | - refine results without |