Skip to main content
Glama

comfy_generate_simple

Generate images using pre-configured AI workflows for text-to-image and image-to-image tasks without managing complex JSON configurations.

Instructions

Quick image generation using pre-configured workflow templates (flux_txt2img, sd15_txt2img, sdxl_txt2img, basic_img2img). Ideal for common use cases without managing workflow JSON.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYes
negative_promptNo
templateYes
modelNo
input_imageNo
widthNo
heightNo
stepsNo
cfgNo
seedNo
samplerNo
schedulerNo
denoiseNo
batch_sizeNo

Implementation Reference

  • src/server.ts:72-76 (registration)
    Registration of the 'comfy_generate_simple' tool in the ListToolsRequestHandler, including name, description, and input schema reference.
    { name: 'comfy_generate_simple', description: 'Quick image generation using pre-configured workflow templates (flux_txt2img, sd15_txt2img, sdxl_txt2img, basic_img2img). Ideal for common use cases without managing workflow JSON.', inputSchema: zodToJsonSchema(GenerateSimpleSchema) as any, },
  • src/server.ts:152-153 (registration)
    Dispatch case in CallToolRequestHandler that invokes the handleGenerateSimple function for the tool.
    case 'comfy_generate_simple': return await handleGenerateSimple(args as any);
  • Zod schema defining the input parameters and validation for the comfy_generate_simple tool.
    export const GenerateSimpleSchema = z.object({ prompt: z.string(), negative_prompt: z.string().optional(), template: z.enum(["flux_txt2img", "sd15_txt2img", "sdxl_txt2img", "basic_img2img"]), model: z.string().optional(), input_image: z.string().optional(), width: z.number().int().min(64).max(8192).optional(), height: z.number().int().min(64).max(8192).optional(), steps: z.number().int().min(1).max(150).optional(), cfg: z.number().min(0).max(30).optional(), seed: z.number().int().optional(), sampler: z.string().optional(), scheduler: z.string().optional(), denoise: z.number().min(0).max(1).optional(), batch_size: z.number().int().min(1).max(100).optional() });
  • Core implementation of the comfy_generate_simple tool. Retrieves a workflow template builder based on the specified template, optionally uploads input image for img2img, constructs the workflow with provided parameters, submits it to ComfyUI, and returns the queue response.
    export async function handleGenerateSimple(input: GenerateSimpleInput) { try { const client = getComfyUIClient(); // Get template builder const builder = getTemplateBuilder(input.template); if (!builder) { throw ComfyUIErrorBuilder.validationError(`Unknown template: ${input.template}`); } // Handle input image if needed let inputImage = input.input_image; if (input.template === 'basic_img2img') { if (!inputImage) { throw ComfyUIErrorBuilder.validationError('input_image is required for img2img template'); } // Upload the image const uploadResult = uploadImage(inputImage); inputImage = uploadResult.filename; } // Build workflow from template const workflow = builder({ prompt: input.prompt, negative_prompt: input.negative_prompt, width: input.width, height: input.height, steps: input.steps, cfg: input.cfg, seed: input.seed, sampler: input.sampler, scheduler: input.scheduler, model: input.model, denoise: input.denoise, batch_size: input.batch_size, input_image: inputImage }); // Submit to ComfyUI const response = await client.submitWorkflow(workflow); const summary = `${input.template} generation: ${input.prompt.substring(0, 50)}...`; 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 ? "Generation failed" : `Generation queued successfully at position ${response.number}`, template_used: input.template, workflow_summary: summary }, null, 2) }] }; } catch (error: any) { if (error.error) { 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 }; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Nikolaibibo/claude-comfyui-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server