Get ComfyUI History
comfy_get_historyRetrieve the generation history for a specific ComfyUI prompt ID to track video creation progress and access previous outputs.
Instructions
Read ComfyUI generation history by prompt id.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | No | local | |
| promptId | Yes |
Implementation Reference
- src/tools/comfy.ts:46-56 (handler)Handler function for comfy_get_history: fetches ComfyUI generation history by prompt ID from the /history endpoint.
async ({ target, promptId }) => { try { const res = await fetch(`${comfyUrl(target)}/history/${encodeURIComponent(promptId)}`); const body = await res.json().catch(() => ({})); if (!res.ok) return errorResult(`ComfyUI history failed: ${res.status}`, body); return textResult(body); } catch (err) { return errorResult('Failed to get ComfyUI history', String(err)); } } ); - src/tools/comfy.ts:38-44 (schema)Schema definition for comfy_get_history: input validation using Zod with target (local/cloud) and promptId fields.
{ title: 'Get ComfyUI History', description: 'Read ComfyUI generation history by prompt id.', inputSchema: z.object({ target: z.enum(['local', 'cloud']).default('local'), promptId: z.string() }) - src/tools/comfy.ts:36-56 (registration)Registration of comfy_get_history tool via server.registerTool inside registerComfyTools function.
server.registerTool( 'comfy_get_history', { title: 'Get ComfyUI History', description: 'Read ComfyUI generation history by prompt id.', inputSchema: z.object({ target: z.enum(['local', 'cloud']).default('local'), promptId: z.string() }) }, async ({ target, promptId }) => { try { const res = await fetch(`${comfyUrl(target)}/history/${encodeURIComponent(promptId)}`); const body = await res.json().catch(() => ({})); if (!res.ok) return errorResult(`ComfyUI history failed: ${res.status}`, body); return textResult(body); } catch (err) { return errorResult('Failed to get ComfyUI history', String(err)); } } ); - src/config.ts:20-26 (helper)Helper function comfyUrl() that resolves the base URL for local or cloud ComfyUI instance.
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:26-36 (helper)Helper functions textResult and errorResult used by the handler to format success/error responses.
export function textResult(data: unknown) { const text = typeof data === 'string' ? data : JSON.stringify(data, null, 2); return { content: [{ type: 'text' as const, text }] }; } export function errorResult(message: string, details?: unknown) { return { isError: true, content: [{ type: 'text' as const, text: JSON.stringify({ error: message, details }, null, 2) }] }; }