I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

comfyui-mcp-server
lightweight Python-based MCP (Model Context Protocol) server for local ComfyUI
1
Github Watches
7
Github Forks
29
Github Stars
ComfyUI MCP Server
A lightweight Python-based MCP (Model Context Protocol) server that interfaces with a local ComfyUI instance to generate images programmatically via AI agent requests.
Overview
This project enables AI agents to send image generation requests to ComfyUI using the MCP protocol over WebSocket. It supports:
- Flexible workflow selection (e.g.,
basic_api_test.json
). - Dynamic parameters:
prompt
,width
,height
, andmodel
. - Returns image URLs served by ComfyUI.
Prerequisites
- Python 3.10+
-
ComfyUI: Installed and running locally (e.g., on
localhost:8188
). -
Dependencies:
requests
,websockets
,mcp
(install via pip).
Setup
-
Clone the Repository: git clone
cd comfyui-mcp-server -
Install Dependencies:
pip install requests websockets mcp
-
Start ComfyUI:
- Install ComfyUI (see ComfyUI docs).
- Run it on port 8188:
cd <ComfyUI_dir> python main.py --port 8188
- Prepare Workflows:
- Place API-format workflow files (e.g.,
basic_api_test.json
) in theworkflows/
directory. - Export workflows from ComfyUI’s UI with “Save (API Format)” (enable dev mode in settings).
Usage
- Run the MCP Server: python server.py
- Listens on
ws://localhost:9000
.
- Test with the Client: python client.py
- Sends a sample request:
"a dog wearing sunglasses"
with512x512
usingsd_xl_base_1.0.safetensors
. - Output example:
Response from server: { "image_url": "http://localhost:8188/view?filename=ComfyUI_00001_.png&subfolder=&type=output" }
- Custom Requests:
- Modify
client.py
’spayload
to changeprompt
,width
,height
,workflow_id
, ormodel
. - Example:
"params": json.dumps({ "prompt": "a cat in space", "width": 768, "height": 768, "workflow_id": "basic_api_test", "model": "v1-5-pruned-emaonly.ckpt" })
Project Structure
-
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.
Notes
- Ensure your chosen
model
(e.g.,v1-5-pruned-emaonly.ckpt
) exists in<ComfyUI_dir>/models/checkpoints/
. - The MCP SDK lacks native WebSocket transport; this uses a custom implementation.
- For custom workflows, adjust node IDs in
comfyui_client.py
’sDEFAULT_MAPPING
if needed.
Contributing
Feel free to submit issues or PRs to enhance flexibility (e.g., dynamic node mapping, progress streaming).
License
Apache License
相关推荐
I find academic articles and books for research and literature reviews.
Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.
Confidential guide on numerology and astrology, based of GG33 Public information
Emulating Dr. Jordan B. Peterson's style in providing life advice and insights.
Your go-to expert in the Rust ecosystem, specializing in precise code interpretation, up-to-date crate version checking, and in-depth source code analysis. I offer accurate, context-aware insights for all your Rust programming questions.
Advanced software engineer GPT that excels through nailing the basics.
Converts Figma frames into front-end code for various mobile frameworks.
Discover the most comprehensive and up-to-date collection of MCP servers in the market. This repository serves as a centralized hub, offering an extensive catalog of open-source and proprietary MCP servers, complete with features, documentation links, and contributors.
The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, No-code agent builder, MCP compatibility, and more.
Micropython I2C-based manipulation of the MCP series GPIO expander, derived from Adafruit_MCP230xx
Mirror ofhttps://github.com/agentience/practices_mcp_server
Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.
A unified API gateway for integrating multiple etherscan-like blockchain explorer APIs with Model Context Protocol (MCP) support for AI assistants.
Reviews

user_gLoTVYp3
I've recently watched the tutorial video by TahaBakhtari on creating an MCP server, and it was incredibly helpful! The instructions were clear and easy to follow, which made the whole process smooth. Highly recommended for anyone looking to set up their own server. You can check it out at: https://mcp.so/server/TorobjoMCP/TahaBakhtari.