ComfyUI MCP server

Integrates with ComfyUI to enable natural language-driven image generation using customizable Stable Diffusion workflows
Back to servers
Setup instructions
Provider
Karim Lalani
Release date
Feb 18, 2025
Language
Python
Stats
6 stars

This Python library allows you to run ComfyUI workflows through Open WebUI pipelines, integrating model inference capabilities into your chat interface. The server acts as a bridge between ComfyUI's powerful image generation capabilities and the conversational interface of Open WebUI.

Installation Requirements

Before installing the Comfy MCP Pipeline, ensure you have the following prerequisites:

Preparing Your ComfyUI Workflow

You'll need to export a workflow from ComfyUI:

  1. Open ComfyUI and design your image generation workflow
  2. From the top menu, go to WorkflowExport (API)
  3. Provide a filename and click Confirm
  4. Note the location of this exported JSON file as you'll need it for configuration

Setting Up the Pipeline

Follow these steps to set up the Comfy MCP Pipeline:

  1. Upload the comfy-mcp-pipeline.py file to your Pipeline server following the Open WebUI Pipelines documentation
  2. In the Open WebUI interface, navigate to the Pipelines section
  3. Select comfy-mcp-pipeline (pipe) from the Pipeline Valves list

Configuration

Configure the following required parameters:

  • Comfy Url: The URL where your ComfyUI server is running (e.g., http://localhost:8188)
  • Comfy Url External: The external URL for your ComfyUI server (use the same value as Comfy Url if they're identical)
  • Comfy Workflow Json File: The path to your exported workflow JSON file
  • Prompt Node Id: The ID of the text prompt node from your workflow JSON file
  • Output Node Id: The ID of the generated image node from your workflow JSON file

If the configuration is successful, you should see Comfy MCP Pipeline appear in your list of available models.

Using the Pipeline

Once set up, you can use the pipeline as follows:

  1. In Open WebUI, click on New Chat
  2. Select Comfy MCP Pipeline from the model list
  3. Enter your image generation prompt in the chat box (e.g., "A scenic mountain landscape at sunset")
  4. Send the message
  5. The system will process your prompt through ComfyUI and return the generated image in the chat

The quality and style of the generated images will depend on the specific ComfyUI workflow you've configured.

Troubleshooting

If you don't see the generated image:

  • Check that all URLs are correctly configured
  • Verify that the node IDs match those in your workflow file
  • Ensure ComfyUI is running and accessible from the pipeline server

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "comfy-mcp-pipeline" '{"command":"pip","args":["install","comfy-mcp-server","&& python","-m","comfy_mcp_server"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "comfy-mcp-pipeline": {
            "command": "pip",
            "args": [
                "install",
                "comfy-mcp-server",
                "&& python",
                "-m",
                "comfy_mcp_server"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "comfy-mcp-pipeline": {
            "command": "pip",
            "args": [
                "install",
                "comfy-mcp-server",
                "&& python",
                "-m",
                "comfy_mcp_server"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later