Repository navigation
How connect to local installation via API or MCP via port? #17646
|
i want use local API or MCP via port but you don't documented it. |
Replies: 3 comments
|
ComfyUI has an HTTP API, not MCP. It listens only on python main.py --listen --port 8188Then call |
|
ComfyUI has a full HTTP + WebSocket API; it just is not in the README. Everything is registered in The endpoints that matter for an agent
The flowimport json, urllib.request, uuid
client_id = str(uuid.uuid4())
payload = {"prompt": workflow_json, "client_id": client_id}
req = urllib.request.Request(
f"http://{host}:{port}/prompt",
data=json.dumps(payload).encode(),
headers={"Content-Type": "application/json"},
)
prompt_id = json.load(urllib.request.urlopen(req))["prompt_id"]
# poll
with urllib.request.urlopen(f"http://{host}:{port}/history/{prompt_id}") as r:
history = json.load(r)
self.client_id = None
...
if self.client_id == sid and self.last_node_id is not None:Without a matching Container-to-container networkingThis is almost certainly the actual blocker, not the API. If Hermes runs in a sibling container:
Quick check from inside Hermes: curl -s http://comfyui:8188/system_statsIf that returns JSON, the network is right and any remaining problem is in the payload. If it hangs, it is a bind/network issue — try About MCPComfyUI itself does not ship an MCP server. The community MCP wrappers in the wild drive the same HTTP API above. If you want Hermes to call ComfyUI "via MCP", what you actually need is either:
The second is less machinery for the same result, and it removes a hop that can fail. One gotcha
|
|
Thanks for all! |
ComfyUI has a full HTTP + WebSocket API; it just is not in the README. Everything is registered in
server.pyonPromptServer, so you can read the exact routes out of the source.The endpoints that matter for an agent
POST/promptprompt_idGET/history/{prompt_id}GET/api/jobs/{job_id}/api/jobslists them)GET/view?filename=...&subfolder=...&type=outputPOST/upload/imageGET/object_infoWS/ws?clientId=<id>/object_infois the one that makes an agent usable against a workfl…