text_to_image
Transform text prompts into detailed images using customizable parameters such as seed, steps, CFG scale, and denoise strength on the ComfyUI MCP Server.
Instructions
Generate an image from a prompt.
Args:
prompt: The prompt to generate the image from.
seed: The seed to use for the image generation.
steps: The number of steps to use for the image generation.
cfg: The CFG scale to use for the image generation.
denoise: The denoise strength to use for the image generation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cfg | Yes | ||
| denoise | Yes | ||
| prompt | Yes | ||
| seed | Yes | ||
| steps | Yes |
Implementation Reference
- src/server.py:14-31 (handler)The @mcp.tool()-decorated handler function implementing the text_to_image tool. It creates a ComfyUI client, loads the 'text_to_image' workflow, processes it with provided parameters, and returns generated images.@mcp.tool() async def text_to_image(prompt: str, seed: int, steps: int, cfg: float, denoise: float) -> Any: """Generate an image from a prompt. Args: prompt: The prompt to generate the image from. seed: The seed to use for the image generation. steps: The number of steps to use for the image generation. cfg: The CFG scale to use for the image generation. denoise: The denoise strength to use for the image generation. """ auth = os.environ.get("COMFYUI_AUTHENTICATION") comfy = ComfyUI( url=f'http://{os.environ.get("COMFYUI_HOST", "localhost")}:{os.environ.get("COMFYUI_PORT", 8188)}', authentication=auth ) images = await comfy.process_workflow("text_to_image", {"prompt": prompt, "seed": seed, "steps": steps, "cfg": cfg, "denoise": denoise}, return_url=os.environ.get("RETURN_URL", "true").lower() == "true") return images