How to Start the xiaohongshu-mcp Server with Command-Line Arguments
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 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:
./xiaohongshu-mcp
The server initializes the global configuration via configs.InitHeadless(true) and configs.SetBinPath("") in configs/browser.go, then starts the HTTP listener via appServer.Start(":18060") defined in app_server.go.
Running with a Visible Browser Window
For debugging or initial authentication flows, disable headless mode to watch the browser interactions:
./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:
# 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 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:
./xiaohongshu-mcp -port=127.0.0.1:9090
This value is passed directly to appServer.Start(port) in app_server.go, which configures the underlying HTTP server listener.
Implementation Details
The command-line parsing logic resides in main.go, where the flag package parses user input. The parsed values propagate through the codebase as follows:
- Headless mode: Stored via
configs.InitHeadless()inconfigs/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()inapp_server.go, which manages the HTTP server lifecycle and graceful shutdown on SIGINT/SIGTERM.
Summary
- Use
./xiaohongshu-mcpwith-headless=falseto debug browser automation visually. - Specify custom Chrome binaries via
-bin=/path/to/chromeor theROD_BROWSER_BINenvironment variable. - Change the listening address with
-port=:PORT(default is:18060). - Configuration flows from
main.goflag parsing toconfigs/browser.gofor browser settings andapp_server.gofor 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 at the repository root. The parsed values are then propagated to configs/browser.go for browser configuration and app_server.go for HTTP server initialization.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →