A simple way to schedule ComfyUI prompts with different parameters
Project description
Comfy API Simplified
This is a small python wrapper over the ComfyUI API. It allows you to edit API-format ComfyUI workflows and queue them programmaticaly to the already running ComfyUI.
I use it to iterate over multiple prompts and key parameters of workflow and get hundreds of images overnight to cherrypick from.
Limitations
Only Basic auth and no auth (for local server) are supported.
Install
pip install comfy_api_simplified # core library
pip install comfy_api_simplified[mcp] # + MCP server for AI agents
Use prerequisits
Prepare workflow
You would like to have your node titles unique. Usually both positive and negative prompts have title "CLIP Text Encode (Prompt)", you would like to at least give them different names in case you would like to change it's parameters from python.
Enable "dev options"
In ComfyUI settings, check "Enable Dev mode Options":
Download your workflow in API-format
Have running ComfyUI server
Use
from comfy_api_simplified import ComfyApiWrapper, ComfyWorkflowWrapper
# create api wrapper using your ComfyUI url (add user and password params if needed)
api = ComfyApiWrapper("http://127.0.0.1:8188/")
# create workflow wrapper using your downloaded in api format workflow
wf = ComfyWorkflowWrapper("workflow_api.json")
# change anything you like in your workflow
# the syntax is "Node Title", then "Input param name", then value
wf.set_node_param("Empty Latent Image", "batch_size", 2)
wf.set_node_param("negative", "text", "embedding:EasyNegative")
# queue your workflow for completion
results = api.queue_and_wait_images(wf, "Save Image")
for filename, image_data in results.items():
with open(f"{filename}", "wb+") as f:
f.write(image_data)
More examples:
-
Queue prompt and get result images example.
-
Queue many prompts and do not wait for completion example.
-
Send input image and then call i2i workflow example.
MCP Server (for AI agents)
The package ships an MCP server that lets AI agents (Claude, Cursor, etc.) discover nodes and models, build workflows, and run them — all via tool calls.
Start the server
# point at your ComfyUI instance
COMFY_URL=http://192.168.1.x:8188 comfy-mcp-server
# with auth and a custom output directory
COMFY_URL=https://myserver.com COMFY_USER=user COMFY_PASSWORD=pass \
COMFY_OUTPUT_DIR=~/comfy_outputs comfy-mcp-server
The server uses stdio transport (compatible with Claude Desktop, Cursor, and any MCP client).
Available tools
| Category | Tool | Description |
|---|---|---|
| Discovery | list_node_types |
All node class names available in ComfyUI |
| Discovery | get_node_type_info |
Inputs, types, defaults for a node class |
| Discovery | list_models |
Checkpoints, LoRAs, VAEs, etc. grouped by type |
| Discovery | get_system_stats |
GPU VRAM, RAM, Python version |
| Discovery | list_embeddings |
Available text embeddings |
| Workflow | load_workflow |
Load a workflow JSON file into a dict |
| Workflow | list_nodes |
List nodes (id, title, class_type) in a workflow |
| Workflow | set_node_param |
Set a node parameter, returns updated workflow |
| Workflow | get_node_param |
Read a node parameter value |
| Execution | upload_image |
Upload a local image, returns server path |
| Execution | run_workflow |
Run a workflow, save output images, return paths |
| Execution | get_queue_status |
Running/pending queue counts |
| Execution | interrupt_execution |
Stop the current generation |
Workflow tools are stateless — the workflow dict is passed in and returned on every call. Chain set_node_param calls to configure a workflow, then pass it to run_workflow.
Add to Claude Desktop
{
"mcpServers": {
"comfyui": {
"command": "comfy-mcp-server",
"env": { "COMFY_URL": "http://127.0.0.1:8188" }
}
}
}
Additional info
There are some other approaches to use Python with ComfyUI out there.
If you are looking to conver your workflows to backend server code, check out ComfyUI-to-Python-Extension
If you are looking to use running ComfyUI as backend, but declare workflow in Python imperatively, check out ComfyScript.
Known issues
If you try to run queue_and_wait_images in async method, it may give you an error since there is already async code inside. As a workaround, you can use
import nest_asyncio
nest_asyncio.apply()
for now.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file comfy_api_simplified-1.6.0.tar.gz.
File metadata
- Download URL: comfy_api_simplified-1.6.0.tar.gz
- Upload date:
- Size: 1.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13efbe03e38d3cd252434508b20857850d3f8f58a9194372effbd9d4d77f5c56
|
|
| MD5 |
1a2b8c7c327bb51ab8ca077c698545d2
|
|
| BLAKE2b-256 |
c5a500ca134a408e37cf236b9c6c2e3b251a580b233d97dcfa230d85dde1b53d
|
File details
Details for the file comfy_api_simplified-1.6.0-py3-none-any.whl.
File metadata
- Download URL: comfy_api_simplified-1.6.0-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0078417f03e371acde204977776d68e8978e5ac3770a2a6bfe466675ac8ee4b
|
|
| MD5 |
e3194876e929a6a05fd19681b2d1656d
|
|
| BLAKE2b-256 |
aefabcc0994a3e96be43c247655af169e9786c50be0295baf04eeeb69b2ddc22
|