Submit ComfyUI Workflow
comfy_submit_workflowSubmit a ComfyUI workflow JSON to a local or cloud /prompt endpoint to trigger automated image-to-video generation and processing.
Instructions
Submit a ComfyUI workflow JSON to local or cloud ComfyUI /prompt endpoint.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | No | local | |
| workflowPath | Yes | Path under VIDEO_FACTORY_ROOT to ComfyUI workflow JSON | |
| clientId | No | mcp-video-factory | |
| extraData | No |
Implementation Reference
- src/tools/comfy.ts:19-33 (handler)Handler function that reads a workflow JSON from file, POSTs it to the ComfyUI /prompt endpoint, and returns the response.
async ({ target, workflowPath, clientId, extraData }) => { try { const workflow = await readJsonFile(safePath(workflowPath)); const res = await fetch(`${comfyUrl(target)}/prompt`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ prompt: workflow, client_id: clientId, extra_data: extraData ?? {} }) }); const body = await res.json().catch(() => ({})); if (!res.ok) return errorResult(`ComfyUI request failed: ${res.status}`, body); return textResult({ ok: true, target, response: body }); } catch (err) { return errorResult('Failed to submit ComfyUI workflow', String(err)); } } - src/tools/comfy.ts:12-17 (schema)Zod input schema defining the tool's parameters: target, workflowPath, clientId, and optional extraData.
inputSchema: z.object({ target: z.enum(['local', 'cloud']).default('local'), workflowPath: z.string().describe('Path under VIDEO_FACTORY_ROOT to ComfyUI workflow JSON'), clientId: z.string().default('mcp-video-factory'), extraData: z.record(z.unknown()).optional() }) - src/tools/comfy.ts:7-34 (registration)Registration of the tool named 'comfy_submit_workflow' on the McpServer via registerTool(), exported by registerComfyTools().
server.registerTool( 'comfy_submit_workflow', { title: 'Submit ComfyUI Workflow', description: 'Submit a ComfyUI workflow JSON to local or cloud ComfyUI /prompt endpoint.', inputSchema: z.object({ target: z.enum(['local', 'cloud']).default('local'), workflowPath: z.string().describe('Path under VIDEO_FACTORY_ROOT to ComfyUI workflow JSON'), clientId: z.string().default('mcp-video-factory'), extraData: z.record(z.unknown()).optional() }) }, async ({ target, workflowPath, clientId, extraData }) => { try { const workflow = await readJsonFile(safePath(workflowPath)); const res = await fetch(`${comfyUrl(target)}/prompt`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ prompt: workflow, client_id: clientId, extra_data: extraData ?? {} }) }); const body = await res.json().catch(() => ({})); if (!res.ok) return errorResult(`ComfyUI request failed: ${res.status}`, body); return textResult({ ok: true, target, response: body }); } catch (err) { return errorResult('Failed to submit ComfyUI workflow', String(err)); } } ); - src/config.ts:20-26 (helper)Helper function comfyUrl() that returns the base URL for local or cloud ComfyUI endpoint, used by the handler.
export function comfyUrl(target: Target) { if (target === 'cloud') { if (!config.comfyCloudUrl) throw new Error('COMFY_CLOUD_URL is not configured'); return config.comfyCloudUrl.replace(/\/$/, ''); } return config.comfyLocalUrl.replace(/\/$/, ''); } - src/utils.ts:5-8 (helper)Helper function readJsonFile() that reads and parses a JSON file, used by the handler to load the workflow.
export async function readJsonFile<T = unknown>(filePath: string): Promise<T> { const raw = await fs.readFile(filePath, 'utf8'); return JSON.parse(raw) as T; }