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:latest
But 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:latest
This would require changes across the stack:
- CLI: Add
--publish flag (string slice) to run_flags.go
- RunConfig: Add
AdditionalPorts field (or similar) to config.go
- Setup: Thread additional ports into
DeployWorkloadOptions.ExposedPorts and PortBindings in setup.go
The Docker/Podman container creation layer already handles multiple ports correctly — no changes needed there.
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 runonly 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:
But there is no equivalent in
thv run— the--publishflag does not exist and is silently ignored.Root Cause
The container runtime layer (
DeployWorkloadOptions) already supports multiple port mappings via itsExposedPortsandPortBindingsmaps. However, no layer above it populates more than one port:cmd/thv/app/run_flags.go--proxy-portand--target-portpkg/runner/config.goPortandTargetPortfieldspkg/runtime/setup.go:72-94targetPortto exposed/bindingspkg/container/runtime/types.gopkg/container/docker/client.goAdditionally,
HostConfig.PublishAllPortsis never set totrue, so even ports declared withEXPOSEin the Dockerfile are not automatically published to the host.Proposed Solution
Add a
--publish/-pflag tothv run(matching Docker/Podman convention) that acceptshostPort:containerPortmappings:This would require changes across the stack:
--publishflag (string slice) torun_flags.goAdditionalPortsfield (or similar) toconfig.goDeployWorkloadOptions.ExposedPortsandPortBindingsinsetup.goThe Docker/Podman container creation layer already handles multiple ports correctly — no changes needed there.