- Rust 69.5%
- Shell 20.2%
- JavaScript 4.5%
- HTML 3.1%
- Makefile 1.8%
- Other 0.9%
- Bind TCP listener on 127.0.0.1:8884 (configurable via HERO_BROWSER_MCP_PORT) - Standardize socket path to $HERO_SOCKET_DIR/hero_browser/rpc.sock - Add OAuth server endpoint returning proper 404 JSON response - Update MCP registration to use HTTP URL instead of Unix socket - Add CLAUDE.md with critical architecture and deployment notes Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| .forgejo/workflows | ||
| crates | ||
| docs | ||
| examples/rhai | ||
| scripts | ||
| .gitignore | ||
| buildenv.sh | ||
| Cargo.toml | ||
| CLAUDE.md | ||
| Makefile | ||
| README.md | ||
Hero Browser
Headless browser automation with MCP protocol support and Rhai scripting.
Architecture
Multi-crate workspace following Hero OS best practices:
hero_browser_mcp/
├── Cargo.toml (workspace root)
├── Makefile (orchestration)
├── crates/
│ ├── hero_browser_sdk/ (lib: types, browser pool, activity log)
│ ├── hero_browser_server/ (bin: MCP daemon, REST API, Unix socket)
│ ├── hero_browser/ (bin: CLI client, health check, script runner)
│ ├── hero_browser_ui/ (bin: Axum HTTP admin dashboard)
│ └── hero_browser_rhai/ (lib: Rhai scripting bindings)
Dependency Graph
hero_browser_sdk (no internal deps)
↑ ↑ ↑ ↑
| | | |
server CLI UI rhai
Sockets & Ports
| Component | Socket | TCP Port |
|---|---|---|
| Server (MCP) | $HERO_SOCKET_DIR/hero_browser_server/rpc.sock |
8884 (env: HERO_BROWSER_MCP_PORT) |
| Admin UI | $HERO_SOCKET_DIR/hero_browser_ui/ui.sock |
— |
HERO_SOCKET_DIR defaults to ~/hero/var/sockets.
Important: The MCP server listens on both the Unix socket and TCP port 8884. The TCP port is required for Claude Code MCP integration (claude mcp add --transport http hero_browser http://localhost:8884/mcp). Do not remove the TCP listener.
Features
- MCP Server: Control browsers via Model Context Protocol (HTTP transport)
- Rhai Scripting: Write automation scripts with a simple scripting language
- Shebang Support: Run scripts directly with
#!/usr/bin/env hero_browser - Visible Mode: Debug scripts by watching the browser in action with
--showflag - Admin Dashboard: Monitor sessions and activity in real-time
Quick Start
# Build all binaries
make build
# Run server + health check + UI (full orchestration)
make run
# Run only the MCP server (port 8884)
make run-server
# Run with visible browser windows
make run-server-show
# Run only the admin UI (port 8885)
make run-ui
# Health check
hero_browser health
Installation
Build from Source
git clone https://forge.ourworld.tf/lhumina_code/hero_browser
cd hero_browser
make build
make install # installs to ~/hero/bin/
Requirements
- Google Chrome (macOS) or Chromium (Linux)
- Rust 1.92+
MCP Server
The hero_browser_server binary provides a Model Context Protocol server for Claude Code integration.
# Start MCP server (auto-configures with Claude Code)
hero_browser_server --port 8884
# With visible browsers
hero_browser_server --show --port 8884
API endpoints:
POST /mcp- MCP protocol endpoint (streamable HTTP)GET /api/sessions- List active browser sessionsGET /api/activity- Recent MCP activity logGET /api/activity/{browser_id}- Session-specific activity
Claude Code Configuration
The server auto-configures on startup. Manual setup (or to re-register after a restart):
claude mcp remove hero_browser
claude mcp add --scope user --transport http hero_browser http://localhost:8884/mcp
Admin Dashboard
The hero_browser_ui binary provides a web dashboard for monitoring.
hero_browser_ui --port 8885 --server-url http://localhost:8884
Open http://localhost:8885/ to see live sessions, activity logs, and stats.
CLI
The hero_browser binary provides a CLI for scripts and health checks.
# Run a Rhai script
hero_browser script.rhai
# Run with visible browser
hero_browser --show script.rhai
# Check server health
hero_browser health
Available Functions
Browser Lifecycle
browser_create()- Create new browser, returns browser_idbrowser_create_with_options(opts)- Create with optionsbrowser_destroy(browser_id)- Close browserbrowser_list()- List active browser IDs
Page Operations
page_create(browser_id)- Create new pagepage_navigate(browser_id, page_id, url)- Navigate to URLpage_navigate_back/forward(browser_id, page_id)- History navigationpage_url/content/title(browser_id, page_id)- Get page infopage_screenshot(browser_id, page_id)- Take screenshot (base64)page_screenshot_save(browser_id, page_id, path)- Save screenshotpage_close(browser_id, page_id)- Close page
Element Interaction
element_click(browser_id, page_id, selector)- Click elementelement_type(browser_id, page_id, selector, text)- Type textelement_hover(browser_id, page_id, selector)- Hoverelement_wait(browser_id, page_id, selector, timeout_ms)- Wait for elementelement_drag_drop(browser_id, page_id, source, target)- Drag and drop
JavaScript, Cookies, Network, Accessibility
js_execute(browser_id, page_id, script)- Execute JavaScriptcookies_get/set/delete(...)- Cookie managementnetwork_install/requests/clear(...)- Network monitoringaccessibility_tree/snapshot(...)- Accessibility infoconsole_install/messages/clear(...)- Console captureviewport_set/set_mobile(...)- Viewport controlkey_press(browser_id, page_id, key)- Keyboard inputdialog_accept/dismiss(...)- Dialog handling
Documentation
- Architecture - System design
- API Reference - Full API documentation
- Scripting Guide - Writing automation scripts
- MCP Quick Start - 5-minute setup
- MCP Integration Guide - Complete reference
License
Apache-2.0