ComfyUI-Agent-Bridge
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ComfyUI-Agent-BridgeGenerate an image of a cat using my ComfyUI workflow"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ComfyUI-Nodes-Agents
In-graph Agent Emit / Agent Receive nodes on named channels, plus an in-process MCP server, so an externally-running coding agent (Claude Code / Codex) can exchange text and images with a ComfyUI workflow mid-pipeline and trigger runs.
How it works
A thread-safe singleton ChannelStore holds, per named channel, an inbox
(graph -> agent) and an outbox (agent -> graph), each with a turn counter.
ComfyUI nodes touch the store directly (same process). A FastMCP
streamable-HTTP server runs in a daemon thread on a side port; its tools touch
the same singleton. Text crosses inline; images cross by file path through a
temp dir.
inbox = graph -> agent: written by
Agent Emit, read by thecomfy_pulltool.outbox = agent -> graph: written by the
comfy_pushtool, read byAgent Receive.
Related MCP server: ComfyUI MCP
Install
Clone (or symlink) this repo into your ComfyUI custom_nodes directory and
install the dependency, then restart ComfyUI:
cd ComfyUI/custom_nodes
git clone https://github.com/ethanfel/ComfyUI-Agent-Bridge
pip install -r ComfyUI-Agent-Bridge/requirements.txt # mcp>=1.2.0 (validated on 1.28.1)(The custom_nodes subdirectory name is arbitrary — ComfyUI loads the package regardless.)
On startup ComfyUI loads the package and the bridge logs its URL:
[comfyui-nodes-agents] MCP bridge on http://127.0.0.1:9188/mcp (claude mcp add --transport http comfy http://127.0.0.1:9188/mcp)The bridge autostarts from __init__.py and is wrapped in try/except, so a
bridge failure never blocks ComfyUI from loading the nodes.
The two nodes (category agents/bridge)
Agent Emit (-> agent) — send from the graph to the agent.
Inputs:
channel(STRING, defaultmain); optionaltext(multiline STRING),image(IMAGE).Writes the latest text/image to the channel inbox (image is saved to a PNG in the temp dir and the path is stored). Passes
(text, image)straight through as outputs, so you can wire it inline.
Agent Receive (<- agent) — receive from the agent into the graph.
Inputs:
channel(STRING, defaultmain);wait_seconds(FLOAT, default30.0, max86400);keep_last(BOOLEAN, defaulttrue);stop_on_timeout(BOOLEAN, defaulttrue).Blocks up to
wait_secondsfor a newcomfy_pushon the channel, then outputs(text, image). Each pushed value is consumed once (turn-based), so a second receive with no new push won't replay it.keep_last— on timeout (no new message), output the last message again instead of blanking. Great for Auto Queue so the display holds steady between evals. Off → returns""+ a 64x64 black placeholder on timeout.stop_on_timeout— on timeout, signal the ComfyUI frontend to switch Auto Queue off, so the loop halts when the message stream goes quiet instead of spinning. (Handled by the bundledweb/agent_bridge.js; best-effort across ComfyUI frontend versions.)
Single Receive per channel: the consume-once model means two
Agent Receivenodes on the same channel compete for pushes. Use distinct channel names.
wait_secondsblocks a ComfyUI execution worker for its whole duration. Outside interactive use, keep it modest (seconds, not hours) so you don't tie up a worker waiting on an agent.
Connecting an agent
The bridge speaks MCP over streamable HTTP at http://127.0.0.1:9188/mcp.
Codex (plugin — recommended)
This repo ships as a Codex plugin. Point Codex at the repo as a marketplace,
then install the plugin; Codex auto-registers the comfy MCP server (HTTP, no
auth) and the comfyui-bridge skill. Verified on Codex CLI 0.142.3:
# from GitHub:
codex plugin marketplace add ethanfel/ComfyUI-Agent-Bridge
# ...or from a local clone:
codex plugin marketplace add /path/to/ComfyUI-Agent-Bridge
codex plugin add comfyui-agents@comfyui-agentsConfirm registration:
codex mcp get comfy
# transport: streamable_http
# url: http://127.0.0.1:9188/mcpThe plugin only declares the HTTP server URL, so ComfyUI (and the bridge) must be running for the tools to connect.
Codex (single MCP server, no plugin)
If you'd rather not install the plugin, add just the MCP server:
codex mcp add comfy --url http://127.0.0.1:9188/mcpThis writes a streamable-HTTP entry equivalent to:
[mcp_servers.comfy]
url = "http://127.0.0.1:9188/mcp"Codex (stdio only): if your Codex build can only speak stdio MCP, point it
at scripts/codex_stdio_shim.py — a real stdio<->HTTP MCP proxy that connects
to the same bridge URL and forwards tool calls. Equivalent to
codex mcp add comfy --env COMFY_BRIDGE_URL=http://127.0.0.1:9188/mcp -- python /abs/path/scripts/codex_stdio_shim.py:
[mcp_servers.comfy]
command = "python"
args = ["/abs/path/ComfyUI-Nodes-Agents/scripts/codex_stdio_shim.py"]
env = { COMFY_BRIDGE_URL = "http://127.0.0.1:9188/mcp" }The shim requires ComfyUI (and the bridge) to be running; if it can't reach the HTTP bridge it exits non-zero with a clear stderr message so Codex surfaces the error. Use an absolute path to the shim.
Claude Code (HTTP)
claude mcp add --transport http comfy http://127.0.0.1:9188/mcpThen in Claude Code, /mcp should list the five tools.
Running ComfyUI in Docker / on another host
The bridge binds 127.0.0.1 by default, reachable only from the same host (inside
the container). To reach it from an agent on another machine:
Bind all interfaces — set
COMFY_BRIDGE_MCP_HOST=0.0.0.0in the container.Publish the port —
-p 9188:9188(orports: ["9188:9188"]in compose).Point the agent at the server IP, not localhost:
claude mcp add --transport http comfy http://192.168.1.12:9188/mcp codex mcp add comfy --url http://192.168.1.12:9188/mcpFor the Codex plugin, edit
.codex-plugin/mcp.json'surlto the server IP (or just usecodex mcp addabove).
COMFY_BASE_URL stays http://127.0.0.1:8188 — the bridge runs inside the
ComfyUI container and reaches ComfyUI over the container's own localhost.
Images across hosts. Images cross by file path. By default the bridge
writes them into ComfyUI's output directory (output/agent_bridge/), which in
a typical setup is a shared mount visible at the same path to both ComfyUI and
the agent — so paths resolve on both sides with no configuration.
If your container mounts that folder at a different internal path than the agent sees, set both:
COMFY_BRIDGE_TMP— dir the bridge writes, container-side (e.g./ComfyUI/output/agent_bridge)COMFY_BRIDGE_TMP_PUBLIC— the path the agent sees for it (e.g./media/unraid/comfyui/output/agent_bridge)
comfy_pull then advertises the agent-visible path and comfy_push translates it
back to the container path before Agent Receive loads it. Text needs none of
this — it's inline.
Security: binding
0.0.0.0exposes the bridge — includingcomfy_run_workflow(runs saved workflows) and file-path reads — to your LAN with no authentication. Keep it on a trusted network or firewall the port.
MCP tools
Tool | Direction | Purpose |
| graph -> agent | Read the latest text/image emitted on a channel (returns |
| agent -> graph | Send text/image to the channel's |
| — | List active channels and their turn counters. |
| — | Load a saved workflow from |
| — | Fetch produced images/outputs for a queued prompt id. |
comfy_run_workflow reads workflows/<name>.json (API-format export). inputs
overrides node fields keyed as "<node_id>.<field>", e.g.
{"6.text": "a red fox"}. With wait=True it polls the ComfyUI /history
endpoint (bounded ~60s) until outputs appear.
The core loop
Graph:
Load Image -> Agent Emit (channel=in). Queue the prompt.Agent:
comfy_pull("in")-> get the image path; inspect/edit it.Agent:
comfy_push("out", text="...", image_path="<edited>.png").Graph:
Agent Receive (channel=out, wait_seconds=30) -> Preview/Save. Queue; the text + image arrive.
For a full render round-trip: save an API-format workflow to
workflows/txt2img.json with an Agent Receive(channel=prompt) feeding the
prompt and an Agent Emit(channel=render) on the output, then from the agent:
comfy_push("prompt", "a red fox") -> comfy_run_workflow("txt2img", wait=true)
-> comfy_pull("render").
Environment variables
Variable | Default | Effect |
|
| Interface the MCP bridge binds. Set |
|
| Port the MCP bridge binds (use |
| ComfyUI | Dir where |
| (unset) | If the container mounts the temp dir at a different path than the agent sees, the prefix the agent should see. |
|
| Age (seconds) after which |
|
| Dir that |
|
| ComfyUI HTTP API base URL used by |
Development
COMFY_BRIDGE_MCP_PORT=0 python -m pytest tests/ -vCOMFY_BRIDGE_MCP_PORT=0 makes the entrypoint import (which autostarts the
bridge) bind an ephemeral port instead of the fixed 9188. The test suite
includes a real MCP round-trip (tests/bridge/test_mcp_roundtrip.py) that boots
the streamable-HTTP server on a free port and drives it with a real MCP client.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ethanfel/ComfyUI-Agent-Bridge'
If you have feedback or need assistance with the MCP directory API, please join our Discord server