Logo van ComfyUI MCP Service

ComfyUI MCP Service

Community
zjf2671

基于Model Context Protocol (MCP)的ComfyUI图像生成服务,通过API调用本地ComfyUI实例生成图片,实现自然语言生图自由

Uitgeverzjf2671
Repositoryhh-mcp-comfyui
TaalPython
Forks
6
Sterren
23
Beschikbare tools
0
Transporttypestdio
Categorieën
LicentieMIT
Links
  • Koppel tools aan AI-workflows

    ComfyUI MCP Service biedt MCP-functionaliteit die compatibele AI-clients en agenten kunnen gebruiken.

  • Beschikbare tools: 0

    Bekijk hieronder de aanroepbare acties, inclusief namen en beschrijvingen als de server die beschikbaar stelt.

  • Configuratie om direct te kopiëren

    Gebruik de installatievoorbeelden om deze server in je favoriete MCP-client te configureren.

  • Belangstelling voor het opensourceproject

    Statistieken van de gekoppelde repository (sterren: 23, forks: 6).

MseeP.ai Security Assessment Badge

ComfyUI MCP 服务

English 简体中文 Python 3.12+ License

这是一个基于Model Context Protocol (MCP)的ComfyUI图像生成服务,通过API调用本地ComfyUI实例生成图片。

功能特性

  • 通过MCP协议提供图像生成服务,实现自然语言生图自由
  • 支持动态替换工作流中的提示词和尺寸等参数
  • 自动加载workflows目录下的工作流文件作为资源

新增功能记录

  • [2025-06-29] 支持kontext图片编辑工作流 edit-image-85457440acc11a9f386f8ef284fd62f2.jpg
  • [2025-05-11] 支持工作流文件目录动态配置
  • [2025-05-09] 增加docker构建方式,支持Python 3.12+
  • [2025-05-07] 增加pip构建方式
  • [2025-05-06] 把项目目录src/hh修改成src/hh_mcp_comfyui,增加uvx构建方式
  • [2025-04-26] 增加图生图和移除背景样例工作流及支持图生图工具
  • [2025-04-20] 加入文生图生成工具

效果

  • Cherry Studio中使用效果 image-b8f946109d63fe1ccb5e2d63933e3f9e.png

  • Cline中使用效果 cline_gen_image-48d8515e0b59cd313879c62a1546162d.png ComfyUI_00020_-d9171f87fc9e67fcc1966cdbfb952a0c.png

安装依赖

1. 确保已安装Python 3.12+

2. 使用uv管理Python环境:

  • 安装uv:
    bash
    # On macOS and Linux.
    $ curl -LsSf https://astral.sh/uv/install.sh | sh
    
    # On Windows.
    $ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
    
    # 更新uv(非必要操作):
    $ uv self update

测试运行服务

  • uvx方式
    bash
    $ uvx hh-mcp-comfyui
    
    INFO:hh_mcp_comfyui.server:Scanning for workflows in: C:\Users\tianw\AppData\Local\uv\cache\archive-v0\dp4MTo0f1qL0DdYF_BYCL\Lib\site-packages\hh_mcp_comfyui\workflows
    INFO:hh_mcp_comfyui.server:Starting ComfyUI MCP Server...
  • pip方式
    bash
    $ pip install hh_mcp_comfyui
    
    $ python -m hh_mcp_comfyui
    
    INFO:hh_mcp_comfyui.server:Scanning for workflows in: F:\Python\Python313\Lib\site-packages\hh_mcp_comfyui\workflows
    INFO:hh_mcp_comfyui.server:Starting ComfyUI MCP Server...

出现上面的信息表示服务启动成功

使用方法

必须确保本地ComfyUI实例正在运行(默认地址: http://127.0.0.1:8188) ComfyUI安装地址

Cherry Studio、Cline、Cursor等客户端的使用方式

bash
{
  "mcpServers": {
    "hh-mcp-comfyui": {
      "command": "uvx",
      "args": [
        "hh-mcp-comfyui@latest"
      ],
      "env": {
        "COMFYUI_API_BASE": "http://127.0.0.1:8188",
        "COMFYUI_WORKFLOWS_DIR": "/path/hh-mcp-comfyui/workflows"
      }
    }
  }
}

需要先执行命令窗口先执行:pip install hh_mcp_comfyui

bash
{
  "mcpServers": {
    "hh-mcp-comfyui": {
      "command": "python",
      "args": [
        "-m",
        "hh_mcp_comfyui"
      ],
      "env": {
        "COMFYUI_API_BASE": "http://127.0.0.1:8188",
        "COMFYUI_WORKFLOWS_DIR": "/path/hh-mcp-comfyui/workflows"
      }
    }
  }
}

前提是已安装docker

bash
{
  "mcpServers": {
    "hh-mcp-comfyui": {
      "command": "docker",
      "args": [
          "run",
          "--net=host",
          "-v",
          "/path/hh-mcp-comfyui/workflows:/app/workflows",
          "-i",
          "--rm",
          "zjf2671/hh-mcp-comfyui:latest"
      ],
      "env": {
        "COMFYUI_API_BASE": "http://127.0.0.1:8188"
      }
    }
  }
}

样例工作流copy到指定工作流目录:

(注意:使用下面uvx或pip方式找到你的安装工作流目录的位置把样例工作流添加进去,然后重启你的MCP服务)

  • uvx

    bash
    $ uvx hh-mcp-comfyui

    image-2-f89caf964efbccdad7b6fa2672d1cac0.png

  • pip

    bash
    #首先安装依赖
    $ pip install hh_mcp_comfyui
    $ python -m hh_mcp_comfyui

    image-3-03a069f40492fea9947a351b8707aa3f.png

测试

使用MCP Inspector测试服务端工具

  • uvx方式
    bash
    $ npx @modelcontextprotocol/inspector uvx hh-mcp-comfyui
  • pip方式
    bash
    $ pip install hh_mcp_comfyui
    $ npx @modelcontextprotocol/inspector python -m hh_mcp_comfyui
  • docker方式
    bash
    $ npx @modelcontextprotocol/inspector docker run --net=host -i --rm zjf2671/hh-mcp-comfyui

然后点击连接如图即可调试: image-1-44c6a003ee317093afe5a61cfe028720.png

使用注意事项(针对没有用过comfyui的特别注意)

  • 默认工作流为t2image_bizyair_flux
  • 图片尺寸默认为1024x1024
  • 服务启动时会自动加载workflows目录下的所有JSON工作流文件
  • 如果你使用的是本项目中的样例工作流需要在comfyui中下载个插件,详细操作请查看:样例工作流插件安装教程
  • 如果使用你本地的comfyui工作流的话,先要保证你的工作流能在comfyui正常运行,然后需要导出(API)的JSON格式,并放入到你本地的/path/hh_mcp_comfyui/workflows目录中

添加新工作流

  1. 将工作流JSON文件放入/path/hh_mcp_comfyui/workflows目录中

    如果是uvx和pip启动方式请看上面 《样例工作流copy到指定工作流目录》 的使用方式

  2. 重启服务自动加载新工作流

开发

项目结构

.
├── .gitignore
├── .python-version
├── pyproject.toml
├── README.md
├── uv.lock
├── example/              # 示例工作流目录
│   └── workflows/
│       ├── i2image_bizyair_sdxl.json
│       ├── t2image_bizyair_flux.json
│       ├── i2image_cogview4.json
│       └── t2image_sd1.5.json
├── src/                  # 源代码目录
│   └── hh_mcp_comfyui/
│       ├── comfyui_client.py    # ComfyUI客户端实现
│       ├── server.py            # MCP服务主文件
│       └── workflows/           # 工作流文件目录

初始化项目开发环境:

bash
# Clone the repository.
$ git clone https://github.com/zjf2671/hh-mcp-comfyui.git

$ cd hh-mcp-comfyui

# Initialized venv
$ uv venv

# Activate the virtual environment.
$ .venv\Scripts\activate

# Install dependencies.
$ uv lock
Resolved 30 packages in 1ms

# sync dependencies.
$ uv sync
Resolved 30 packages in 2.54s
Audited 29 package in 0.02ms

检查服务是否正常

bash
$ uv --directory 你本地安装目录/hh-mcp-comfyui run hh-mcp-comfyui

INFO:__main__:Scanning for workflows in: D:\cygitproject\hh-mcp-comfyui\src\hh_mcp_comfyui\workflows
INFO:__main__:Registered resource: workflow://t2image_bizyair_flux -> t2image_bizyair_flux.json
INFO:__main__:Starting ComfyUI MCP Server...

使用MCP Inspector测试服务端工具

bash
$ npx @modelcontextprotocol/inspector uv --directory 你本地安装目录/hh-mcp-comfyui run hh-mcp-comfyui

MCP配置

bash
{
  "mcpServers": {
    "hh-mcp-comfyui": {
      "command": "uv",
      "args": [
        "--directory",
        "项目绝对路径(例如:D:/hh-mcp-comfyui)",
        "run",
        "hh-mcp-comfyui"
      ],
      "env": {
        "COMFYUI_API_BASE": "http://127.0.0.1:8188",
        "COMFYUI_WORKFLOWS_DIR": "/path/hh-mcp-comfyui/workflows"
      }
    }
  }
}

贡献

  1. Fork项目
  2. 创建特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 打开Pull Request

如有问题可以到公众号中联系我:

公众号二维码


Installatie

TypingMind
Vereisten:

Node.js 18+

{
  "mcpServers": {
    "zjf2671-hh-mcp-comfyui": {
      "command": "uvx",
      "args": [
        "hh-mcp-comfyui"
      ]
    }
  }
}

Gebruik ComfyUI MCP Service MCP met meerdere AI-modellen

TypingMind koppelt MCP-tools aan de werkruimte. Zodra ComfyUI MCP Service is verbonden, kun je de verbinding dus met verschillende AI-modellen in TypingMind gebruiken, zonder die voor elk model apart in te stellen. Deze MCP-integratie draait lokaal via de TypingMind MCP-connector op je apparaat.

Installatiehandleiding voor de lokale connector

Gebruik dit als de MCP-server toegang nodig heeft tot lokale bestanden, apps of privébronnen op je computer.

1

Open de MCP-instellingen

Ga in TypingMind naar Instellingen, Geavanceerde instellingen en vervolgens Model Context Protocol. Kies daar Connector instellen.

  1. Open TypingMind in je browser.
  2. Klik op het pictogram Instellingen.
  3. Ga naar Geavanceerde instellingen.
  4. Open het gedeelte Model Context Protocol.
  5. Klik op Connector instellen en kies Dit apparaat.
Instelscherm voor de TypingMind MCP-connector met Dit apparaat geselecteerd
2

Voer de connectoropdracht uit

Kies Dit apparaat, kopieer de opdracht uit TypingMind en voer deze uit in Terminal. Laat het proces draaien zolang je MCP gebruikt.

  1. Kopieer de installatieopdracht die TypingMind toont.
  2. Open Terminal op macOS of Windows Terminal op Windows.
  3. Plak de opdracht en voer deze uit.
  4. Keur de pakketinstallatie goed als Terminal vraagt of je wilt doorgaan.
  5. Laat het proces in het Terminal-venster draaien zolang je MCP-tools gebruikt.
3

Voeg ComfyUI MCP Service toe als server

Klik op Servers bewerken zodra de connectorstatus Gereed is en plak de MCP-serverconfiguratie.

  1. Wacht tot de connectorstatus op ‘Gereed’ staat.
  2. Klik op Servers bewerken.
  3. Plak de MCP-serverconfiguratie van ComfyUI MCP Service.
  4. Sla de serverlijst op.
  5. Vernieuw de pagina als je wilt controleren of de connectorstatus nog op ‘Gereed’ staat.
MCP-instellingen van TypingMind met een actieve server en de knop Servers bewerken
{
  "mcpServers": {
    "zjf2671-hh-mcp-comfyui": {
      "command": "npx",
      "args": [
        "-y",
        "hh-mcp-comfyui"
      ]
    }
  }
}
4

Gebruik de verbinding met verschillende modellen

Sla de serverlijst op, open Plug-ins en schakel de MCP-tools van ComfyUI MCP Service in. Selecteer vervolgens een ondersteund AI-model in TypingMind en gebruik de tools in de chat of wijs ze toe aan een AI-agent.

  1. Open de pagina Plug-ins in TypingMind.
  2. Schakel de MCP-tools van ComfyUI MCP Service in.
  3. Start een chat en kies het AI-model dat je wilt gebruiken.
  4. Gebruik de MCP-tools in een chat of wijs ze toe aan een AI-agent.
  5. Schakel wanneer nodig over naar een ander AI-model zonder opnieuw verbinding te maken met MCP.
TypingMind-chat met ingeschakelde MCP-tools en een geselecteerd AI-model
Kun je ComfyUI MCP Service gebruiken om me hiermee te helpen?
ComfyUI MCP Service
Zeker. Ik heb het gelezen.
Dit vond ik met ComfyUI MCP Service.

Veelgestelde vragen

Waarvoor wordt de MCP-server ComfyUI MCP Service gebruikt?

ComfyUI MCP Service is een MCP-server waarmee compatibele AI-clients toegang krijgen tot externe tools en context. In TypingMind hoef je deze MCP-server maar één keer toe te voegen om de tools beschikbaar te maken in je AI-werkruimte.

Kan ik ComfyUI MCP Service MCP met meerdere AI-modellen in TypingMind gebruiken?

Ja. TypingMind verbindt MCP-tools op werkruimteniveau. Daardoor kun je ComfyUI MCP Service gebruiken met verschillende AI-modellen, zoals Claude, ChatGPT, Gemini of andere modellen die je in TypingMind hebt ingesteld, zonder de MCP-server voor elk model afzonderlijk in te stellen.

Waarom ComfyUI MCP Service MCP gebruiken met TypingMind?

TypingMind is een van de beste interfaces voor chats met LLM's, omdat het meerdere AI-modellen, prompts, plug-ins, AI-agenten, API-sleutels en MCP-tools samenbrengt in één werkruimte. Als ComfyUI MCP Service verbonden is, kun je de MCP-tools ervan gebruiken met je favoriete modellen en je chatworkflow overzichtelijk houden in TypingMind.

Hoe verbind ik ComfyUI MCP Service MCP met TypingMind?

ComfyUI MCP Service werkt via de lokale MCP-connector van TypingMind. Dit is de beste optie als de MCP-server toegang nodig heeft tot lokale bestanden, desktopapps, opdrachtregeltools of privébronnen op je computer.

Welke tools biedt ComfyUI MCP Service MCP in TypingMind?

ComfyUI MCP Service biedt MCP-functies die je kunt inschakelen via de pagina Plug-ins in TypingMind. Je kunt ze gebruiken in chats of toewijzen aan AI-agenten.

Moet ik mijn API-sleutels delen met TypingMind om ComfyUI MCP Service MCP te gebruiken?

Nee. TypingMind werkt in de eerste plaats lokaal en laat je de controle houden over je modelaanbieders, API-sleutels, prompts en MCP-configuratie. Als ComfyUI MCP Service authenticatie vereist, voeg je bij het maken van de verbinding de vereiste headers, OAuth-instellingen of lokale configuratie voor die MCP-server toe.

Gerelateerde MCP-servers

Bekijk alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇