No project description provided
Project description
comfyui-mcp
A Model Context Protocol(MCP) server that exposes ComfyUI workflows as callable MCP tools. Built using FastMCP and comfyui-utils.
Installation
Contents of this package require Python 3.11 or higher.
pip install comfyui-mcp
Quick Start
mcpo --port 8000 --api-key "AwesomeKey" -- python3 -m comfyui_mcp.server
Arguments
ComfyUI Connection (--comfyui.*)
--comfyui.host(default:127.0.0.1:8188) - ComfyUI host and port--comfyui.request_timeout(default:5) - Timeout in seconds for ComfyUI API requests--comfyui.use_remote_workflow(default:True) - Pull workflows from ComfyUI API (True) or load from local directory (False)--comfyui.workflow_directory(default:workflows) - Local directory path for workflow JSON files
Output Formatting (--generate.*)
--generate.audio_url_template- Template for audio output URLs (vars:{index},{url})--generate.image_url_template- Template for image output URLs (vars:{index},{url})--generate.unknown_url_template- Template for unknown output types (vars:{index},{url})--generate.nothing_generated_message- Message when workflow executes but produces no output--generate.reply_include_workflow(default:True) - Include executed workflow parameters in response--generate.reply_workflow_format_indent(default:2) - JSON indentation for workflow output--generate.reply_workflow_format_sort_keys(default:True) - Sort JSON keys in workflow output--generate.reply_workflow_template- Template for workflow parameters section (vars:{workflow_params})--generate.result_generated_message_template- Overall message template (vars:{image_list})
Architecture Overview
src/comfyui_mcp/
- __about__.py: Version and license metadata
- argument_parser.py: CLI argument definitions using pydantic
- base_types.py: Shared type aliases
- function_utils.py: Dynamic function wrapper generation
- workflow_loader.py: Load workflows from disk or ComfyUI API
- workflow_utils.py: Workflow preparation and invocation
- server.py: FastMCP server entry point
How It Works
-
Workflow Preparation:
- For local workflows: Export your ComfyUI workflow in API format (use "Save (API Format)" in ComfyUI's menu). Place the JSON file in your configured workflows directory.
- For remote workflows: Build and save your workflow in ComfyUI, then start or restart the MCP server. The server will automatically fetch and register available workflows from the ComfyUI instance.
-
Tool Registration: The server parses workflow JSON and automatically detects parameters by scanning for:
- Primitive nodes (
PrimitiveFloat,PrimitiveInt,PrimitiveString, etc.) - extracted as typed parameters - LoadImageOutput nodes - exposed as image input parameters
- Node titles (from
_meta.title) become the parameter names in the MCP tool
- Primitive nodes (
-
Workflow Execution: When a tool is invoked:
- User-provided parameters are mapped back to their corresponding primitive nodes
- The workflow is deep-copied and parameter values are injected into
inputs.valuefields - The prepared workflow is submitted to ComfyUI's API
- Results are polled until completion
- Generated outputs are returned as accessible URLs (format is user-configurable)
-
Batch Processing: Supports
submit_batchparameter for generating multiple variations:- Automatically randomizes seeds for each generation
- Executes workflows sequentially
- Collects and returns all results together
Development
pip setup -hatch
hatch test
hatch build
hatch run release
Contributing
- Fork the repo on GitHub.
- Make changes, add tests, and build
- Run
hatch testto ensure all passes - Submit a PR
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file comfyui_mcp-0.0.5.tar.gz.
File metadata
- Download URL: comfyui_mcp-0.0.5.tar.gz
- Upload date:
- Size: 22.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cca674b2ed5f5e5e468aa73ff700930542381add70fa741e00db5cd1acabe50d
|
|
| MD5 |
21a2e10bb87f75af608175366c756c47
|
|
| BLAKE2b-256 |
5b2f3febe0d9922bb019db8e0f69e94100ba550acca24e06fbf567f50104075a
|
Provenance
The following attestation bundles were made for comfyui_mcp-0.0.5.tar.gz:
Publisher:
ci.yml on ModdingFox/comfyui_mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
comfyui_mcp-0.0.5.tar.gz -
Subject digest:
cca674b2ed5f5e5e468aa73ff700930542381add70fa741e00db5cd1acabe50d - Sigstore transparency entry: 975847757
- Sigstore integration time:
-
Permalink:
ModdingFox/comfyui_mcp@80d37f52ab7d0bfc843b985b337118516c5f3012 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/ModdingFox
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@80d37f52ab7d0bfc843b985b337118516c5f3012 -
Trigger Event:
push
-
Statement type:
File details
Details for the file comfyui_mcp-0.0.5-py3-none-any.whl.
File metadata
- Download URL: comfyui_mcp-0.0.5-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1f02edab456616e0019d4ba7b612d0e7a552ab465b066d22c4d994c21c8c922
|
|
| MD5 |
440f55c80da72534412f7d205d1fa6f0
|
|
| BLAKE2b-256 |
7f0225d5beabb5a41655515530b9aa7a7afc7055a6e41958b3de72d1fc5143b9
|
Provenance
The following attestation bundles were made for comfyui_mcp-0.0.5-py3-none-any.whl:
Publisher:
ci.yml on ModdingFox/comfyui_mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
comfyui_mcp-0.0.5-py3-none-any.whl -
Subject digest:
d1f02edab456616e0019d4ba7b612d0e7a552ab465b066d22c4d994c21c8c922 - Sigstore transparency entry: 975847758
- Sigstore integration time:
-
Permalink:
ModdingFox/comfyui_mcp@80d37f52ab7d0bfc843b985b337118516c5f3012 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/ModdingFox
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@80d37f52ab7d0bfc843b985b337118516c5f3012 -
Trigger Event:
push
-
Statement type: