-
Notifications
You must be signed in to change notification settings - Fork 198
Support publishing additional container ports in thv run #3812
Description
Problem
Some MCP server images expose multiple ports — for example, one port for the MCP transport and a secondary port for a frontend UI or metrics endpoint. Currently, thv run only exposes a single port (the MCP transport port via --target-port), with no mechanism to publish additional container ports to the host.
This was reported in #3721 (reply in thread), where a user attempted to expose a secondary frontend port alongside the MCP transport port. Working directly with Podman succeeds:
podman run -d -p 8002:8000 -p 8003:8001 ghcr.io/manykarim/rf-mcp:latestBut there is no equivalent in thv run — the --publish flag does not exist and is silently ignored.
Root Cause
The container runtime layer (DeployWorkloadOptions) already supports multiple port mappings via its ExposedPorts and PortBindings maps. However, no layer above it populates more than one port:
| Layer | File | Supports multiple ports? |
|---|---|---|
| CLI flags | cmd/thv/app/run_flags.go |
No — only --proxy-port and --target-port |
| RunConfig | pkg/runner/config.go |
No — only Port and TargetPort fields |
| Setup | pkg/runtime/setup.go:72-94 |
No — only adds targetPort to exposed/bindings |
| DeployWorkloadOptions | pkg/container/runtime/types.go |
Yes — maps ready for multiple entries |
| Docker/Podman client | pkg/container/docker/client.go |
Yes — correctly applies all ports from options |
Additionally, HostConfig.PublishAllPorts is never set to true, so even ports declared with EXPOSE in the Dockerfile are not automatically published to the host.
Proposed Solution
Add a --publish / -p flag to thv run (matching Docker/Podman convention) that accepts hostPort:containerPort mappings:
thv run --name my-mcp --transport streamable-http \
--target-port 8000 \
--publish 8003:8001 \
ghcr.io/manykarim/rf-mcp:latestThis would require changes across the stack:
- CLI: Add
--publishflag (string slice) torun_flags.go - RunConfig: Add
AdditionalPortsfield (or similar) toconfig.go - Setup: Thread additional ports into
DeployWorkloadOptions.ExposedPortsandPortBindingsinsetup.go
The Docker/Podman container creation layer already handles multiple ports correctly — no changes needed there.