UNPKG

comfyui-mcp

Version:

Local-first, agent-native control plane for ComfyUI — MCP server + autonomous sidebar agent that drives your live graph in natural language on ANY LLM: Claude/ChatGPT/Gemini on your subscription (no API key), free local models via Ollama (fully offline),

60 lines • 2.6 kB
import { generateWithControlNet, generateWithIpAdapter, } from "../services/generate-conditioned.js"; import { enqueueWorkflow } from "../services/workflow-executor.js"; import { listLocalModels } from "../services/model-resolver.js"; async function resolveFirstModel(type) { try { const models = await listLocalModels(type); return models[0]?.name; } catch { return undefined; } } const deps = { resolveCheckpoint: () => resolveFirstModel("checkpoints"), resolveControlNetModel: () => resolveFirstModel("controlnet"), enqueue: (workflow) => enqueueWorkflow(workflow), }; function enqueuedResult(result, tool) { return { content: [ { type: "text", text: JSON.stringify({ status: "enqueued", tool, prompt_id: result.prompt_id, queue_remaining: result.queue_remaining, // #1037 — a 200 from /prompt does not mean every output was accepted; // ComfyUI queues the branches that validate and reports the rest. ...(result.rejectedOutputs ? { rejected_outputs: result.rejectedOutputs } : {}), checkpoint: result.checkpoint, note: 'asset_id will be available in the completion notification; use get_image (action:"view") or generate_image (action:"regenerate") with it.', }, null, 2), }, ], }; } /** * `generate_image (action:"controlnet")` — the handler the standalone ControlNet * tool used to carry (0.50.0 slice 16), unchanged apart from losing its own * registration. * * Same service, same shared `deps`, same enqueuedResult payload; its `tool` * label now spells the live call form rather than a name that no longer exists. * The try/catch moved OUT to the dispatcher in generate-image.ts. */ export async function generateWithControlNetAction(args) { return enqueuedResult(await generateWithControlNet(args, deps), 'generate_image (action:"controlnet")'); } /** * `generate_image (action:"ip_adapter")` — the handler the standalone * IP-Adapter tool used to carry (0.50.0 slice 16). Same service, same deps, same * payload; see generateWithControlNetAction above for the `tool` label. */ export async function generateWithIpAdapterAction(args) { return enqueuedResult(await generateWithIpAdapter(args, deps), 'generate_image (action:"ip_adapter")'); } //# sourceMappingURL=generate-conditioned.js.map