comfyui-mcp
Version:
Local-first, agent-native control plane for ComfyUI — MCP server + autonomous sidebar agent that drives your live graph in natural language on ANY LLM: Claude/ChatGPT/Gemini on your subscription (no API key), free local models via Ollama (fully offline),
24 lines • 1.05 kB
JavaScript
/**
* Trim a URL pathname into a base prefix: no trailing slash, and "" for the
* root ("" or "/"). "/comfyapi/" → "/comfyapi".
*/
function normalizeBasePath(pathname) {
const trimmed = pathname.replace(/\/+$/, "");
return trimmed === "" || trimmed === "/" ? "" : trimmed;
}
/**
* Parse a full ComfyUI URL (e.g. http://127.0.0.1:8188, https://comfy.example.com,
* https://host/comfyapi) into host/port/ssl/basePath. Used by --comfyui-url /
* COMFYUI_URL to target any (incl. remote, reverse-proxied) ComfyUI instance,
* overriding the COMFYUI_HOST/PORT/SSL env vars.
*/
export function parseComfyUIUrl(url) {
const u = new URL(url);
if (u.protocol !== "http:" && u.protocol !== "https:") {
throw new Error(`Unsupported protocol "${u.protocol}" in --comfyui-url (expected http or https)`);
}
const ssl = u.protocol === "https:";
const port = u.port ? Number(u.port) : ssl ? 443 : 80;
return { host: u.hostname, port, ssl, basePath: normalizeBasePath(u.pathname) };
}
//# sourceMappingURL=comfyui-url.js.map