Skip to content
reaatechREAATECH

@reaatech/media-pipeline-mcp-comfyui

npm v0.3.0

A ComfyUI provider for the media pipeline framework that runs image generation, image editing, and video generation on your own GPU via local ComfyUI workflows, with zero API cost. It exports a `ComfyUIProvider` class that accepts a `baseUrl` pointing to a running ComfyUI instance and optionally a `workflowsDir` for custom JSON workflows.

@reaatech/media-pipeline-mcp-comfyui

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

Local ComfyUI provider for the media pipeline framework. Supports image generation, image editing, and video generation via custom ComfyUI workflows at zero API cost. Ships with built-in SDXL and Flux workflows and supports loading custom workflows from a directory.

Installation

terminal
npm install @reaatech/media-pipeline-mcp-comfyui
# or
pnpm add @reaatech/media-pipeline-mcp-comfyui

Feature Overview

  • Zero API cost — all generation runs on your own GPU
  • Built-in workflows — SDXL text-to-image, SDXL image-to-image, Flux text-to-image, and Stable Video Diffusion image-to-video
  • Custom workflows — load your own ComfyUI JSON workflows from a directory
  • Workflow registry — register, list, and retrieve workflows at runtime
  • Poll-based completion — automatic polling with configurable interval and retention
  • Progress streaming — per-node progress surfaced during workflow execution
  • Parameters per workflow — each workflow exposes its own typed input parameter spec

Quick Start

typescript
import { ComfyUIProvider } from "@reaatech/media-pipeline-mcp-comfyui";
 
const provider = new ComfyUIProvider({
  baseUrl: "http://localhost:8188",
  downloadOutputs: true,
});
 
const result = await provider.execute({
  operation: "image.generate",
  params: {
    prompt: "A majestic dragon flying over a castle at sunset",
    negative_prompt: "blurry, low quality, distorted",
    seed: 42,
    steps: 30,
    cfg: 7,
    width: 1024,
    height: 1024,
  },
  config: {},
});
 
console.log(result.metadata.workflow); // "sdxl-text2img"
console.log(result.metadata.prompt_id); // "abc123..."
console.log(result.costUsd); // 0

Using a specific workflow:

typescript
const result = await provider.execute({
  operation: "image.generate",
  params: {
    prompt: "A futuristic city skyline, neon lights, cyberpunk",
    seed: 100,
    steps: 20,
    model: "workflow:flux-text2img",
  },
  config: {},
});

Loading custom workflows from a directory:

typescript
const provider = new ComfyUIProvider({
  baseUrl: "http://localhost:8188",
  workflowsDir: "./my-workflows",
});
 
// Workflows are loaded lazily on first execution
const result = await provider.execute({
  operation: "image.generate",
  params: {
    model: "workflow:custom/my-ip-adapter",
    prompt: "A portrait in the style of Van Gogh",
    image: "https://example.com/reference.png",
  },
  config: {},
});

Supported Operations

OperationBuilt-in WorkflowDescription
image.generatesdxl-text2img (default), flux-text2imgText-to-image generation
image.editsdxl-img2imgImage-to-image transformation
video.generatesvd-img2vidImage-to-video (Stable Video Diffusion)

Built-in Workflows

NameTypeDescription
sdxl-text2imgText-to-ImageSDXL generation with full parameter control
sdxl-img2imgImage-to-ImageSDXL image-to-image with denoise control
flux-text2imgText-to-ImageFlux.1-dev text-to-image generation
svd-img2vidImage-to-VideoStable Video Diffusion with motion control

Configuration

typescript
interface ComfyUIConfig {
  baseUrl?: string;          // Default: "http://localhost:8188"
  workflowsDir?: string;     // Directory of custom JSON workflow files
  downloadOutputs?: boolean; // Default: true
  pollIntervalMs?: number;   // Default: 1000
  retentionMs?: number;      // Default: 600000 (10 min)
}

API Reference

ComfyUIProvider

Main provider class extending MediaProvider.

MemberTypeDescription
supportedOperationsstring[]['image.generate', 'image.edit', 'video.generate']
supportsStreamingSet<string>Operations that surface per-node progress
supportsWebhooksbooleanfalse — ComfyUI has no outbound webhook callbacks
healthCheck()Promise<ProviderHealth>Checks /system_stats endpoint
estimateCost()Promise<CostEstimate>Always returns { costUsd: 0 }
execute(input)Promise<ProviderOutput>Runs a workflow and returns the output data buffer
registerWorkflow(name, workflow)voidRegister a custom workflow at runtime
getWorkflow(name)ComfyUIWorkflow | undefinedRetrieve a workflow by name
listWorkflows()string[]List all registered workflow names
loadWorkflowsFromDir()Promise<void>Load JSON workflows from workflowsDir

createComfyUIProvider(config?)

Factory function that returns a new ComfyUIProvider instance.

ComfyUIConfig

Configuration interface (see Configuration section above).

ComfyUIWorkflow

typescript
interface ComfyUIWorkflow {
  name: string;
  apiFormat: object;                           // Raw ComfyUI API JSON
  inputs: Record<string, ComfyParamSpec>;      // Typed input parameters
  outputs: Record<string, "image" | "video" | "mask" | "latent">;
}

ComfyParamSpec

typescript
interface ComfyParamSpec {
  path: string;                                 // Dot-separated JSON path (e.g. "6.inputs.text")
  type: "string" | "number" | "boolean" | "enum";
  enum?: string[];
  default?: unknown;
  required?: boolean;
}

Built-in Workflow Parameters

SDXL Text-to-Image (sdxl-text2img)

ParameterTypeDefaultRequiredDescription
promptstringYesPositive text prompt
negative_promptstring""NoNegative prompt
seednumber-1NoRandom seed (-1 = random)
stepsnumber20NoSampling steps
cfgnumber7NoCFG scale
widthnumber1024NoImage width
heightnumber1024NoImage height

SDXL Image-to-Image (sdxl-img2img)

ParameterTypeDefaultRequiredDescription
promptstringYesPositive text prompt
negative_promptstring""NoNegative prompt
seednumber-1NoRandom seed
stepsnumber20NoSampling steps
cfgnumber7NoCFG scale
denoisenumber0.75NoDenoising strength
imagestringYesInput image URL or artifact ID

Flux Text-to-Image (flux-text2img)

ParameterTypeDefaultRequiredDescription
promptstringYesPositive text prompt
negative_promptstring""NoNegative prompt
seednumber-1NoRandom seed
stepsnumber20NoSampling steps
cfgnumber1NoCFG scale
widthnumber1024NoImage width
heightnumber1024NoImage height

Stable Video Diffusion (svd-img2vid)

ParameterTypeDefaultRequiredDescription
imagestringYesInput image URL or artifact ID
seednumber-1NoRandom seed
stepsnumber20NoSampling steps
cfgnumber2.5NoCFG scale
widthnumber1024NoOutput width
heightnumber576NoOutput height
video_framesnumber14NoNumber of video frames
motion_bucket_idnumber127NoMotion intensity
fpsnumber6NoFrames per second

Cost Estimation

OperationEstimated Cost
image.generate$0.00 (local)
image.edit$0.00 (local)
video.generate$0.00 (local)

License

MIT