grok-browser-mcp
# grok-browser-mcp
MCP server that attaches to **your already-running Brave** over [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/) (CDP). Grok CLI can then snapshot, click, type, and screenshot whatever tab you have open — same window, same logins.
It does **not** launch a fresh empty browser.
## Requirements
- Linux (Brave flags file `~/.config/brave-flags.conf`)
- [Brave](https://brave.com/)
- Node.js 18+
- [Grok CLI](https://github.com/xai-org)
## Install
```bash
git clone https://github.com/v76ADrR/grok-browser-mcp.git
cd grok-browser-mcp
npm install
```
## Enable CDP on Brave (once)
The Arch/CachyOS Brave wrapper reads `~/.config/brave-flags.conf`. Put:
```
--remote-debugging-port=9222
--remote-debugging-address=127.0.0.1
--remote-allow-origins=*
```
Restart Brave. Tabs usually restore. Confirm:
```bash
curl -s http://127.0.0.1:9222/json/version
```
Or call the MCP tool `browser_prepare` (this **restarts** Brave).
CDP is **localhost only**. Any process on this machine can control the browser while those flags are set. Remove them and restart Brave when you are done.
## Grok CLI config
`~/.grok/config.toml`:
```toml
[mcp_servers.browser]
command = "/usr/bin/node"
args = ["/ABS/PATH/TO/grok-browser-mcp/src/server.mjs"]
enabled = true
startup_timeout_sec = 20
tool_timeout_sec = 180
```
Reload: `/mcps` then `r`, or a new Grok session.
## Tools
| Tool | Purpose |
| --- | --- |
| `browser_status` | Brave PIDs + CDP health |
| `browser_prepare` | Write flags; restart Brave if CDP is down |
| `browser_tabs` | List / focus tabs |
| `browser_snapshot` | Clickable elements + refs |
| `browser_find` | Filter snapshot by text |
| `browser_click` | Click by ref / selector / text |
| `browser_type` / `browser_press` | Keyboard |
| `browser_evaluate` | JS in the page |
| `browser_screenshot` | JPEG of the current tab |
| `browser_navigate` / `browser_scroll` / `browser_wait` | Navigation |
Never call Playwright `browser.close()` on this connection — it would quit the user's Brave.
## License
MIT
TDQS
Scored across 14 tools
Most tools have clearly distinct actions and targets, but browser_snapshot and browser_find overlap because both return clickable-element refs, and browser_status/browser_prepare both concern Brave/CDP availability. The descriptions help mitigate this, so boundaries are mostly clear.
All tools use the browser_ prefix followed by snake_case verbs or nouns, giving a highly predictable and readable pattern. browser_desktop_screenshot is slightly longer but still consistent with the schema.
With 14 tools, the set sits comfortably in the expected range for a browser automation server. Each tool maps to a recognizable action or control, and the count does not feel bloated or thin.
The surface covers navigation, input, scrolling, waiting, JavaScript evaluation, snapshots, screenshots, tab listing/focusing, and CDP setup. Minor gaps exist around explicit new/close tab, back/forward/reload, and file upload or select-option handling, but browser_evaluate and browser_navigate can often work around them.