diff --git a/.agents/plugins/marketplace.json b/.agents/plugins/marketplace.json new file mode 100644 index 0000000..fb49922 --- /dev/null +++ b/.agents/plugins/marketplace.json @@ -0,0 +1,20 @@ +{ + "name": "comfyui-agents", + "interface": { + "displayName": "ComfyUI Agents" + }, + "plugins": [ + { + "name": "comfyui-agents", + "source": { + "source": "local", + "path": "." + }, + "policy": { + "installation": "AVAILABLE", + "authentication": "ON_USE" + }, + "category": "Developer Tools" + } + ] +} diff --git a/.codex-plugin/mcp.json b/.codex-plugin/mcp.json new file mode 100644 index 0000000..b18f814 --- /dev/null +++ b/.codex-plugin/mcp.json @@ -0,0 +1,8 @@ +{ + "mcpServers": { + "comfy": { + "type": "http", + "url": "http://127.0.0.1:9188/mcp" + } + } +} diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json new file mode 100644 index 0000000..5e61db9 --- /dev/null +++ b/.codex-plugin/plugin.json @@ -0,0 +1,37 @@ +{ + "name": "comfyui-agents", + "version": "0.1.0", + "description": "Bridge an external coding agent (Codex) to a running ComfyUI graph: exchange text and images on named channels and trigger workflow runs over MCP.", + "author": { + "name": "Ethan Fel", + "email": "ethan.fel@ts-pc.fr" + }, + "homepage": "https://github.com/ethanfel/ComfyUI-Nodes-Agents", + "repository": "https://github.com/ethanfel/ComfyUI-Nodes-Agents", + "license": "MIT", + "keywords": [ + "comfyui", + "mcp", + "agent", + "image-generation", + "bridge" + ], + "skills": "./skills/", + "mcpServers": "./.codex-plugin/mcp.json", + "interface": { + "displayName": "ComfyUI Agent Bridge", + "shortDescription": "Exchange text/images with a running ComfyUI graph and trigger runs over MCP", + "longDescription": "Connects Codex to the ComfyUI-Nodes-Agents in-process MCP server (HTTP, 127.0.0.1:9188/mcp). Pull images/text the graph emitted, push text/images back into the graph, list channels, and run saved workflows from the agent.", + "developerName": "Ethan Fel", + "category": "Developer Tools", + "capabilities": [ + "Read", + "Write" + ], + "defaultPrompt": [ + "Pull the latest image from the ComfyUI graph and describe it.", + "Push a prompt to ComfyUI and run the txt2img workflow." + ], + "brandColor": "#1F6FEB" + } +} diff --git a/skills/comfyui-bridge/SKILL.md b/skills/comfyui-bridge/SKILL.md new file mode 100644 index 0000000..7888e8e --- /dev/null +++ b/skills/comfyui-bridge/SKILL.md @@ -0,0 +1,54 @@ +--- +name: comfyui-bridge +description: Use when exchanging text or images with a running ComfyUI graph or triggering a ComfyUI workflow run from the agent. Trigger terms - ComfyUI, comfy_pull, comfy_push, comfy_run_workflow, named channel, inbox, outbox, render a prompt, edit the graph's image. +license: MIT +--- + +# ComfyUI Agent Bridge + +Connects you to a running ComfyUI graph through the `comfy` MCP server +(HTTP at `http://127.0.0.1:9188/mcp`). You exchange text and images with the +graph on **named channels** and can trigger saved workflow runs. + +ComfyUI must be running with the `ComfyUI-Nodes-Agents` custom node installed, +or the tools below will fail to connect. + +## Named-channel model + +Each channel name (default `main`) has two directions: + +- **inbox** = graph -> agent: an `Agent Emit` node writes the latest text/image; + you read it with `comfy_pull`. +- **outbox** = agent -> graph: you write with `comfy_push`; an `Agent Receive` + node reads it. Each pushed value is **consumed once** (turn-based). + +Use distinct channel names for distinct streams (e.g. `in`, `out`, `prompt`, +`render`); two `Agent Receive` nodes on one channel compete for the same push. + +## The five tools + +- `comfy_pull(channel="main")` -> `{turn, text, image_path}`: read what the graph + emitted on a channel. +- `comfy_push(channel="main", text=None, image_path=None)`: send text/image to + the graph's `Agent Receive` node on a channel. +- `comfy_list_channels()`: list active channels and their turn counters. +- `comfy_run_workflow(name, inputs=None, wait=True)`: load `workflows/.json` + (API-format export), optionally inject `inputs` keyed `"."` + (e.g. `{"6.text": "a red fox"}`), queue it, and (with `wait=True`) poll until + outputs appear. +- `comfy_get_result(prompt_id)`: fetch produced images/outputs for a queued + prompt id. + +Images cross by file path: `comfy_pull` returns an `image_path` you can read; +pass a local PNG path to `comfy_push(image_path=...)`. + +## The core loop + +1. `comfy_push(channel, text=..., image_path=...)` — stage inputs for the graph. +2. `comfy_run_workflow(name, wait=True)` — trigger the run and wait for outputs. +3. `comfy_pull(channel)` — read the text/image the graph emitted back. + +Full render round-trip: with a workflow whose `Agent Receive(channel=prompt)` +feeds the prompt and whose output goes to `Agent Emit(channel=render)`: +`comfy_push("prompt", "a red fox")` -> `comfy_run_workflow("txt2img", wait=True)` +-> `comfy_pull("render")`.