Skip to content

Commit 4a55afb

Browse files
authored
Use proxy-port instead of port in the CLI (#1022)
I find that having `port` and `target-port` flags is confusing, because it's not clear what exactly the `port` flag is for. Add a `proxy-port` flag, but leave `port` around for backwards compatibility. This is a cosmetic CLI-only change - it does not change the structure of the run configs which are stored to disk, or the API for the UI.
1 parent 0983d0f commit 4a55afb

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

cmd/thv/app/run.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ var (
6262
runName string
6363
runHost string
6464
runPort int
65+
runProxyPort int
6566
runTargetPort int
6667
runTargetHost string
6768
runPermissionProfile string
@@ -94,7 +95,11 @@ func init() {
9495
runCmd.Flags().StringVar(&runProxyMode, "proxy-mode", "sse", "Proxy mode for stdio transport (sse or streamable-http)")
9596
runCmd.Flags().StringVar(&runName, "name", "", "Name of the MCP server (auto-generated from image if not provided)")
9697
runCmd.Flags().StringVar(&runHost, "host", transport.LocalhostIPv4, "Host for the HTTP proxy to listen on (IP or hostname)")
98+
runCmd.Flags().IntVar(&runProxyPort, "proxy-port", 0, "Port for the HTTP proxy to listen on (host port)")
9799
runCmd.Flags().IntVar(&runPort, "port", 0, "Port for the HTTP proxy to listen on (host port)")
100+
if err := runCmd.Flags().MarkDeprecated("port", "use --proxy-port instead"); err != nil {
101+
logger.Warnf("Error marking port flag as deprecated: %v", err)
102+
}
98103
runCmd.Flags().IntVar(&runTargetPort, "target-port", 0,
99104
"Port for the container to expose (only applicable to SSE or Streamable HTTP transport)")
100105
runCmd.Flags().StringVar(
@@ -311,6 +316,12 @@ func runCmdFunc(cmd *cobra.Command, args []string) error {
311316
}
312317
}
313318

319+
// Determine effective port value - prefer --proxy-port over --port for backwards compatibility
320+
effectivePort := runProxyPort
321+
if effectivePort == 0 && runPort != 0 {
322+
effectivePort = runPort
323+
}
324+
314325
// Initialize a new RunConfig with values from command-line flags
315326
// TODO: As noted elsewhere, we should use the builder pattern here to make it more readable.
316327
runConfig, err := runner.NewRunConfigFromFlags(
@@ -330,7 +341,7 @@ func runCmdFunc(cmd *cobra.Command, args []string) error {
330341
runPermissionProfile,
331342
runTargetHost,
332343
runTransport,
333-
runPort,
344+
effectivePort,
334345
runTargetPort,
335346
runEnv,
336347
oidcIssuer,

docs/cli/thv_run.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)