run_workflow_template
Run a saved workflow template against ComfyUI and receive the generated image URLs.
Instructions
Run a saved workflow template against ComfyUI and return the resulting image URLs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Saved template name to run. |
Implementation Reference
- src/tools/templates.ts:217-239 (handler)Handler for the 'run_workflow_template' tool. Reads a saved template from disk, parses it as StoredTemplate, calls client.runWorkflow(record.workflow) to execute it against ComfyUI, and returns the prompt ID and image URLs.
server.tool( "run_workflow_template", "Run a saved workflow template against ComfyUI and return the resulting image URLs.", runSchema, async (args) => { validateName(args.name); let raw: string; try { raw = await fs.readFile(templatePath(store.dir, args.name), "utf-8"); } catch { throw new Error(`Template "${args.name}" not found.`); } const record = JSON.parse(raw) as StoredTemplate; const result = await client.runWorkflow(record.workflow); const lines = [ `Ran template "${record.name}" (prompt_id: ${result.promptId}), ${result.images.length} image(s):`, ...result.images.map((u, i) => ` ${i + 1}. ${u}`), ]; return { content: [{ type: "text" as const, text: lines.join("\n") }], }; }, ); - src/tools/templates.ts:66-68 (schema)Input schema for 'run_workflow_template': requires a single 'name' string parameter identifying the saved template.
const runSchema = { name: z.string().describe("Saved template name to run."), }; - src/server.ts:48-49 (registration)Registration call: registerTemplateTools(s, client, templateStore) is invoked during server setup, which registers all template tools including 'run_workflow_template' on the MCP server.
registerTemplateTools(s, client, templateStore); return s; - src/tools/templates.ts:70-74 (registration)The registerTemplateTools function that registers all template tools (save, list, get, delete, run) on the MCP server. The 'run_workflow_template' tool is registered at line 217-239 via server.tool().
export function registerTemplateTools( server: McpServer, client: ComfyUIClient, store: TemplateStore, ): void { - src/comfyui/client.ts:61-68 (helper)The client.runWorkflow method used by the handler: submits the workflow to ComfyUI and waits for completion, returning promptId and image URLs.
async runWorkflow(workflow: Workflow): Promise<GenerateResult> { const { prompt_id } = await this.submit(workflow); const entry = await this.waitForCompletion(prompt_id); return { promptId: prompt_id, images: extractImageUrls(entry, this.publicUrl), }; }