comfy_submit_workflow
Execute ComfyUI workflows by submitting JSON with parameter overrides for dynamic image generation adjustments.
Instructions
Submit a complete workflow JSON to ComfyUI for execution. Supports parameter overrides for dynamic modifications without editing the workflow structure.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workflow | Yes | ||
| overrides | No | ||
| client_id | No |
Implementation Reference
- src/tools/generation.ts:9-62 (handler)Core implementation of the comfy_submit_workflow tool handler. Parses input workflow JSON, validates it, applies optional parameter overrides, submits to ComfyUI API, and returns prompt_id, queue position, and status.export async function handleSubmitWorkflow(input: SubmitWorkflowInput) { try { const client = getComfyUIClient(); const processor = new WorkflowProcessor(); // Parse workflow const workflow = processor.parseWorkflow(input.workflow); // Validate workflow if (!validateWorkflowJSON(workflow)) { throw ComfyUIErrorBuilder.invalidWorkflow('Invalid workflow structure'); } // Apply overrides const modifiedWorkflow = await processor.applyOverrides(workflow, input.overrides); // Submit to ComfyUI const response = await client.submitWorkflow(modifiedWorkflow, input.client_id); return { content: [{ type: "text", text: JSON.stringify({ prompt_id: response.prompt_id, number: response.number, status: response.node_errors ? "failed" : "queued", message: response.node_errors ? "Workflow validation failed" : `Workflow queued successfully at position ${response.number}`, node_errors: response.node_errors }, null, 2) }] }; } catch (error: any) { if (error.error) { // Already a ComfyUIError return { content: [{ type: "text", text: JSON.stringify(error, null, 2) }], isError: true }; } return { content: [{ type: "text", text: JSON.stringify(ComfyUIErrorBuilder.executionError(error.message), null, 2) }], isError: true }; } }
- src/types/tools.ts:4-28 (schema)Zod input schema for the tool, defining workflow (JSON string or object), optional overrides for common parameters like prompts, seed, dimensions, LoRAs, and optional client_id.export const SubmitWorkflowSchema = z.object({ workflow: z.union([z.string(), z.record(z.any())]), overrides: z.object({ positive_prompt: z.string().optional(), negative_prompt: z.string().optional(), seed: z.number().int().optional(), steps: z.number().int().min(1).max(150).optional(), cfg: z.number().min(0).max(30).optional(), sampler_name: z.string().optional(), scheduler: z.string().optional(), width: z.number().int().min(64).max(8192).optional(), height: z.number().int().min(64).max(8192).optional(), denoise: z.number().min(0).max(1).optional(), input_image: z.string().optional(), batch_size: z.number().int().min(1).max(100).optional(), model: z.string().optional(), vae: z.string().optional(), lora: z.array(z.object({ name: z.string(), strength_model: z.number(), strength_clip: z.number() })).optional() }).optional(), client_id: z.string().optional() });
- src/server.ts:68-70 (registration)Tool metadata registration in the ListTools response, including name, description, and derived JSON input schema.name: 'comfy_submit_workflow', description: 'Submit a complete workflow JSON to ComfyUI for execution. Supports parameter overrides for dynamic modifications without editing the workflow structure.', inputSchema: zodToJsonSchema(SubmitWorkflowSchema) as any,
- src/server.ts:149-150 (registration)Handler dispatch in the CallToolRequest switch statement, routing tool calls to the handleSubmitWorkflow function.case 'comfy_submit_workflow': return await handleSubmitWorkflow(args as any);