├── LICENSE ├── README.md ├── client.py ├── comfyui_client.py ├── comfyui_workflow_test.py ├── server.py └── workflows ├── basic.json └── basic_api_test.json /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ComfyUI MCP Server 2 | 3 | A lightweight Python-based MCP (Model Context Protocol) server that interfaces with a local [ComfyUI](https://github.com/comfyanonymous/ComfyUI) instance to generate images programmatically via AI agent requests. 4 | 5 | ## Overview 6 | 7 | This project enables AI agents to send image generation requests to ComfyUI using the MCP protocol over WebSocket. It supports: 8 | - Flexible workflow selection (e.g., `basic_api_test.json`). 9 | - Dynamic parameters: `prompt`, `width`, `height`, and `model`. 10 | - Returns image URLs served by ComfyUI. 11 | 12 | ## Prerequisites 13 | 14 | - **Python 3.10+** 15 | - **ComfyUI**: Installed and running locally (e.g., on `localhost:8188`). 16 | - **Dependencies**: `requests`, `websockets`, `mcp` (install via pip). 17 | 18 | ## Setup 19 | 20 | 1. **Clone the Repository**: 21 | git clone 22 | cd comfyui-mcp-server 23 | 24 | 2. **Install Dependencies**: 25 | 26 | pip install requests websockets mcp 27 | 28 | 29 | 3. **Start ComfyUI**: 30 | - Install ComfyUI (see [ComfyUI docs](https://github.com/comfyanonymous/ComfyUI)). 31 | - Run it on port 8188: 32 | ``` 33 | cd 34 | python main.py --port 8188 35 | ``` 36 | 37 | 4. **Prepare Workflows**: 38 | - Place API-format workflow files (e.g., `basic_api_test.json`) in the `workflows/` directory. 39 | - Export workflows from ComfyUI’s UI with “Save (API Format)” (enable dev mode in settings). 40 | 41 | ## Usage 42 | 43 | 1. **Run the MCP Server**: 44 | python server.py 45 | 46 | - Listens on `ws://localhost:9000`. 47 | 48 | 2. **Test with the Client**: 49 | python client.py 50 | 51 | - Sends a sample request: `"a dog wearing sunglasses"` with `512x512` using `sd_xl_base_1.0.safetensors`. 52 | - Output example: 53 | ``` 54 | Response from server: 55 | { 56 | "image_url": "http://localhost:8188/view?filename=ComfyUI_00001_.png&subfolder=&type=output" 57 | } 58 | ``` 59 | 60 | 3. **Custom Requests**: 61 | - Modify `client.py`’s `payload` to change `prompt`, `width`, `height`, `workflow_id`, or `model`. 62 | - Example: 63 | ``` 64 | "params": json.dumps({ 65 | "prompt": "a cat in space", 66 | "width": 768, 67 | "height": 768, 68 | "workflow_id": "basic_api_test", 69 | "model": "v1-5-pruned-emaonly.ckpt" 70 | }) 71 | ``` 72 | 73 | ## Project Structure 74 | 75 | - `server.py`: MCP server with WebSocket transport and lifecycle support. 76 | - `comfyui_client.py`: Interfaces with ComfyUI’s API, handles workflow queuing. 77 | - `client.py`: Test client for sending MCP requests. 78 | - `workflows/`: Directory for API-format workflow JSON files. 79 | 80 | ## Notes 81 | 82 | - Ensure your chosen `model` (e.g., `v1-5-pruned-emaonly.ckpt`) exists in `/models/checkpoints/`. 83 | - The MCP SDK lacks native WebSocket transport; this uses a custom implementation. 84 | - For custom workflows, adjust node IDs in `comfyui_client.py`’s `DEFAULT_MAPPING` if needed. 85 | 86 | ## Contributing 87 | 88 | Feel free to submit issues or PRs to enhance flexibility (e.g., dynamic node mapping, progress streaming). 89 | 90 | ## License 91 | 92 | Apache License -------------------------------------------------------------------------------- /client.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import websockets 3 | import json 4 | 5 | payload = { 6 | "tool": "generate_image", 7 | "params": json.dumps({ 8 | "prompt": "an english mastiff dog sitting on a large boulder, bright shiny day", 9 | "width": 512, 10 | "height": 512, 11 | "workflow_id": "basic_api_test", 12 | "model": "v1-5-pruned-emaonly.ckpt" # No extra quote 13 | }) 14 | } 15 | 16 | async def test_mcp_server(): 17 | uri = "ws://localhost:9000" 18 | try: 19 | async with websockets.connect(uri) as ws: 20 | print("Connected to MCP server") 21 | await ws.send(json.dumps(payload)) 22 | response = await ws.recv() 23 | print("Response from server:") 24 | print(json.dumps(json.loads(response), indent=2)) 25 | except Exception as e: 26 | print(f"WebSocket error: {e}") 27 | 28 | if __name__ == "__main__": 29 | print("Testing MCP server with WebSocket...") 30 | asyncio.run(test_mcp_server()) -------------------------------------------------------------------------------- /comfyui_client.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | import time 4 | import logging 5 | 6 | logging.basicConfig(level=logging.INFO) 7 | logger = logging.getLogger("ComfyUIClient") 8 | 9 | DEFAULT_MAPPING = { 10 | "prompt": ("6", "text"), 11 | "width": ("5", "width"), 12 | "height": ("5", "height"), 13 | "model": ("4", "ckpt_name") 14 | } 15 | 16 | class ComfyUIClient: 17 | def __init__(self, base_url): 18 | self.base_url = base_url 19 | self.available_models = self._get_available_models() 20 | 21 | def _get_available_models(self): 22 | """Fetch list of available checkpoint models from ComfyUI""" 23 | try: 24 | response = requests.get(f"{self.base_url}/object_info/CheckpointLoaderSimple") 25 | if response.status_code != 200: 26 | logger.warning("Failed to fetch model list; using default handling") 27 | return [] 28 | data = response.json() 29 | models = data["CheckpointLoaderSimple"]["input"]["required"]["ckpt_name"][0] 30 | logger.info(f"Available models: {models}") 31 | return models 32 | except Exception as e: 33 | logger.warning(f"Error fetching models: {e}") 34 | return [] 35 | 36 | def generate_image(self, prompt, width, height, workflow_id="basic_api_test", model=None): 37 | try: 38 | workflow_file = f"workflows/{workflow_id}.json" 39 | with open(workflow_file, "r") as f: 40 | workflow = json.load(f) 41 | 42 | params = {"prompt": prompt, "width": width, "height": height} 43 | if model: 44 | # Validate or correct model name 45 | if model.endswith("'"): # Strip accidental quote 46 | model = model.rstrip("'") 47 | logger.info(f"Corrected model name: {model}") 48 | if self.available_models and model not in self.available_models: 49 | raise Exception(f"Model '{model}' not in available models: {self.available_models}") 50 | params["model"] = model 51 | 52 | for param_key, value in params.items(): 53 | if param_key in DEFAULT_MAPPING: 54 | node_id, input_key = DEFAULT_MAPPING[param_key] 55 | if node_id not in workflow: 56 | raise Exception(f"Node {node_id} not found in workflow {workflow_id}") 57 | workflow[node_id]["inputs"][input_key] = value 58 | 59 | logger.info(f"Submitting workflow {workflow_id} to ComfyUI...") 60 | response = requests.post(f"{self.base_url}/prompt", json={"prompt": workflow}) 61 | if response.status_code != 200: 62 | raise Exception(f"Failed to queue workflow: {response.status_code} - {response.text}") 63 | 64 | prompt_id = response.json()["prompt_id"] 65 | logger.info(f"Queued workflow with prompt_id: {prompt_id}") 66 | 67 | max_attempts = 30 68 | for _ in range(max_attempts): 69 | history = requests.get(f"{self.base_url}/history/{prompt_id}").json() 70 | if history.get(prompt_id): 71 | outputs = history[prompt_id]["outputs"] 72 | logger.info("Workflow outputs: %s", json.dumps(outputs, indent=2)) 73 | image_node = next((nid for nid, out in outputs.items() if "images" in out), None) 74 | if not image_node: 75 | raise Exception(f"No output node with images found: {outputs}") 76 | image_filename = outputs[image_node]["images"][0]["filename"] 77 | image_url = f"{self.base_url}/view?filename={image_filename}&subfolder=&type=output" 78 | logger.info(f"Generated image URL: {image_url}") 79 | return image_url 80 | time.sleep(1) 81 | raise Exception(f"Workflow {prompt_id} didn’t complete within {max_attempts} seconds") 82 | 83 | except FileNotFoundError: 84 | raise Exception(f"Workflow file '{workflow_file}' not found") 85 | except KeyError as e: 86 | raise Exception(f"Workflow error - invalid node or input: {e}") 87 | except requests.RequestException as e: 88 | raise Exception(f"ComfyUI API error: {e}") -------------------------------------------------------------------------------- /comfyui_workflow_test.py: -------------------------------------------------------------------------------- 1 | import json 2 | from urllib import request 3 | 4 | #This is the ComfyUI api prompt format. 5 | 6 | #If you want it for a specific workflow you can "enable dev mode options" 7 | #in the settings of the UI (gear beside the "Queue Size: ") this will enable 8 | #a button on the UI to save workflows in api format. 9 | 10 | #keep in mind ComfyUI is pre alpha software so this format will change a bit. 11 | 12 | #this is the one for the default workflow 13 | 14 | def queue_prompt(prompt): 15 | p = {"prompt": prompt} 16 | data = json.dumps(p).encode('utf-8') 17 | req = request.Request("http://localhost:8188/prompt", data=data) 18 | request.urlopen(req) 19 | 20 | 21 | with open("workflows/basic_api_test.json", "r") as f: 22 | prompt = json.load(f) 23 | #set the text prompt for our positive CLIPTextEncode 24 | prompt["6"]["inputs"]["text"] = "beautiful scenery nature glass bottle landscape, purple galaxy bottle" 25 | 26 | #set the seed for our KSampler node 27 | prompt["3"]["inputs"]["seed"] = 5 28 | 29 | 30 | queue_prompt(prompt) -------------------------------------------------------------------------------- /server.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import json 3 | import logging 4 | from typing import AsyncIterator 5 | from contextlib import asynccontextmanager 6 | import websockets 7 | from mcp.server.fastmcp import FastMCP 8 | from comfyui_client import ComfyUIClient 9 | 10 | # Configure logging 11 | logging.basicConfig(level=logging.INFO) 12 | logger = logging.getLogger("MCP_Server") 13 | 14 | # Global ComfyUI client (fallback since context isn’t available) 15 | comfyui_client = ComfyUIClient("http://localhost:8188") 16 | 17 | # Define application context (for future use) 18 | class AppContext: 19 | def __init__(self, comfyui_client: ComfyUIClient): 20 | self.comfyui_client = comfyui_client 21 | 22 | # Lifespan management (placeholder for future context support) 23 | @asynccontextmanager 24 | async def app_lifespan(server: FastMCP) -> AsyncIterator[AppContext]: 25 | """Manage application lifecycle""" 26 | logger.info("Starting MCP server lifecycle...") 27 | try: 28 | # Startup: Could add ComfyUI health check here in the future 29 | logger.info("ComfyUI client initialized globally") 30 | yield AppContext(comfyui_client=comfyui_client) 31 | finally: 32 | # Shutdown: Cleanup (if needed) 33 | logger.info("Shutting down MCP server") 34 | 35 | # Initialize FastMCP with lifespan 36 | mcp = FastMCP("ComfyUI_MCP_Server", lifespan=app_lifespan) 37 | 38 | # Define the image generation tool 39 | @mcp.tool() 40 | def generate_image(params: str) -> dict: 41 | """Generate an image using ComfyUI""" 42 | logger.info(f"Received request with params: {params}") 43 | try: 44 | param_dict = json.loads(params) 45 | prompt = param_dict["prompt"] 46 | width = param_dict.get("width", 512) 47 | height = param_dict.get("height", 512) 48 | workflow_id = param_dict.get("workflow_id", "basic_api_test") 49 | model = param_dict.get("model", None) 50 | 51 | # Use global comfyui_client (since mcp.context isn’t available) 52 | image_url = comfyui_client.generate_image( 53 | prompt=prompt, 54 | width=width, 55 | height=height, 56 | workflow_id=workflow_id, 57 | model=model 58 | ) 59 | logger.info(f"Returning image URL: {image_url}") 60 | return {"image_url": image_url} 61 | except Exception as e: 62 | logger.error(f"Error: {e}") 63 | return {"error": str(e)} 64 | 65 | # WebSocket server 66 | async def handle_websocket(websocket, path): 67 | logger.info("WebSocket client connected") 68 | try: 69 | async for message in websocket: 70 | request = json.loads(message) 71 | logger.info(f"Received message: {request}") 72 | if request.get("tool") == "generate_image": 73 | result = generate_image(request.get("params", "")) 74 | await websocket.send(json.dumps(result)) 75 | else: 76 | await websocket.send(json.dumps({"error": "Unknown tool"})) 77 | except websockets.ConnectionClosed: 78 | logger.info("WebSocket client disconnected") 79 | 80 | # Main server loop 81 | async def main(): 82 | logger.info("Starting MCP server on ws://localhost:9000...") 83 | async with websockets.serve(handle_websocket, "localhost", 9000): 84 | await asyncio.Future() # Run forever 85 | 86 | if __name__ == "__main__": 87 | asyncio.run(main()) -------------------------------------------------------------------------------- /workflows/basic.json: -------------------------------------------------------------------------------- 1 | {"last_node_id":9,"last_link_id":9,"nodes":[{"id":7,"type":"CLIPTextEncode","pos":[413,389],"size":[425.27801513671875,180.6060791015625],"flags":{},"order":3,"mode":0,"inputs":[{"name":"clip","localized_name":"clip","type":"CLIP","link":5}],"outputs":[{"name":"CONDITIONING","localized_name":"CONDITIONING","type":"CONDITIONING","links":[6],"slot_index":0}],"properties":{"cnr_id":"comfy-core","ver":"0.3.22","Node name for S&R":"CLIPTextEncode"},"widgets_values":["text, watermark"]},{"id":6,"type":"CLIPTextEncode","pos":[415,186],"size":[422.84503173828125,164.31304931640625],"flags":{},"order":2,"mode":0,"inputs":[{"name":"clip","localized_name":"clip","type":"CLIP","link":3}],"outputs":[{"name":"CONDITIONING","localized_name":"CONDITIONING","type":"CONDITIONING","links":[4],"slot_index":0}],"properties":{"cnr_id":"comfy-core","ver":"0.3.22","Node name for S&R":"CLIPTextEncode"},"widgets_values":["beautiful scenery nature glass bottle landscape, , purple galaxy bottle,"]},{"id":5,"type":"EmptyLatentImage","pos":[473,609],"size":[315,106],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[{"name":"LATENT","localized_name":"LATENT","type":"LATENT","links":[2],"slot_index":0}],"properties":{"cnr_id":"comfy-core","ver":"0.3.22","Node name for S&R":"EmptyLatentImage"},"widgets_values":[512,512,1]},{"id":3,"type":"KSampler","pos":[863,186],"size":[315,262],"flags":{},"order":4,"mode":0,"inputs":[{"name":"model","localized_name":"model","type":"MODEL","link":1},{"name":"positive","localized_name":"positive","type":"CONDITIONING","link":4},{"name":"negative","localized_name":"negative","type":"CONDITIONING","link":6},{"name":"latent_image","localized_name":"latent_image","type":"LATENT","link":2}],"outputs":[{"name":"LATENT","localized_name":"LATENT","type":"LATENT","links":[7],"slot_index":0}],"properties":{"cnr_id":"comfy-core","ver":"0.3.22","Node name for S&R":"KSampler"},"widgets_values":[156680208700286,"randomize",20,8,"euler","normal",1]},{"id":8,"type":"VAEDecode","pos":[1209,188],"size":[210,46],"flags":{},"order":5,"mode":0,"inputs":[{"name":"samples","localized_name":"samples","type":"LATENT","link":7},{"name":"vae","localized_name":"vae","type":"VAE","link":8}],"outputs":[{"name":"IMAGE","localized_name":"IMAGE","type":"IMAGE","links":[9],"slot_index":0}],"properties":{"cnr_id":"comfy-core","ver":"0.3.22","Node name for S&R":"VAEDecode"},"widgets_values":[]},{"id":9,"type":"SaveImage","pos":[1451,189],"size":[210,58],"flags":{},"order":6,"mode":0,"inputs":[{"name":"images","localized_name":"images","type":"IMAGE","link":9}],"outputs":[],"properties":{"cnr_id":"comfy-core","ver":"0.3.22"},"widgets_values":["ComfyUI"]},{"id":4,"type":"CheckpointLoaderSimple","pos":[26,474],"size":[315,98],"flags":{},"order":1,"mode":0,"inputs":[],"outputs":[{"name":"MODEL","localized_name":"MODEL","type":"MODEL","links":[1],"slot_index":0},{"name":"CLIP","localized_name":"CLIP","type":"CLIP","links":[3,5],"slot_index":1},{"name":"VAE","localized_name":"VAE","type":"VAE","links":[8],"slot_index":2}],"properties":{"cnr_id":"comfy-core","ver":"0.3.22","Node name for S&R":"CheckpointLoaderSimple"},"widgets_values":["v1-5-pruned-emaonly.ckpt"]}],"links":[[1,4,0,3,0,"MODEL"],[2,5,0,3,3,"LATENT"],[3,4,1,6,0,"CLIP"],[4,6,0,3,1,"CONDITIONING"],[5,4,1,7,0,"CLIP"],[6,7,0,3,2,"CONDITIONING"],[7,3,0,8,0,"LATENT"],[8,4,2,8,1,"VAE"],[9,8,0,9,0,"IMAGE"]],"groups":[],"config":{},"extra":{"ds":{"scale":1,"offset":[0,0]}},"version":0.4} -------------------------------------------------------------------------------- /workflows/basic_api_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "3": { 3 | "inputs": { 4 | "seed": 156680208700286, 5 | "steps": 20, 6 | "cfg": 8, 7 | "sampler_name": "euler", 8 | "scheduler": "normal", 9 | "denoise": 1, 10 | "model": [ 11 | "4", 12 | 0 13 | ], 14 | "positive": [ 15 | "6", 16 | 0 17 | ], 18 | "negative": [ 19 | "7", 20 | 0 21 | ], 22 | "latent_image": [ 23 | "5", 24 | 0 25 | ] 26 | }, 27 | "class_type": "KSampler", 28 | "_meta": { 29 | "title": "KSampler" 30 | } 31 | }, 32 | "4": { 33 | "inputs": { 34 | "ckpt_name": "v1-5-pruned-emaonly.ckpt" 35 | }, 36 | "class_type": "CheckpointLoaderSimple", 37 | "_meta": { 38 | "title": "Load Checkpoint" 39 | } 40 | }, 41 | "5": { 42 | "inputs": { 43 | "width": 512, 44 | "height": 512, 45 | "batch_size": 1 46 | }, 47 | "class_type": "EmptyLatentImage", 48 | "_meta": { 49 | "title": "Empty Latent Image" 50 | } 51 | }, 52 | "6": { 53 | "inputs": { 54 | "text": "beautiful scenery nature glass bottle landscape, , purple galaxy bottle,", 55 | "clip": [ 56 | "4", 57 | 1 58 | ] 59 | }, 60 | "class_type": "CLIPTextEncode", 61 | "_meta": { 62 | "title": "CLIP Text Encode (Prompt)" 63 | } 64 | }, 65 | "7": { 66 | "inputs": { 67 | "text": "text, watermark", 68 | "clip": [ 69 | "4", 70 | 1 71 | ] 72 | }, 73 | "class_type": "CLIPTextEncode", 74 | "_meta": { 75 | "title": "CLIP Text Encode (Prompt)" 76 | } 77 | }, 78 | "8": { 79 | "inputs": { 80 | "samples": [ 81 | "3", 82 | 0 83 | ], 84 | "vae": [ 85 | "4", 86 | 2 87 | ] 88 | }, 89 | "class_type": "VAEDecode", 90 | "_meta": { 91 | "title": "VAE Decode" 92 | } 93 | }, 94 | "9": { 95 | "inputs": { 96 | "filename_prefix": "ComfyUI", 97 | "images": [ 98 | "8", 99 | 0 100 | ] 101 | }, 102 | "class_type": "SaveImage", 103 | "_meta": { 104 | "title": "Save Image" 105 | } 106 | } 107 | } --------------------------------------------------------------------------------