ComfyUI MCP 服务器
1.概述
用于集成 ComfyUI 与 MCP 的服务器实现。
⚠️ 重要提示:此服务器需要正在运行的 ComfyUI 服务器。
您必须托管自己的 ComfyUI 服务器,
或者访问现有的 ComfyUI 服务器地址。
2. 调试
2.1 ComfyUI 调试
2.2 MCP调试
3.安装和配置
3.1 ComfyUI 配置
编辑
src/.env
以设置 ComfyUI 主机和端口:COMFYUI_HOST=localhost COMFYUI_PORT=8188
3.2 添加自定义工作流程
要添加新工具,请将工作流 JSON 文件放在
workflows
目录中,并在系统中将其声明为新工具。
4.内置工具
文本转图像
仅返回所生成图像的 URL。
要获取实际图像:
使用
download_image
工具,或者直接在浏览器中访问该 URL。
下载图片
使用图像 URL 下载由其他工具(如
text_to_image
)生成的图像。
运行工作流与文件
通过提供工作流 JSON 文件的路径来运行工作流。
# You should ask to agent like this. Run comfyui workflow with text_to_image.jsonCursorAI 的示例图像
使用 json 运行工作流
通过直接提供工作流 JSON 数据来运行工作流。
# You should ask to agent like this. Run comfyui workflow with this { "3": { "inputs": { "seed": 156680208700286, "steps": 20, ... (workflow JSON example) }
5. 如何运行
5.1 使用紫外线(推荐)
示例
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 使用 Docker
由于 Docker 容器不共享主机文件系统,因此使用
download_image
将图像下载到本地文件夹可能会很困难。使用 Docker 时,请考虑:
在
.env
中设置RETURN_URL=false
以字节形式接收图像数据。将
.env
中的COMFYUI_HOST
设置为适当的地址(例如,host.docker.internal
或服务器的 IP)。注意:使用二进制数据时,大型图像有效载荷可能会超出响应限制。
5.2.1 构建 Docker 镜像
5.2.2 使用现有图像
您也可以使用预先构建的图像。
5.2.3 使用 SSE 传输
使用 Docker 运行 SSE 服务器:
docker run -i --rm -p 8001:8000 overseer66/mcp-comfyui-sse配置
mcp.json
(如果需要,将 localhost 更改为您的 IP 或域):{ "mcpServers": { "comfyui": { "url": "http://localhost:8001/sse" } } }
注意:当添加新的工作流程作为工具时,您需要重建并重新部署 Docker 镜像以使其可用。
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
ComfyUI 与 MCP 集成的服务器,允许用户通过自然语言交互生成图像并下载。
Related MCP Servers
- -securityAlicense-qualityThe Comfy MCP Server uses the FastMCP framework to generate images from prompts by interacting with a remote Comfy server, allowing automated image creation based on workflow configurations.Last updated -30MIT License
- AsecurityAlicenseAqualityAn MCP Server that integrates with Stability AI's API to provide high-quality image generation, editing, and manipulation capabilities including background removal, outpainting, search-and-replace, and upscaling.Last updated -8278MIT License
- AsecurityAlicenseAqualityA MCP server that integrates with Stable Diffusion WebUI to provide text-to-image generation and image upscaling capabilities through simple API calls.Last updated -524MIT License
- -securityFlicense-qualityThis MCP server enables interaction with the Giphy API through natural language, allowing users to search, retrieve, and manage GIFs through the Multi-Agent Conversation Protocol.Last updated -