ComfyUI图像生成器
HTTP-SSE通过AI代理请求生成图像的MCP服务器
通过AI代理请求生成图像的MCP服务器
A lightweight Python-based MCP (Model Context Protocol) server that interfaces with a local ComfyUI instance to generate images programmatically via AI agent requests.
This project enables AI agents to send image generation requests to ComfyUI using the MCP protocol over WebSocket. It supports:
basic_api_test.json
).prompt
, width
, height
, and model
.localhost:8188
).requests
, websockets
, mcp
(install via pip).Clone the Repository:
git clone
Install Dependencies:
pip install requests websockets mcp
Start ComfyUI:
cd <ComfyUI_dir>
python main.py --port 8188
basic_api_test.json
) in the workflows/
directory.ws://localhost:9000
."a dog wearing sunglasses"
with 512x512
using sd_xl_base_1.0.safetensors
.Response from server:
{
"image_url": "http://localhost:8188/view?filename=ComfyUI_00001_.png&subfolder=&type=output"
}
client.py
’s payload
to change prompt
, width
, height
, workflow_id
, or model
."params": json.dumps({
"prompt": "a cat in space",
"width": 768,
"height": 768,
"workflow_id": "basic_api_test",
"model": "v1-5-pruned-emaonly.ckpt"
})
server.py
: MCP server with WebSocket transport and lifecycle support.comfyui_client.py
: Interfaces with ComfyUI’s API, handles workflow queuing.client.py
: Test client for sending MCP requests.workflows/
: Directory for API-format workflow JSON files.model
(e.g., v1-5-pruned-emaonly.ckpt
) exists in <ComfyUI_dir>/models/checkpoints/
.comfyui_client.py
’s DEFAULT_MAPPING
if needed.Feel free to submit issues or PRs to enhance flexibility (e.g., dynamic node mapping, progress streaming).
Apache License