ComfyUI MCP Server

by Overseer66
Integrations
  • Supports environment variable configuration for ComfyUI connections through .env files, allowing users to customize host and port settings.

  • Supports containerized deployment of the MCP server through Docker, with instructions for building and configuring the Docker image.

  • Provides integration with ComfyUI, a Python-based stable diffusion interface, enabling AI image generation through tools like text_to_image and download_image capabilities.

ComfyUI MCP 服务器

1.概述

  • 用于集成 ComfyUI 与 MCP 的服务器实现。
  • ⚠️ 重要提示:此服务器需要正在运行的 ComfyUI 服务器。
    • 您必须托管自己的 ComfyUI 服务器,
    • 或者访问现有的 ComfyUI 服务器地址。

2. 调试

2.1 ComfyUI 调试

python src/test_comfyui.py

2.2 MCP调试

mcp dev src/server.py

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.json
    • CursorAI 的示例图像
  • 使用 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 时,请考虑:
    1. .env中设置RETURN_URL=false以字节形式接收图像数据。
    2. .env中的COMFYUI_HOST设置为适当的地址(例如, host.docker.internal或服务器的 IP)。
    3. 注意:使用二进制数据时,大型图像有效载荷可能会超出响应限制。
5.2.1 构建 Docker 镜像
# 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 使用现有图像

您也可以使用预先构建的图像。

{ "mcpServers": { "comfyui": { "command": "docker", "args": [ "run", "-i", "--rm", "-p", "3001:3000", "overseer66/mcp-comfyui" ] } } }
5.2.3 使用 SSE 传输
  1. 使用 Docker 运行 SSE 服务器:
    docker run -i --rm -p 8001:8000 overseer66/mcp-comfyui-sse
  2. 配置mcp.json (如果需要,将 localhost 更改为您的 IP 或域):
    { "mcpServers": { "comfyui": { "url": "http://localhost:8001/sse" } } }

注意:当添加新的工作流程作为工具时,您需要重建并重新部署 Docker 镜像以使其可用。


-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

ComfyUI 与 MCP 集成的服务器,允许用户通过自然语言交互生成图像并下载。

  1. 1.概述
    1. 调试
      1. 2.1 ComfyUI 调试
      2. 2.2 MCP调试
    2. 3.安装和配置
      1. 3.1 ComfyUI 配置
      2. 3.2 添加自定义工作流程
    3. 4.内置工具
      1. 如何运行
        1. 5.1 使用紫外线(推荐)
        2. 5.2 使用 Docker

      Related MCP Servers

      • A
        security
        A
        license
        A
        quality
        A powerful MCP server for fetching and transforming web content into various formats (HTML, JSON, Markdown, Plain Text) with ease.
        Last updated -
        4
        146
        12
        TypeScript
        MIT License
        • Apple
        • Linux
      • -
        security
        A
        license
        -
        quality
        The 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 -
        7
        Python
        MIT License
      • -
        security
        A
        license
        -
        quality
        A MCP server that integrates with Cursor IDE to generate images based on text descriptions using JiMeng AI, allowing users to create and save custom images directly within their development environment.
        Last updated -
        82
        Python
        MIT License
        • Apple
        • Linux
      • -
        security
        -
        license
        -
        quality
        A TypeScript-based MCP server that lets users generate images using OpenAI's dall-e-3 model by providing a prompt and image name.
        Last updated -
        1

      View all related MCP servers

      ID: 1ohqlsrp1j