ComfyUI MCP Server
This server enables AI assistants to generate and manage images through ComfyUI by providing workflow execution and image handling capabilities.
Core Tools:
Generate images from text prompts using
text_to_imagewith configurable parameters (seed, steps, CFG scale, denoise strength)Download generated images using
download_imageto save images from URLs to local file pathsExecute workflows from files using
run_workflow_from_fileto run ComfyUI workflow JSON files stored on diskExecute workflows from JSON data using
run_workflow_from_jsonto directly run workflows by providing JSON objectsAdd custom workflows by placing JSON files in the workflows directory to create new tools
Configuration & Deployment:
Requires a running ComfyUI server instance (self-hosted or remote)
Configurable via environment variables (
COMFYUI_HOST,COMFYUI_PORT)Supports multiple deployment options: UV (recommended), Docker with prebuilt images, and SSE transport
Supports containerized deployment of the MCP server through Docker, with instructions for building and configuring the Docker image.
Supports environment variable configuration for ComfyUI connections through .env files, allowing users to customize host and port settings.
Provides integration with ComfyUI, a Python-based stable diffusion interface, enabling AI image generation through tools like text_to_image and download_image capabilities.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ComfyUI MCP Server generate an image of a futuristic city at sunset"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ComfyUI MCP Server
1. Overview
A server implementation for integrating ComfyUI with MCP.
⚠️ IMPORTANT: This server requires a running ComfyUI server.
You must either host your own ComfyUI server,
or have access to an existing ComfyUI server address.
Related MCP server: ComfyUI MCP
2. Debugging
2.1 ComfyUI Debugging
python src/test_comfyui.py2.2 MCP Debugging
mcp dev src/server.py3. Installation and Configuration
3.1 ComfyUI Configuration
Edit
src/.envto set ComfyUI host and port:COMFYUI_HOST=localhost COMFYUI_PORT=8188
3.2 Adding Custom Workflows
To add new tools, place your workflow JSON files in the
workflowsdirectory and declare them as new tools in the system.
4. Built-in Tools
text_to_image
Returns only the URL of the generated image.
To get the actual image:
Use the
download_imagetool, orAccess the URL directly in your browser.
download_image
Downloads images generated by other tools (like
text_to_image) using the image URL.
run_workflow_with_file
Run a workflow by providing the path to a workflow JSON file.
# You should ask to agent like this. Run comfyui workflow with text_to_image.jsonexample image of CursorAI

run_workflow_with_json
Run a workflow by providing the workflow JSON data directly.
# You should ask to agent like this. Run comfyui workflow with this { "3": { "inputs": { "seed": 156680208700286, "steps": 20, ... (workflow JSON example) }
5. How to Run
5.1 Using UV (Recommended)
Example
mcp.json:{ "mcpServers": { "comfyui": { "command": "uv", "args": [ "--directory", "PATH/MCP/comfyui", "run", "--with", "mcp", "--with", "websocket-client", "--with", "python-dotenv", "mcp", "run", "src/server.py:mcp" ] } } }
5.2 Using Docker
Downloading images to a local folder with
download_imagemay be difficult since the Docker container does not share the host filesystem.When using Docker, consider:
Set
RETURN_URL=falsein.envto receive image data as bytes.Set
COMFYUI_HOSTin.envto the appropriate address (e.g.,host.docker.internalor your server's IP).Note: Large image payloads may exceed response limits when using binary data.
5.2.1 Build Docker Image
# First build image
docker image build -t mcp/comfyui .{
"mcpServers": {
"comfyui": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-p",
"3001:3000",
"mcp/comfyui"
]
}
}
}5.2.2 Using Existing Images
Also you can use prebuilt image.
{
"mcpServers": {
"comfyui": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-p",
"3001:3000",
"overseer66/mcp-comfyui"
]
}
}
}5.2.3 Using SSE Transport
Run the SSE server with Docker:
docker run -i --rm -p 8001:8000 overseer66/mcp-comfyui-sseConfigure
mcp.json(change localhost to your IP or domain if needed):{ "mcpServers": { "comfyui": { "url": "http://localhost:8001/sse" } } }
NOTE: When adding new workflows as tools, you need to rebuild and redeploy the Docker images to make them available.
Available Tools
4 toolsdownload_imageA
Download an image from a URL and save it to a file.
Args:
url: The URL of the image to download.
save_path: The absolute path to save the image to. Must be an absolute path, otherwise the image will be saved relative to the server location.
Inputs: url (required), save_path (required).
run_workflow_from_fileC
Run a workflow from a file.
Args:
file_path: The absolute path to the file to run.
Inputs: file_path (required).
run_workflow_from_jsonC
Run a workflow from a JSON data.
Args:
json_data: The JSON data to run.
Inputs: json_data (required).
text_to_imageB
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.
Inputs: prompt (required), seed (required), steps (required), cfg (required), +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a clearly distinct purpose: downloading images, running workflows from files, running workflows from JSON, and generating images from text. There is no overlap in functionality, making it easy for an agent to select the correct tool for any given task without confusion.
All tool names follow a consistent verb_noun pattern with underscores (e.g., download_image, run_workflow_from_file, run_workflow_from_json, text_to_image). This predictable naming scheme enhances readability and usability for agents.
With 4 tools, the server is well-scoped for basic ComfyUI operations, covering key areas like image handling and workflow execution. However, it might feel slightly thin for advanced use cases, such as missing tools for managing workflows or querying server status, but it remains reasonable for its purpose.
The tools cover core functionalities like image generation and workflow execution, but there are notable gaps. For example, there are no tools for listing available workflows, updating or deleting workflows, or handling errors, which could limit agents in more complex scenarios within the ComfyUI domain.
Maintenance
Related MCP Connectors
MCP server for Qwen Image 3 AI image generation
MCP server for Flux AI image generation
Generate AI images and videos from any compatible MCP client.
Generate AI images, video, music, and sound effects, and upscale them, from any MCP client.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA lightweight MCP server that bridges AI agents with a local ComfyUI instance to generate and iteratively refine images, audio, and video through conversational tool calls.20 npmMIT
- FlicenseNot gradedqualityDmaintenanceMCP server that connects local ComfyUI to AI agents, enabling natural language control of ComfyUI for creating workflows, generating images, and managing the queue.1-
- AlicenseAqualityDmaintenanceMCP server that provides image generation, captioning, and tagging via ComfyUI API, configurable for agent tools.43MIT
- AlicenseNot gradedqualityCmaintenanceMCP server for generating AI images with local ComfyUI, featuring a reference-image-to-replication toolchain including Danbooru tag lookup, local Ollama vision, deobfuscation, and Civitai LoRA search/download.3MIT