feat(mcp): update bigmind/mcp-image-gen/webscraper servers; add image-gen batch scripts

This commit is contained in:
Patrick Plate
2026-06-11 09:02:09 +02:00
parent 0cb94122bf
commit bf721c1379
9 changed files with 2659 additions and 297 deletions
+35 -12
View File
@@ -244,26 +244,49 @@ def build_flux_workflow(
"""
workflow_path = _WORKFLOW_REGISTRY.get(model, _WORKFLOW_REGISTRY[_DEFAULT_MODEL])
with open(workflow_path) as f:
wf = json.load(f)
wf = copy.deepcopy(wf)
# Load workflow as text first — replace string placeholders
raw = workflow_path.read_text()
actual_seed = seed if seed != -1 else random.randint(0, 2**32 - 1)
wf["6"]["inputs"]["text"] = prompt
wf["33"]["inputs"]["text"] = neg_prompt
wf["27"]["inputs"]["width"] = width
wf["27"]["inputs"]["height"] = height
wf["13"]["inputs"]["steps"] = steps
wf["13"]["inputs"]["seed"] = actual_seed
# Node 32 = UNETLoader (flux1-schnell.safetensors is UNet-only, not all-in-one checkpoint)
wf["32"]["inputs"]["unet_name"] = model
raw = raw.replace('"PROMPT_PLACEHOLDER"', json.dumps(prompt))
raw = raw.replace('"NEGATIVE_PLACEHOLDER"', json.dumps(neg_prompt))
wf = json.loads(raw)
wf = copy.deepcopy(wf)
# Recursively inject numeric values into matching field names
_inject_workflow_params(wf, {
"width": width,
"height": height,
"steps": steps,
"seed": actual_seed,
"noise_seed": actual_seed,
"unet_name": model,
})
# Attach the actual seed as metadata so callers can retrieve it
wf["_meta"] = {"actual_seed": actual_seed}
return wf
def _inject_workflow_params(node: dict | list, params: dict) -> None:
"""Recursively walk a workflow dict/list and inject parameter values.
For each dict encountered, if it has an "inputs" sub-dict, update
any matching field names from params. This is model-agnostic and
works regardless of ComfyUI node IDs.
"""
if isinstance(node, dict):
if "inputs" in node and isinstance(node["inputs"], dict):
for key, value in params.items():
if key in node["inputs"] and not isinstance(node["inputs"][key], list):
node["inputs"][key] = value
for v in node.values():
_inject_workflow_params(v, params)
elif isinstance(node, list):
for item in node:
_inject_workflow_params(item, params)
# ---------------------------------------------------------------------------
# Helpers
# ---------------------------------------------------------------------------