diff --git a/packages/browseros-agent/apps/cli/cmd/init.go b/packages/browseros-agent/apps/cli/cmd/init.go index c38793c08..b1fc0047b 100644 --- a/packages/browseros-agent/apps/cli/cmd/init.go +++ b/packages/browseros-agent/apps/cli/cmd/init.go @@ -25,13 +25,17 @@ func init() { Long: `Set up the CLI by providing the MCP server URL from BrowserOS. Open BrowserOS → Settings → BrowserOS MCP to find your Server URL. -The URL looks like: http://127.0.0.1:9004/mcp +The URL looks like: http://127.0.0.1:9000/mcp The port varies per installation, so this step is required on first use. Run again if your port changes. +You can provide the full URL or just the port number: + browseros-cli init http://127.0.0.1:9000/mcp + browseros-cli init 9000 + Three modes: - browseros-cli init Non-interactive, use the provided URL + browseros-cli init Non-interactive (full URL or port number) browseros-cli init --auto Auto-discover from ~/.browseros/server.json browseros-cli init Interactive prompt`, Annotations: map[string]string{"group": "Setup:"}, @@ -65,13 +69,14 @@ Three modes: bold.Println("BrowserOS CLI Setup") fmt.Println() fmt.Println("Open BrowserOS → Settings → BrowserOS MCP") - fmt.Println("Copy the Server URL shown there.") + fmt.Println("Copy the Server URL or port number shown there.") fmt.Println() - dim.Println("It looks like: http://127.0.0.1:9004/mcp") + dim.Println("Examples: http://127.0.0.1:9000/mcp") + dim.Println(" 9000") fmt.Println() reader := bufio.NewReader(os.Stdin) - fmt.Print("Server URL: ") + fmt.Print("Server URL or port: ") line, err := reader.ReadString('\n') if err != nil { output.Error("failed to read input", 1) diff --git a/packages/browseros-agent/apps/cli/cmd/root.go b/packages/browseros-agent/apps/cli/cmd/root.go index 5ce906e0b..cb8507fe7 100644 --- a/packages/browseros-agent/apps/cli/cmd/root.go +++ b/packages/browseros-agent/apps/cli/cmd/root.go @@ -338,10 +338,27 @@ func loadBrowserosServerURL() string { func normalizeServerURL(raw string) string { normalized := strings.TrimSpace(raw) + + if isPortOnly(normalized) { + normalized = "http://127.0.0.1:" + normalized + } + normalized = strings.TrimSuffix(normalized, "/mcp") return strings.TrimSuffix(normalized, "/") } +func isPortOnly(s string) bool { + if s == "" { + return false + } + for _, c := range s { + if c < '0' || c > '9' { + return false + } + } + return true +} + func validateServerURL(raw string) (string, error) { baseURL := normalizeServerURL(raw) if baseURL != "" {