server: Parse port numbers from MCP server URLs in CORS proxy (#20208)

* Parse port numbers from MCP server URLs

* Pass scheme to http proxy for determining whether to use SSL

* Fix download on non-standard port and re-add port to logging

* add test

---------

Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
This commit is contained in:
Evan Huus
2026-03-09 12:47:54 -04:00
committed by GitHub
parent e22cd0aa15
commit 23fbfcb1ad
6 changed files with 67 additions and 4 deletions
+3
View File
@@ -102,6 +102,7 @@ class ServerProcess:
mmproj_url: str | None = None
media_path: str | None = None
sleep_idle_seconds: int | None = None
webui_mcp_proxy: bool = False
# session variables
process: subprocess.Popen | None = None
@@ -236,6 +237,8 @@ class ServerProcess:
server_args.extend(["--media-path", self.media_path])
if self.sleep_idle_seconds is not None:
server_args.extend(["--sleep-idle-seconds", self.sleep_idle_seconds])
if self.webui_mcp_proxy:
server_args.append("--webui-mcp-proxy")
args = [str(arg) for arg in [server_path, *server_args]]
print(f"tests: starting server with: {' '.join(args)}")