hero_browser_server: --help/--version flags ignored, server starts anyway #21

Closed
opened 2026-05-06 14:17:24 +00:00 by mik-tf · 0 comments
Owner

Summary

hero_browser_server --help (and --version, -h, -V) does not print help and exit. Instead, the server starts up and binds its socket/port. Any tool that probes a binary with --help to discover its CLI surface will accidentally launch a daemon.

Reproduction

On a host where 8884 is free, run:

$ /home/pctwo/hero/bin/hero_browser_server --help
MCP server already configured

Hero Browser MCP Server
=======================
Socket:  /home/pctwo/hero/var/sockets/hero_browser/rpc.sock
TCP:     localhost:8884
...
Ready for connections...

The process keeps running and listens on the configured TCP port and Unix socket. Same for --version, -h, -V, or any other flag.

Root cause

crates/hero_browser_server/src/main.rs:312-318 does no argument parsing — main() just constructs the runtime and calls run_server(false) directly:

fn main() {
    let rt = tokio::runtime::Runtime::new().expect("Failed to create tokio runtime");
    if let Err(e) = rt.block_on(run_server(false)) {
        eprintln!("Server error: {}", e);
        std::process::exit(1);
    }
}

Expected behavior

  • --help / -h → print usage and exit 0.
  • --version / -V → print hero_browser_server <version> and exit 0.
  • Unknown flags → print error referencing --help, exit 2.
  • Bare invocation (no args) → start server (current default).

Proposed fix

Minimal hand-rolled arg matcher in main() (no new deps). The binary is intentionally minimal per its module-level doc comment, so a full clap derive is overkill. ~25 lines.

Will open a PR shortly.

## Summary `hero_browser_server --help` (and `--version`, `-h`, `-V`) does not print help and exit. Instead, the server starts up and binds its socket/port. Any tool that probes a binary with `--help` to discover its CLI surface will accidentally launch a daemon. ## Reproduction On a host where 8884 is free, run: ``` $ /home/pctwo/hero/bin/hero_browser_server --help MCP server already configured Hero Browser MCP Server ======================= Socket: /home/pctwo/hero/var/sockets/hero_browser/rpc.sock TCP: localhost:8884 ... Ready for connections... ``` The process keeps running and listens on the configured TCP port and Unix socket. Same for `--version`, `-h`, `-V`, or any other flag. ## Root cause `crates/hero_browser_server/src/main.rs:312-318` does no argument parsing — `main()` just constructs the runtime and calls `run_server(false)` directly: ```rust fn main() { let rt = tokio::runtime::Runtime::new().expect("Failed to create tokio runtime"); if let Err(e) = rt.block_on(run_server(false)) { eprintln!("Server error: {}", e); std::process::exit(1); } } ``` ## Expected behavior - `--help` / `-h` → print usage and exit 0. - `--version` / `-V` → print `hero_browser_server <version>` and exit 0. - Unknown flags → print error referencing `--help`, exit 2. - Bare invocation (no args) → start server (current default). ## Proposed fix Minimal hand-rolled arg matcher in `main()` (no new deps). The binary is intentionally minimal per its module-level doc comment, so a full `clap` derive is overkill. ~25 lines. Will open a PR shortly.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_browser#21
No description provided.