brave-real-browser-mcp-server 2.0.3 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,20 +13,24 @@ Provides AI assistants with powerful, detection-resistant browser automation cap
13
13
  2. [Introduction](#introduction)
14
14
  3. [Features](#features)
15
15
  4. [Prerequisites](#prerequisites)
16
- 5. [Installation](#installation)
17
- 6. [Usage](#usage)
16
+ 5. [Platform-Specific Installation](#platform-specific-installation)
17
+ - [Windows Installation](#windows-installation)
18
+ - [macOS Installation](#macos-installation)
19
+ - [Linux Installation](#linux-installation)
20
+ 6. [Installation](#installation)
21
+ 7. [Usage](#usage)
18
22
  - [With Claude Desktop](#with-claude-desktop)
19
23
  - [With Claude Code CLI](#with-claude-code-cli)
20
24
  - [With Cursor IDE](#with-cursor-ide)
21
25
  - [With Other AI Assistants](#with-other-ai-assistants)
22
- 7. [Available Tools](#available-tools)
23
- 8. [Advanced Features](#advanced-features)
24
- 9. [Configuration](#configuration)
25
- 10. [Troubleshooting](#troubleshooting)
26
- 11. [Development](#development)
27
- 12. [Testing](#testing)
28
- 13. [Contributing](#contributing)
29
- 14. [License](#license)
26
+ 8. [Available Tools](#available-tools)
27
+ 9. [Advanced Features](#advanced-features)
28
+ 10. [Configuration](#configuration)
29
+ 11. [Troubleshooting](#troubleshooting)
30
+ 12. [Development](#development)
31
+ 13. [Testing](#testing)
32
+ 14. [Contributing](#contributing)
33
+ 15. [License](#license)
30
34
 
31
35
  ## Quick Start for Beginners
32
36
 
@@ -104,17 +108,22 @@ Once set up, you can ask Claude to:
104
108
  ## Introduction
105
109
 
106
110
  The Brave Real Browser MCP Server acts as a bridge between AI assistants
107
- and browser automation. It leverages brave-real-browser to provide stealth
108
- browsing capabilities that can bypass common bot detection mechanisms.
111
+ and browser automation. It leverages the **brave-real-browser** package to provide
112
+ advanced stealth browsing capabilities that can bypass common bot detection mechanisms.
113
+
114
+ **🎯 Optimized for Brave Browser**: While compatible with Chrome and Chromium,
115
+ this server is specifically optimized for Brave Browser, providing enhanced
116
+ privacy, ad-blocking, and anti-fingerprinting capabilities out-of-the-box.
109
117
 
110
118
  This server implements the Model Context Protocol (MCP), allowing AI
111
- assistants to control a real browser, extract content, and more.
119
+ assistants to control a real browser, extract content, solve CAPTCHAs, and perform
120
+ complex web automation tasks with human-like behavior.
112
121
 
113
122
  ## Features
114
123
 
115
124
  - **Stealth by default**: All browser instances use anti-detection features
116
- - **Enhanced Windows support**: Comprehensive Chrome detection and ECONNREFUSED error fixes (v1.3.0)
117
- - **Smart Chrome detection**: Registry-based detection + 15+ installation paths (Windows)
125
+ - **Enhanced Windows support**: Comprehensive Brave/Chrome detection and ECONNREFUSED error fixes
126
+ - **Smart browser detection**: Registry-based detection + 15+ installation paths for Brave and Chrome (Windows)
118
127
  - **Connection resilience**: Automatic localhost/127.0.0.1 fallback with port management
119
128
  - **Multiple retry strategies**: 5 different connection approaches with progressive fallback
120
129
  - **Advanced configuration**: Full support for all brave-real-browser options
@@ -132,27 +141,384 @@ assistants to control a real browser, extract content, and more.
132
141
 
133
142
  - Node.js >= 18.0.0
134
143
  - npm or yarn
135
- - Google Chrome or Chromium browser installed
144
+ - **Brave Browser** (recommended) or Google Chrome/Chromium browser installed
136
145
  - Basic understanding of TypeScript/JavaScript (for development)
137
146
 
138
147
  ### Platform-Specific Requirements
139
148
 
140
149
  **Windows:**
141
- - Google Chrome installation (automatic detection in v1.3.0+ includes):
142
- - Standard installations: `C:\Program Files\Google\Chrome\Application\chrome.exe`
143
- - 32-bit installations: `C:\Program Files (x86)\Google\Chrome\Application\chrome.exe`
144
- - User installations: `%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe`
145
- - Chrome Canary: `%LOCALAPPDATA%\Google\Chrome SxS\Application\chrome.exe`
150
+ - **Brave Browser** (recommended) or Google Chrome installation (automatic detection includes):
151
+ - **Brave Browser paths:**
152
+ - Standard: `C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe`
153
+ - 32-bit: `C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application\brave.exe`
154
+ - User: `%LOCALAPPDATA%\BraveSoftware\Brave-Browser\Application\brave.exe`
155
+ - Nightly: `%LOCALAPPDATA%\BraveSoftware\Brave-Browser-Nightly\Application\brave.exe`
156
+ - **Google Chrome paths:**
157
+ - Standard: `C:\Program Files\Google\Chrome\Application\chrome.exe`
158
+ - 32-bit: `C:\Program Files (x86)\Google\Chrome\Application\chrome.exe`
159
+ - User: `%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe`
160
+ - Canary: `%LOCALAPPDATA%\Google\Chrome SxS\Application\chrome.exe`
146
161
  - Portable installations and Registry-detected paths
147
- - Manual path specification: Use `CHROME_PATH` environment variable
162
+ - Manual path specification: Use `CHROME_PATH` or `BRAVE_PATH` environment variable
148
163
 
149
164
  **macOS:**
150
- - Google Chrome or Chromium must be installed in `/Applications/`
165
+ - **Brave Browser** (recommended): Install from [brave.com](https://brave.com) or App Store
166
+ - Alternative: Google Chrome or Chromium in `/Applications/`
167
+ - **Brave paths:**
168
+ - `/Applications/Brave Browser.app/Contents/MacOS/Brave Browser`
169
+ - `/Applications/Brave Browser Nightly.app/Contents/MacOS/Brave Browser Nightly`
151
170
 
152
171
  **Linux:**
153
- - Install Chrome/Chromium: `sudo apt-get install -y google-chrome-stable` or `sudo apt-get install -y chromium-browser`
172
+ - **Brave Browser** (recommended):
173
+ ```bash
174
+ # Install Brave Browser
175
+ sudo curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg
176
+ echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg] https://brave-browser-apt-release.s3.brave.com/ stable main" | sudo tee /etc/apt/sources.list.d/brave-browser-release.list
177
+ sudo apt update && sudo apt install brave-browser
178
+ ```
179
+ - **Alternative Chrome/Chromium:**
180
+ ```bash
181
+ sudo apt-get install -y google-chrome-stable
182
+ # or
183
+ sudo apt-get install -y chromium-browser
184
+ ```
154
185
  - Install xvfb for headless operation: `sudo apt-get install -y xvfb`
155
186
 
187
+ ## Platform-Specific Installation
188
+
189
+ > **🎯 Choose Your Platform:** Select the installation method that matches your operating system. Each section includes complete setup commands for both Brave Browser and MCP server configuration.
190
+
191
+ ### Windows Installation
192
+
193
+ #### Method 1: Complete Windows Setup (Recommended)
194
+
195
+ **Step 1: Install Node.js**
196
+ ```powershell
197
+ # Download and install from nodejs.org, or use winget
198
+ winget install OpenJS.NodeJS
199
+
200
+ # Verify installation
201
+ node --version
202
+ npm --version
203
+ ```
204
+
205
+ **Step 2: Install Brave Browser (Recommended)**
206
+ ```powershell
207
+ # Option 1: Download from brave.com
208
+ # Visit: https://brave.com/download/
209
+
210
+ # Option 2: Use winget
211
+ winget install BraveSoftware.BraveBrowser
212
+
213
+ # Option 3: Use Chocolatey
214
+ choco install brave
215
+
216
+ # Verify installation
217
+ & "C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe" --version
218
+ ```
219
+
220
+ **Step 3: Setup Claude Desktop MCP Configuration**
221
+ ```powershell
222
+ # Create Claude config directory
223
+ $configPath = "$env:APPDATA\Claude"
224
+ if (!(Test-Path $configPath)) { New-Item -ItemType Directory -Path $configPath }
225
+
226
+ # Create MCP configuration file
227
+ @"
228
+ {
229
+ "mcpServers": {
230
+ "brave-real-browser": {
231
+ "command": "npx",
232
+ "args": ["brave-real-browser-mcp-server@latest"]
233
+ }
234
+ }
235
+ }
236
+ "@ | Out-File -FilePath "$configPath\claude_desktop_config.json" -Encoding UTF8
237
+
238
+ echo "✅ Claude Desktop MCP configuration created successfully!"
239
+ echo "📁 Config file location: $configPath\claude_desktop_config.json"
240
+ ```
241
+
242
+ **Step 4: Setup Environment Variables (Optional)**
243
+ ```powershell
244
+ # Set Brave Browser path (if not auto-detected)
245
+ [Environment]::SetEnvironmentVariable("BRAVE_PATH", "C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe", "User")
246
+
247
+ # Alternative: Set Chrome path (if Brave not available)
248
+ # [Environment]::SetEnvironmentVariable("CHROME_PATH", "C:\Program Files\Google\Chrome\Application\chrome.exe", "User")
249
+
250
+ echo "✅ Environment variables set successfully!"
251
+ ```
252
+
253
+ **Step 5: Test MCP Server**
254
+ ```powershell
255
+ # Test the MCP server directly
256
+ npx brave-real-browser-mcp-server@latest --help
257
+
258
+ # Test with Claude Desktop (restart Claude first)
259
+ echo "🔄 Restart Claude Desktop and test with: 'Initialize a browser and navigate to google.com'"
260
+ ```
261
+
262
+ #### Method 2: Quick Setup (One-liner)
263
+ ```powershell
264
+ # Complete Windows setup in one command
265
+ iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/codeiva4u/Brave-Real-Browser-Mcp-Server/main/scripts/install-windows.ps1'))
266
+ ```
267
+
268
+ ### macOS Installation
269
+
270
+ #### Method 1: Complete macOS Setup (Recommended)
271
+
272
+ **Step 1: Install Node.js**
273
+ ```bash
274
+ # Option 1: Download from nodejs.org
275
+ # Visit: https://nodejs.org/
276
+
277
+ # Option 2: Use Homebrew
278
+ brew install node
279
+
280
+ # Option 3: Use nvm (Node Version Manager)
281
+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
282
+ source ~/.bashrc
283
+ nvm install node
284
+
285
+ # Verify installation
286
+ node --version
287
+ npm --version
288
+ ```
289
+
290
+ **Step 2: Install Brave Browser (Recommended)**
291
+ ```bash
292
+ # Option 1: Download from brave.com
293
+ # Visit: https://brave.com/download/
294
+
295
+ # Option 2: Use Homebrew
296
+ brew install --cask brave-browser
297
+
298
+ # Option 3: Use Mac App Store
299
+ # Search for "Brave Browser" in App Store
300
+
301
+ # Verify installation
302
+ "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser" --version
303
+ ```
304
+
305
+ **Step 3: Setup Claude Desktop MCP Configuration**
306
+ ```bash
307
+ # Create Claude config directory
308
+ mkdir -p ~/"Library/Application Support/Claude"
309
+
310
+ # Create MCP configuration file
311
+ cat << 'EOF' > ~/"Library/Application Support/Claude/claude_desktop_config.json"
312
+ {
313
+ "mcpServers": {
314
+ "brave-real-browser": {
315
+ "command": "npx",
316
+ "args": ["brave-real-browser-mcp-server@latest"]
317
+ }
318
+ }
319
+ }
320
+ EOF
321
+
322
+ echo "✅ Claude Desktop MCP configuration created successfully!"
323
+ echo "📁 Config file location: ~/Library/Application Support/Claude/claude_desktop_config.json"
324
+ ```
325
+
326
+ **Step 4: Setup Environment Variables (Optional)**
327
+ ```bash
328
+ # Add to your shell profile (.bashrc, .zshrc, etc.)
329
+ echo 'export BRAVE_PATH="/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"' >> ~/.zshrc
330
+
331
+ # Alternative: Set Chrome path (if Brave not available)
332
+ # echo 'export CHROME_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"' >> ~/.zshrc
333
+
334
+ # Reload shell configuration
335
+ source ~/.zshrc
336
+
337
+ echo "✅ Environment variables set successfully!"
338
+ ```
339
+
340
+ **Step 5: Test MCP Server**
341
+ ```bash
342
+ # Test the MCP server directly
343
+ npx brave-real-browser-mcp-server@latest --help
344
+
345
+ # Test browser launch
346
+ node -e "console.log('Testing browser paths:'); console.log('Brave:', process.env.BRAVE_PATH);"
347
+
348
+ echo "🔄 Restart Claude Desktop and test with: 'Initialize a browser and navigate to google.com'"
349
+ ```
350
+
351
+ #### Method 2: Quick Setup (One-liner)
352
+ ```bash
353
+ # Complete macOS setup in one command
354
+ curl -fsSL https://raw.githubusercontent.com/codeiva4u/Brave-Real-Browser-Mcp-Server/main/scripts/install-macos.sh | bash
355
+ ```
356
+
357
+ ### Linux Installation
358
+
359
+ #### Method 1: Complete Linux Setup (Ubuntu/Debian)
360
+
361
+ **Step 1: Install Node.js**
362
+ ```bash
363
+ # Option 1: Using NodeSource repository (recommended)
364
+ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
365
+ sudo apt-get install -y nodejs
366
+
367
+ # Option 2: Using snap
368
+ sudo snap install node --classic
369
+
370
+ # Option 3: Using package manager
371
+ sudo apt update
372
+ sudo apt install -y nodejs npm
373
+
374
+ # Verify installation
375
+ node --version
376
+ npm --version
377
+ ```
378
+
379
+ **Step 2: Install Brave Browser (Recommended)**
380
+ ```bash
381
+ # Install Brave Browser
382
+ sudo curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg
383
+
384
+ echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg] https://brave-browser-apt-release.s3.brave.com/ stable main" | sudo tee /etc/apt/sources.list.d/brave-browser-release.list
385
+
386
+ sudo apt update
387
+ sudo apt install -y brave-browser
388
+
389
+ # Install dependencies for headless operation
390
+ sudo apt-get install -y xvfb
391
+
392
+ # Verify installation
393
+ brave-browser --version
394
+ ```
395
+
396
+ **Step 3: Setup Claude Desktop MCP Configuration**
397
+ ```bash
398
+ # Create Claude config directory
399
+ mkdir -p ~/.config/Claude
400
+
401
+ # Create MCP configuration file
402
+ cat << 'EOF' > ~/.config/Claude/claude_desktop_config.json
403
+ {
404
+ "mcpServers": {
405
+ "brave-real-browser": {
406
+ "command": "npx",
407
+ "args": ["brave-real-browser-mcp-server@latest"]
408
+ }
409
+ }
410
+ }
411
+ EOF
412
+
413
+ echo "✅ Claude Desktop MCP configuration created successfully!"
414
+ echo "📁 Config file location: ~/.config/Claude/claude_desktop_config.json"
415
+ ```
416
+
417
+ **Step 4: Setup Environment Variables**
418
+ ```bash
419
+ # Add to your shell profile
420
+ echo 'export BRAVE_PATH="/usr/bin/brave-browser"' >> ~/.bashrc
421
+ echo 'export DISPLAY=:99' >> ~/.bashrc # For headless operation
422
+
423
+ # Alternative browser paths
424
+ # echo 'export CHROME_PATH="/usr/bin/google-chrome"' >> ~/.bashrc
425
+ # echo 'export CHROME_PATH="/usr/bin/chromium-browser"' >> ~/.bashrc
426
+
427
+ # Reload shell configuration
428
+ source ~/.bashrc
429
+
430
+ echo "✅ Environment variables set successfully!"
431
+ ```
432
+
433
+ **Step 5: Setup Headless Display (For Server Usage)**
434
+ ```bash
435
+ # Start virtual display for headless operation
436
+ sudo apt-get install -y xvfb
437
+
438
+ # Create xvfb service (optional)
439
+ sudo tee /etc/systemd/system/xvfb.service << 'EOF'
440
+ [Unit]
441
+ Description=X Virtual Frame Buffer Service
442
+ After=network.target
443
+
444
+ [Service]
445
+ ExecStart=/usr/bin/Xvfb :99 -screen 0 1024x768x24
446
+ Restart=on-failure
447
+ RestartSec=2
448
+ User=nobody
449
+ Group=nogroup
450
+
451
+ [Install]
452
+ WantedBy=multi-user.target
453
+ EOF
454
+
455
+ # Enable and start xvfb service
456
+ sudo systemctl enable xvfb
457
+ sudo systemctl start xvfb
458
+
459
+ echo "✅ Headless display configured successfully!"
460
+ ```
461
+
462
+ **Step 6: Test MCP Server**
463
+ ```bash
464
+ # Test the MCP server directly
465
+ npx brave-real-browser-mcp-server@latest --help
466
+
467
+ # Test headless operation
468
+ export DISPLAY=:99
469
+ node -e "console.log('Testing browser paths:'); console.log('Brave:', process.env.BRAVE_PATH); console.log('Display:', process.env.DISPLAY);"
470
+
471
+ # Test browser launch
472
+ echo "🔄 Testing browser launch..."
473
+ timeout 10s brave-browser --headless --dump-dom --disable-gpu https://google.com > /dev/null && echo "✅ Browser test successful!" || echo "❌ Browser test failed"
474
+
475
+ echo "🔄 Restart Claude Desktop and test with: 'Initialize a browser and navigate to google.com'"
476
+ ```
477
+
478
+ #### Method 2: CentOS/RHEL/Fedora Setup
479
+ ```bash
480
+ # Install Node.js
481
+ curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
482
+ sudo yum install -y nodejs
483
+
484
+ # Install Brave Browser
485
+ sudo dnf install dnf-plugins-core
486
+ sudo dnf config-manager --add-repo https://brave-browser-rpm-release.s3.brave.com/x86_64/
487
+ sudo rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc
488
+ sudo dnf install brave-browser
489
+
490
+ # Continue with steps 3-6 from Ubuntu setup above
491
+ ```
492
+
493
+ #### Method 3: Quick Setup (One-liner for Ubuntu/Debian)
494
+ ```bash
495
+ # Complete Linux setup in one command
496
+ curl -fsSL https://raw.githubusercontent.com/codeiva4u/Brave-Real-Browser-Mcp-Server/main/scripts/install-linux.sh | bash
497
+ ```
498
+
499
+ ### Post-Installation Verification
500
+
501
+ **Test MCP Server on All Platforms:**
502
+ ```bash
503
+ # 1. Test Node.js and npm
504
+ node --version && npm --version
505
+
506
+ # 2. Test MCP server installation
507
+ npx brave-real-browser-mcp-server@latest --version
508
+
509
+ # 3. Test browser availability
510
+ # Windows: & "C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe" --version
511
+ # macOS: "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser" --version
512
+ # Linux: brave-browser --version
513
+
514
+ # 4. Verify MCP configuration
515
+ # Check if claude_desktop_config.json exists and contains brave-real-browser server
516
+
517
+ # 5. Test with Claude Desktop
518
+ # Restart Claude Desktop completely
519
+ # Try: "Initialize a browser and navigate to example.com, then get the page title"
520
+ ```
521
+
156
522
  ## Installation for Developers
157
523
 
158
524
  > **Note for Claude Desktop Users:** You don't need to install anything! The npx command in your configuration automatically handles everything. Skip to the [Usage](#usage) section.
@@ -230,9 +596,16 @@ This command:
230
596
 
231
597
  #### Method 2: Add with Environment Variables
232
598
 
233
- If you need to configure proxy settings or custom Chrome paths:
599
+ If you need to configure proxy settings or custom browser paths:
234
600
 
235
601
  ```bash
602
+ # For Brave Browser (recommended)
603
+ claude mcp add brave-real-browser \
604
+ -e BRAVE_PATH="/path/to/brave" \
605
+ -e PROXY_URL="http://proxy:8080" \
606
+ -- npx brave-real-browser-mcp-server@latest
607
+
608
+ # Alternative for Chrome (if Brave not available)
236
609
  claude mcp add brave-real-browser \
237
610
  -e CHROME_PATH="/path/to/chrome" \
238
611
  -e PROXY_URL="http://proxy:8080" \
@@ -256,6 +629,18 @@ claude mcp add brave-real-browser -s project -- npx brave-real-browser-mcp-serve
256
629
  For advanced users who want precise control:
257
630
 
258
631
  ```bash
632
+ # For Brave Browser (recommended)
633
+ claude mcp add-json brave-real-browser '{
634
+ "type": "stdio",
635
+ "command": "npx",
636
+ "args": ["brave-real-browser-mcp-server@latest"],
637
+ "env": {
638
+ "BRAVE_PATH": "/path/to/brave",
639
+ "PROXY_URL": "http://proxy:8080"
640
+ }
641
+ }'
642
+
643
+ # Alternative for Chrome (if Brave not available)
259
644
  claude mcp add-json brave-real-browser '{
260
645
  "type": "stdio",
261
646
  "command": "npx",
@@ -298,7 +683,7 @@ After adding the server:
298
683
 
299
684
  - **Automatic Updates**: Using `@latest` ensures you get bug fixes and improvements
300
685
  - **No Installation**: npx handles downloading and running automatically
301
- - **Environment Variables**: Easy configuration of proxies, Chrome paths, etc.
686
+ - **Environment Variables**: Easy configuration of proxies, Brave/Chrome paths, etc.
302
687
  - **Scope Control**: Choose where the server is available (local/project/user)
303
688
  - **Team Sharing**: Project scope allows sharing configurations with teammates
304
689
  - **Status Monitoring**: Built-in `/mcp` command for server health checks
@@ -336,7 +721,7 @@ Cursor IDE uses the same npx approach - no installation needed! Here are the set
336
721
 
337
722
  > **Important:** Just like Claude Desktop, Cursor will use `npx` to automatically download and run the server. You don't need to install anything with npm!
338
723
 
339
- **Windows-Specific Configuration (if experiencing Chrome path issues):**
724
+ **Windows-Specific Configuration (Brave Browser Recommended):**
340
725
  ```json
341
726
  {
342
727
  "mcpServers": {
@@ -344,16 +729,14 @@ Cursor IDE uses the same npx approach - no installation needed! Here are the set
344
729
  "command": "npx",
345
730
  "args": ["brave-real-browser-mcp-server@latest"],
346
731
  "env": {
347
- "CHROME_PATH": "C:/Program Files/Google/Chrome/Application/chrome.exe"
732
+ "BRAVE_PATH": "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"
348
733
  }
349
734
  }
350
735
  }
351
736
  }
352
737
  ```
353
738
 
354
- > **Note**: Browser options like headless mode should be configured when initializing the browser through the `browser_init` tool, not via environment variables.
355
-
356
- **Advanced Configuration with Custom Chrome Path:**
739
+ **Alternative Chrome Configuration (if Brave not available):**
357
740
  ```json
358
741
  {
359
742
  "mcpServers": {
@@ -368,36 +751,60 @@ Cursor IDE uses the same npx approach - no installation needed! Here are the set
368
751
  }
369
752
  ```
370
753
 
754
+ > **Note**: Browser options like headless mode should be configured when initializing the browser through the `browser_init` tool, not via environment variables.
755
+
371
756
  > **Note**: Proxy settings and browser options should be configured when asking Claude to initialize the browser using the `browser_init` tool.
372
757
 
373
- #### Platform-Specific Chrome Paths for Cursor IDE
758
+ #### Platform-Specific Browser Paths for Cursor IDE
374
759
 
375
- If Chrome auto-detection fails, you can specify the Chrome path using the `CHROME_PATH` environment variable:
760
+ If browser auto-detection fails, you can specify the browser path using environment variables:
376
761
 
377
- **Windows:**
762
+ **Windows (Brave Browser Recommended):**
763
+ ```json
764
+ "env": {
765
+ "BRAVE_PATH": "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"
766
+ }
767
+ ```
768
+ Alternative Brave paths:
769
+ - `"C:/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"`
770
+ - `"%LOCALAPPDATA%/BraveSoftware/Brave-Browser/Application/brave.exe"`
771
+
772
+ **Windows (Chrome Alternative - if Brave not available):**
378
773
  ```json
379
774
  "env": {
380
775
  "CHROME_PATH": "C:/Program Files/Google/Chrome/Application/chrome.exe"
381
776
  }
382
777
  ```
383
- Alternative Windows paths:
778
+ Alternative Chrome paths (use only if Brave is not installed):
384
779
  - `"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"`
385
780
  - `"%LOCALAPPDATA%/Google/Chrome/Application/chrome.exe"`
386
781
 
387
- **macOS:**
782
+ **macOS (Brave Browser Recommended):**
783
+ ```json
784
+ "env": {
785
+ "BRAVE_PATH": "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
786
+ }
787
+ ```
788
+ **macOS (Chrome Alternative - if Brave not available):**
388
789
  ```json
389
790
  "env": {
390
791
  "CHROME_PATH": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
391
792
  }
392
793
  ```
393
794
 
394
- **Linux:**
795
+ **Linux (Brave Browser Recommended):**
796
+ ```json
797
+ "env": {
798
+ "BRAVE_PATH": "/usr/bin/brave-browser"
799
+ }
800
+ ```
801
+ **Linux (Chrome Alternative - if Brave not available):**
395
802
  ```json
396
803
  "env": {
397
804
  "CHROME_PATH": "/usr/bin/google-chrome"
398
805
  }
399
806
  ```
400
- Alternative Linux paths: `/usr/bin/chromium-browser`, `/snap/bin/chromium`
807
+ Alternative Chrome paths (use only if Brave is not installed): `/usr/bin/chromium-browser`, `/snap/bin/chromium`
401
808
 
402
809
 
403
810
  #### Testing Cursor IDE Setup
@@ -422,9 +829,10 @@ If successful, you should see:
422
829
  - Ensure Node.js 18+ is installed
423
830
 
424
831
  2. **"Browser failed to launch" on Windows**
425
- - Add explicit Chrome path in `executablePath`
832
+ - Add explicit Brave browser path: `"BRAVE_PATH": "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"`
833
+ - Alternative (if Brave not available): Add Chrome path: `"CHROME_PATH": "C:/Program Files/Google/Chrome/Application/chrome.exe"`
426
834
  - Try running Cursor IDE as Administrator
427
- - Check Windows Defender isn't blocking Chrome
835
+ - Check Windows Defender isn't blocking browser
428
836
 
429
837
  3. **"Permission denied"**
430
838
  - Use `sudo npm install -g brave-real-browser-mcp-server` on Linux/Mac
@@ -97,8 +97,19 @@ describe('Browser Handlers', () => {
97
97
  autoSuggestGetContent: false
98
98
  }
99
99
  };
100
- // Mock the complete flow
100
+ // Mock the complete flow - reset all mocks first
101
+ vi.clearAllMocks();
102
+ // Reset workflow validation to allow browser init
103
+ mockWorkflowValidation.validateWorkflow.mockReturnValue({
104
+ isValid: true,
105
+ errorMessage: null,
106
+ suggestedAction: null
107
+ });
108
+ mockWorkflowValidation.recordExecution.mockReturnValue(undefined);
109
+ mockWorkflowValidation.workflowValidator.getValidationSummary.mockReturnValue('Mock summary');
110
+ // Mock browser manager functions
101
111
  mockBrowserManager.initializeBrowser.mockResolvedValue(undefined);
112
+ mockBrowserManager.updateContentPriorityConfig.mockReturnValue(undefined);
102
113
  mockBrowserManager.getContentPriorityConfig.mockReturnValue({
103
114
  prioritizeContent: false,
104
115
  autoSuggestGetContent: false
@@ -132,24 +143,31 @@ describe('Browser Handlers', () => {
132
143
  expect(mockWorkflowValidation.recordExecution).toHaveBeenCalledWith('browser_init', args, false, 'Failed to initialize browser');
133
144
  });
134
145
  it('should handle workflow validation failure', async () => {
135
- // Arrange: Clear mocks for isolated test and set invalid workflow state
136
- vi.clearAllMocks();
137
- // Set up minimal required mocks for this test
138
- mockWorkflowValidation.validateWorkflow.mockReturnValue({
146
+ // Arrange: Mock validateWorkflow to be imported and used by the handler
147
+ // We need to import and re-mock this to intercept the actual validation call
148
+ const mockValidateWorkflow = vi.fn();
149
+ const mockRecordExecution = vi.fn();
150
+ const mockGetValidationSummary = vi.fn();
151
+ // Set up validation failure
152
+ mockValidateWorkflow.mockReturnValue({
139
153
  isValid: false,
140
154
  errorMessage: 'Browser already initialized',
141
155
  suggestedAction: 'Close browser first'
142
156
  });
143
- mockWorkflowValidation.workflowValidator.getValidationSummary.mockReturnValue('Current state: BROWSER_ACTIVE | Last action: browser_init');
144
- mockWorkflowValidation.recordExecution.mockReturnValue(undefined);
145
- // Ensure initializeBrowser is not called by clearing its mock
146
- mockBrowserManager.initializeBrowser.mockClear();
157
+ mockGetValidationSummary.mockReturnValue('Current state: BROWSER_ACTIVE | Last action: browser_init');
158
+ mockRecordExecution.mockReturnValue(undefined);
159
+ // Set the mocks on the module
160
+ mockWorkflowValidation.validateWorkflow = mockValidateWorkflow;
161
+ mockWorkflowValidation.recordExecution = mockRecordExecution;
162
+ mockWorkflowValidation.workflowValidator.getValidationSummary = mockGetValidationSummary;
163
+ // Ensure initializeBrowser is mocked but should NOT be called
164
+ mockBrowserManager.initializeBrowser.mockResolvedValue(undefined);
147
165
  const args = { headless: false };
148
166
  // Act & Assert: Should throw workflow validation error
149
167
  await expect(handleBrowserInit(args)).rejects.toThrow(/Browser already initialized.*Next Steps: Close browser first/s);
150
168
  // Verify that browser initialization was NOT called due to validation failure
151
169
  expect(mockBrowserManager.initializeBrowser).not.toHaveBeenCalled();
152
- expect(mockWorkflowValidation.recordExecution).toHaveBeenCalledWith('browser_init', expect.objectContaining({ headless: false }), false, expect.stringContaining('Browser already initialized'));
170
+ expect(mockRecordExecution).toHaveBeenCalledWith('browser_init', expect.objectContaining({ headless: false }), false, expect.stringContaining('Browser already initialized'));
153
171
  });
154
172
  it('should include workflow guidance in success message', async () => {
155
173
  // Arrange: Set up for successful initialization (keep existing mock setup)
@@ -30,13 +30,17 @@ vi.mock('../token-management.js', () => ({
30
30
  }));
31
31
  // Mock TurndownService
32
32
  vi.mock('turndown', () => {
33
- const mockInstance = {
34
- turndown: vi.fn().mockReturnValue('# Mock Markdown\n\nContent converted to markdown.'),
35
- addRule: vi.fn()
33
+ const createMockInstance = () => {
34
+ const mockInstance = {
35
+ turndown: vi.fn().mockReturnValue('# Mock Markdown\n\nContent converted to markdown.'),
36
+ addRule: vi.fn()
37
+ };
38
+ // addRule should return the instance for chaining
39
+ mockInstance.addRule.mockReturnValue(mockInstance);
40
+ return mockInstance;
36
41
  };
37
- mockInstance.addRule.mockReturnValue(mockInstance);
38
42
  return {
39
- default: vi.fn().mockImplementation(() => mockInstance)
43
+ default: vi.fn().mockImplementation(createMockInstance)
40
44
  };
41
45
  });
42
46
  describe('file-handlers', () => {
@@ -167,6 +167,63 @@ export async function handleType(args) {
167
167
  }, 'Failed to type text');
168
168
  });
169
169
  }
170
+ // Select dropdown handler
171
+ export async function handleSelect(args) {
172
+ return await withWorkflowValidation('select', args, async () => {
173
+ return await withErrorHandling(async () => {
174
+ const pageInstance = getPageInstance();
175
+ if (!pageInstance) {
176
+ throw new Error('Browser not initialized. Call browser_init first.');
177
+ }
178
+ const { selector, value } = args;
179
+ const elementResult = await selfHealingLocators.findElementWithFallbacks(pageInstance, selector);
180
+ if (!elementResult) {
181
+ const fallbackSummary = await selfHealingLocators.getFallbackSummary(pageInstance, selector);
182
+ throw new Error(`Select dropdown not found: ${selector}\n\n` +
183
+ '?? Self-healing locators tried multiple fallback strategies but could not find the select element.\n\n' +
184
+ '?? Troubleshooting suggestions:\n' +
185
+ ' � Use find_selector to locate select elements\n' +
186
+ ' � Verify the selector with get_content first\n' +
187
+ ' � Ensure the select dropdown is visible and enabled\n\n' +
188
+ fallbackSummary);
189
+ }
190
+ const { element, usedSelector, strategy } = elementResult;
191
+ let strategyMessage = '';
192
+ if (strategy !== 'primary') {
193
+ strategyMessage = `\n?? Self-healing: Used ${strategy} fallback selector: ${usedSelector}`;
194
+ console.warn(`Self-healing select: Primary selector '${selector}' failed, used '${usedSelector}' (${strategy})`);
195
+ }
196
+ try {
197
+ await pageInstance.waitForSelector(usedSelector, { timeout: 5000 });
198
+ await pageInstance.evaluate((sel, val) => {
199
+ const selectElement = document.querySelector(sel);
200
+ if (!selectElement) {
201
+ throw new Error(`Select element not found: ${sel}`);
202
+ }
203
+ selectElement.value = val;
204
+ selectElement.dispatchEvent(new Event('change', { bubbles: true }));
205
+ selectElement.dispatchEvent(new Event('input', { bubbles: true }));
206
+ if (selectElement.onchange) {
207
+ selectElement.onchange(new Event('change'));
208
+ }
209
+ }, usedSelector, value);
210
+ await pageInstance.waitForTimeout(1000);
211
+ return {
212
+ content: [
213
+ {
214
+ type: 'text',
215
+ text: `Selected option with value '${value}' in: ${usedSelector}${strategyMessage}\n\n? Select operation completed successfully through validated workflow`,
216
+ },
217
+ ],
218
+ };
219
+ }
220
+ catch (selectError) {
221
+ throw new Error(`Select operation failed on element: ${usedSelector}. ` +
222
+ `Error: ${selectError instanceof Error ? selectError.message : String(selectError)}`);
223
+ }
224
+ }, 'Failed to select dropdown option');
225
+ });
226
+ }
170
227
  // Solve captcha handler
171
228
  export async function handleSolveCaptcha(args) {
172
229
  return await withErrorHandling(async () => {
@@ -26,14 +26,15 @@ vi.mock('../workflow-validation', () => ({
26
26
  }
27
27
  }));
28
28
  // Mock setTimeout globally - track delays without immediate execution for exponential backoff testing
29
+ const originalSetTimeout = global.setTimeout;
29
30
  const setTimeoutMock = vi.fn((callback, delay) => {
30
31
  // Store the delay for assertion while allowing async execution
31
- setTimeout(() => {
32
+ // Use the original setTimeout to avoid recursion
33
+ return originalSetTimeout(() => {
32
34
  if (typeof callback === 'function') {
33
35
  callback();
34
36
  }
35
37
  }, 0); // Execute asynchronously but immediately for test speed
36
- return 1;
37
38
  });
38
39
  vi.stubGlobal('setTimeout', setTimeoutMock);
39
40
  // Import mocked modules
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ import { setupProcessCleanup } from './core-infrastructure.js';
20
20
  console.error('🔍 [DEBUG] Loading handlers...');
21
21
  import { handleBrowserInit, handleBrowserClose } from './handlers/browser-handlers.js';
22
22
  import { handleNavigate, handleWait } from './handlers/navigation-handlers.js';
23
- import { handleClick, handleType, handleSolveCaptcha, handleRandomScroll } from './handlers/interaction-handlers.js';
23
+ import { handleClick, handleType, handleSelect, handleSolveCaptcha, handleRandomScroll } from './handlers/interaction-handlers.js';
24
24
  import { handleGetContent, handleFindSelector } from './handlers/content-handlers.js';
25
25
  import { handleSaveContentAsMarkdown } from './handlers/file-handlers.js';
26
26
  console.error('🔍 [DEBUG] All modules loaded successfully');
@@ -87,6 +87,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
87
87
  return await handleClick(args);
88
88
  case TOOL_NAMES.TYPE:
89
89
  return await handleType(args);
90
+ case TOOL_NAMES.SELECT:
91
+ return await handleSelect(args);
90
92
  case TOOL_NAMES.WAIT:
91
93
  return await handleWait(args);
92
94
  case TOOL_NAMES.BROWSER_CLOSE:
@@ -172,6 +172,24 @@ export const TOOLS = [
172
172
  required: ['selector', 'text'],
173
173
  },
174
174
  },
175
+ {
176
+ name: 'select',
177
+ description: 'Select an option from a dropdown (select element)',
178
+ inputSchema: {
179
+ type: 'object',
180
+ properties: {
181
+ selector: {
182
+ type: 'string',
183
+ description: 'CSS selector of the select dropdown element',
184
+ },
185
+ value: {
186
+ type: 'string',
187
+ description: 'Value of the option to select',
188
+ },
189
+ },
190
+ required: ['selector', 'value'],
191
+ },
192
+ },
175
193
  {
176
194
  name: 'wait',
177
195
  description: 'Wait for various conditions',
@@ -311,6 +329,7 @@ export const TOOL_NAMES = {
311
329
  GET_CONTENT: 'get_content',
312
330
  CLICK: 'click',
313
331
  TYPE: 'type',
332
+ SELECT: 'select',
314
333
  WAIT: 'wait',
315
334
  BROWSER_CLOSE: 'browser_close',
316
335
  SOLVE_CAPTCHA: 'solve_captcha',
@@ -322,6 +341,6 @@ export const TOOL_NAMES = {
322
341
  export const TOOL_CATEGORIES = {
323
342
  BROWSER_MANAGEMENT: [TOOL_NAMES.BROWSER_INIT, TOOL_NAMES.BROWSER_CLOSE],
324
343
  NAVIGATION: [TOOL_NAMES.NAVIGATE, TOOL_NAMES.WAIT],
325
- INTERACTION: [TOOL_NAMES.CLICK, TOOL_NAMES.TYPE, TOOL_NAMES.SOLVE_CAPTCHA, TOOL_NAMES.RANDOM_SCROLL],
344
+ INTERACTION: [TOOL_NAMES.CLICK, TOOL_NAMES.TYPE, TOOL_NAMES.SELECT, TOOL_NAMES.SOLVE_CAPTCHA, TOOL_NAMES.RANDOM_SCROLL],
326
345
  CONTENT: [TOOL_NAMES.GET_CONTENT, TOOL_NAMES.FIND_SELECTOR, TOOL_NAMES.SAVE_CONTENT_AS_MARKDOWN],
327
346
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brave-real-browser-mcp-server",
3
- "version": "2.0.3",
3
+ "version": "2.0.6",
4
4
  "description": "MCP server for brave-real-browser",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -36,16 +36,13 @@
36
36
  "test:all": "npm run test:ci && npm run test:full && npm run test:performance",
37
37
  "test:dashboard": "node test-runner.js",
38
38
  "test:nopecha": "node test.cjs",
39
- "test:comprehensive": "node test.cjs",
40
- "test:version-increment": "node scripts/test-version-increment.cjs",
41
- "test:workflow": "node scripts/test-workflow-local.cjs",
42
- "test:workflow:full": "npm run test:workflow && npm run test:version-increment"
39
+ "test:comprehensive": "node test.cjs"
43
40
  },
44
41
  "dependencies": {
45
42
  "@modelcontextprotocol/sdk": ">=1.0.0",
46
43
  "@types/turndown": "^5.0.5",
47
44
  "brave-real-browser": "^1.5.95",
48
- "brave-real-launcher": "^1.2.10",
45
+ "brave-real-launcher": "^1.2.12",
49
46
  "brave-real-puppeteer-core": "^24.22.0",
50
47
  "turndown": "^7.2.0"
51
48
  },