# How to Start the xiaohongshu-mcp Server with Command-Line Arguments

> Start the xiaohongshu-mcp server using command-line arguments. Control browser visibility headless mode executable path and HTTP port for flexible setup.

- Repository: [zy/xiaohongshu-mcp](https://github.com/xpzouying/xiaohongshu-mcp)
- Tags: how-to-guide
- Published: 2026-03-09

---

**Run the `./xiaohongshu-mcp` binary with the `-headless`, `-bin`, and `-port` flags to control browser visibility, executable path, and HTTP server address.**

The `xpzouying/xiaohongshu-mcp` repository provides a Model Context Protocol (MCP) server for automating Xiaohongshu (Little Red Book) interactions. When you start the xiaohongshu-mcp server with command-line arguments, you can customize browser automation settings and network bindings without modifying the source code.

## Available Command-Line Flags

The entry point in [`main.go`](https://github.com/xpzouying/xiaohongshu-mcp/blob/main/main.go) defines three primary flags that configure the server's behavior:

| Flag | Type | Default | Description |
|------|------|---------|-------------|
| `-headless` | `bool` | `true` | Run Chromium in headless mode. Set to `false` to see the browser UI. |
| `-bin` | `string` | `""` | Absolute path to a custom Chrome/Chromium binary. |
| `-port` | `string` | `:18060` | TCP address for the HTTP server (e.g., `:8080` or `127.0.0.1:9090`). |

## Starting with Default Configuration

To launch the server with default settings—headless browser, automatic binary detection, and port `:18060`—run the compiled binary:

```bash
./xiaohongshu-mcp

```

The server initializes the global configuration via `configs.InitHeadless(true)` and `configs.SetBinPath("")` in [`configs/browser.go`](https://github.com/xpzouying/xiaohongshu-mcp/blob/main/configs/browser.go), then starts the HTTP listener via `appServer.Start(":18060")` defined in [`app_server.go`](https://github.com/xpzouying/xiaohongshu-mcp/blob/main/app_server.go).

## Running with a Visible Browser Window

For debugging or initial authentication flows, disable headless mode to watch the browser interactions:

```bash
./xiaohongshu-mcp -headless=false

```

This invokes `configs.InitHeadless(false)`, which stores the flag in the global state accessed by the browser wrapper when creating new Rod sessions.

## Specifying a Custom Chrome Binary

If your Chrome installation is in a non-standard location, use the `-bin` flag or the `ROD_BROWSER_BIN` environment variable:

```bash

# Using the flag

./xiaohongshu-mcp -bin=/usr/local/bin/chrome -port=:8080

# Using environment variable fallback

export ROD_BROWSER_BIN=/opt/google/chrome/chrome
./xiaohongshu-mcp

```

The [`main.go`](https://github.com/xpzouying/xiaohongshu-mcp/blob/main/main.go) logic checks the `-bin` value first; if empty, it falls back to `ROD_BROWSER_BIN` before allowing Rod to auto-detect the browser.

## Changing the HTTP Server Port

To bind the MCP server to a different interface or port, modify the `-port` argument:

```bash
./xiaohongshu-mcp -port=127.0.0.1:9090

```

This value is passed directly to `appServer.Start(port)` in [`app_server.go`](https://github.com/xpzouying/xiaohongshu-mcp/blob/main/app_server.go), which configures the underlying HTTP server listener.

## Implementation Details

The command-line parsing logic resides in [`main.go`](https://github.com/xpzouying/xiaohongshu-mcp/blob/main/main.go), where the `flag` package parses user input. The parsed values propagate through the codebase as follows:

- **Headless mode**: Stored via `configs.InitHeadless()` in [`configs/browser.go`](https://github.com/xpzouying/xiaohongshu-mcp/blob/main/configs/browser.go), affecting how the Rod browser driver initializes sessions.
- **Binary path**: Set via `configs.SetBinPath()` in the same file, used when constructing the browser launcher.
- **Port binding**: Passed to `appServer.Start()` in [`app_server.go`](https://github.com/xpzouying/xiaohongshu-mcp/blob/main/app_server.go), which manages the HTTP server lifecycle and graceful shutdown on SIGINT/SIGTERM.

## Summary

- Use `./xiaohongshu-mcp` with `-headless=false` to debug browser automation visually.
- Specify custom Chrome binaries via `-bin=/path/to/chrome` or the `ROD_BROWSER_BIN` environment variable.
- Change the listening address with `-port=:PORT` (default is `:18060`).
- Configuration flows from [`main.go`](https://github.com/xpzouying/xiaohongshu-mcp/blob/main/main.go) flag parsing to [`configs/browser.go`](https://github.com/xpzouying/xiaohongshu-mcp/blob/main/configs/browser.go) for browser settings and [`app_server.go`](https://github.com/xpzouying/xiaohongshu-mcp/blob/main/app_server.go) for HTTP server startup.

## Frequently Asked Questions

### What is the default port for xiaohongshu-mcp?

The default TCP address is `:18060`, binding to all interfaces on port 18060. You can override this with the `-port` flag (e.g., `-port=127.0.0.1:8080`).

### How do I run xiaohongshu-mcp without headless mode?

Pass `-headless=false` when starting the binary: `./xiaohongshu-mcp -headless=false`. This launches a visible Chrome window, which is useful for debugging authentication flows or scraping issues.

### Can I use an environment variable instead of the `-bin` flag?

Yes. If the `-bin` flag is omitted, the server checks the `ROD_BROWSER_BIN` environment variable. If set, that path is used as the Chrome/Chromium binary location.

### Where does the server handle command-line argument parsing?

Flag parsing occurs in [`main.go`](https://github.com/xpzouying/xiaohongshu-mcp/blob/main/main.go) at the repository root. The parsed values are then propagated to [`configs/browser.go`](https://github.com/xpzouying/xiaohongshu-mcp/blob/main/configs/browser.go) for browser configuration and [`app_server.go`](https://github.com/xpzouying/xiaohongshu-mcp/blob/main/app_server.go) for HTTP server initialization.