brave-real-browser-mcp-server 2.9.13 → 2.9.14
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 +100 -101
- package/dist/browser-manager.js +99 -104
- package/dist/browser-manager.test.js +33 -33
- package/dist/index.js +2 -2
- package/dist/tool-definitions.js +5 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -114,8 +114,8 @@ assistants to control a real browser, extract content, and more.
|
|
|
114
114
|
|
|
115
115
|
- **🔄 Auto-Update System**: Automatically updates all dependencies to latest versions on every `npm install`
|
|
116
116
|
- **Stealth by default**: All browser instances use anti-detection features
|
|
117
|
-
- **Enhanced Windows support**: Comprehensive
|
|
118
|
-
- **Smart
|
|
117
|
+
- **Enhanced Windows support**: Comprehensive Brave detection and ECONNREFUSED error fixes
|
|
118
|
+
- **Smart Brave detection**: Registry-based detection + 13+ installation paths (Windows)
|
|
119
119
|
- **Connection resilience**: Automatic localhost/127.0.0.1 fallback with port management
|
|
120
120
|
- **Multiple retry strategies**: 5 different connection approaches with progressive fallback
|
|
121
121
|
- **Advanced configuration**: Full support for all brave-real-browser options
|
|
@@ -133,25 +133,24 @@ assistants to control a real browser, extract content, and more.
|
|
|
133
133
|
|
|
134
134
|
- Node.js >= 18.0.0
|
|
135
135
|
- npm or yarn
|
|
136
|
-
-
|
|
136
|
+
- Brave Browser 13+ installed
|
|
137
137
|
- Basic understanding of TypeScript/JavaScript (for development)
|
|
138
138
|
|
|
139
139
|
### Platform-Specific Requirements
|
|
140
140
|
|
|
141
141
|
**Windows:**
|
|
142
|
-
-
|
|
143
|
-
- Standard installations: `C:\Program Files\
|
|
144
|
-
- 32-bit installations: `C:\Program Files (x86)\
|
|
145
|
-
- User installations: `%LOCALAPPDATA%\
|
|
146
|
-
- Chrome Canary: `%LOCALAPPDATA%\Google\Chrome SxS\Application\chrome.exe`
|
|
142
|
+
- Brave Browser installation (automatic detection includes):
|
|
143
|
+
- Standard installations: `C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe`
|
|
144
|
+
- 32-bit installations: `C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application\brave.exe`
|
|
145
|
+
- User installations: `%LOCALAPPDATA%\BraveSoftware\Brave-Browser\Application\brave.exe`
|
|
147
146
|
- Portable installations and Registry-detected paths
|
|
148
|
-
- Manual path specification: Use `
|
|
147
|
+
- Manual path specification: Use `BRAVE_PATH` environment variable
|
|
149
148
|
|
|
150
149
|
**macOS:**
|
|
151
|
-
-
|
|
150
|
+
- Brave Browser must be installed in `/Applications/Brave Browser.app`
|
|
152
151
|
|
|
153
152
|
**Linux:**
|
|
154
|
-
- Install
|
|
153
|
+
- Install Brave: `sudo apt install brave-browser` or via snap: `sudo snap install brave`
|
|
155
154
|
- Install xvfb for headless operation: `sudo apt-get install -y xvfb`
|
|
156
155
|
|
|
157
156
|
## Installation for Developers
|
|
@@ -231,11 +230,11 @@ This command:
|
|
|
231
230
|
|
|
232
231
|
#### Method 2: Add with Environment Variables
|
|
233
232
|
|
|
234
|
-
If you need to configure proxy settings or custom
|
|
233
|
+
If you need to configure proxy settings or custom Brave paths:
|
|
235
234
|
|
|
236
235
|
```bash
|
|
237
236
|
claude mcp add brave-real-browser \
|
|
238
|
-
-e
|
|
237
|
+
-e BRAVE_PATH="/path/to/brave" \
|
|
239
238
|
-e PROXY_URL="http://proxy:8080" \
|
|
240
239
|
-- npx brave-real-browser-mcp-server@latest
|
|
241
240
|
```
|
|
@@ -262,7 +261,7 @@ claude mcp add-json brave-real-browser '{
|
|
|
262
261
|
"command": "npx",
|
|
263
262
|
"args": ["brave-real-browser-mcp-server@latest"],
|
|
264
263
|
"env": {
|
|
265
|
-
"
|
|
264
|
+
"BRAVE_PATH": "/path/to/brave",
|
|
266
265
|
"PROXY_URL": "http://proxy:8080"
|
|
267
266
|
}
|
|
268
267
|
}'
|
|
@@ -299,7 +298,7 @@ After adding the server:
|
|
|
299
298
|
|
|
300
299
|
- **Automatic Updates**: Using `@latest` ensures you get bug fixes and improvements
|
|
301
300
|
- **No Installation**: npx handles downloading and running automatically
|
|
302
|
-
- **Environment Variables**: Easy configuration of proxies,
|
|
301
|
+
- **Environment Variables**: Easy configuration of proxies, Brave paths, etc.
|
|
303
302
|
- **Scope Control**: Choose where the server is available (local/project/user)
|
|
304
303
|
- **Team Sharing**: Project scope allows sharing configurations with teammates
|
|
305
304
|
- **Status Monitoring**: Built-in `/mcp` command for server health checks
|
|
@@ -337,7 +336,7 @@ Cursor IDE uses the same npx approach - no installation needed! Here are the set
|
|
|
337
336
|
|
|
338
337
|
> **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!
|
|
339
338
|
|
|
340
|
-
**Windows-Specific Configuration (if experiencing
|
|
339
|
+
**Windows-Specific Configuration (if experiencing Brave path issues):**
|
|
341
340
|
```json
|
|
342
341
|
{
|
|
343
342
|
"mcpServers": {
|
|
@@ -345,7 +344,7 @@ Cursor IDE uses the same npx approach - no installation needed! Here are the set
|
|
|
345
344
|
"command": "npx",
|
|
346
345
|
"args": ["brave-real-browser-mcp-server@latest"],
|
|
347
346
|
"env": {
|
|
348
|
-
"
|
|
347
|
+
"BRAVE_PATH": "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"
|
|
349
348
|
}
|
|
350
349
|
}
|
|
351
350
|
}
|
|
@@ -354,7 +353,7 @@ Cursor IDE uses the same npx approach - no installation needed! Here are the set
|
|
|
354
353
|
|
|
355
354
|
> **Note**: Browser options like headless mode should be configured when initializing the browser through the `browser_init` tool, not via environment variables.
|
|
356
355
|
|
|
357
|
-
**Advanced Configuration with Custom
|
|
356
|
+
**Advanced Configuration with Custom Brave Path:**
|
|
358
357
|
```json
|
|
359
358
|
{
|
|
360
359
|
"mcpServers": {
|
|
@@ -362,7 +361,7 @@ Cursor IDE uses the same npx approach - no installation needed! Here are the set
|
|
|
362
361
|
"command": "npx",
|
|
363
362
|
"args": ["brave-real-browser-mcp-server@latest"],
|
|
364
363
|
"env": {
|
|
365
|
-
"
|
|
364
|
+
"BRAVE_PATH": "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"
|
|
366
365
|
}
|
|
367
366
|
}
|
|
368
367
|
}
|
|
@@ -371,34 +370,34 @@ Cursor IDE uses the same npx approach - no installation needed! Here are the set
|
|
|
371
370
|
|
|
372
371
|
> **Note**: Proxy settings and browser options should be configured when asking Claude to initialize the browser using the `browser_init` tool.
|
|
373
372
|
|
|
374
|
-
#### Platform-Specific
|
|
373
|
+
#### Platform-Specific Brave Paths for Cursor IDE
|
|
375
374
|
|
|
376
|
-
If
|
|
375
|
+
If Brave auto-detection fails, you can specify the Brave path using the `BRAVE_PATH` environment variable:
|
|
377
376
|
|
|
378
377
|
**Windows:**
|
|
379
378
|
```json
|
|
380
379
|
"env": {
|
|
381
|
-
"
|
|
380
|
+
"BRAVE_PATH": "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"
|
|
382
381
|
}
|
|
383
382
|
```
|
|
384
383
|
Alternative Windows paths:
|
|
385
|
-
- `"C:/Program Files (x86)/
|
|
386
|
-
- `"%LOCALAPPDATA%/
|
|
384
|
+
- `"C:/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"`
|
|
385
|
+
- `"%LOCALAPPDATA%/BraveSoftware/Brave-Browser/Application/brave.exe"`
|
|
387
386
|
|
|
388
387
|
**macOS:**
|
|
389
388
|
```json
|
|
390
389
|
"env": {
|
|
391
|
-
"
|
|
390
|
+
"BRAVE_PATH": "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
|
|
392
391
|
}
|
|
393
392
|
```
|
|
394
393
|
|
|
395
394
|
**Linux:**
|
|
396
395
|
```json
|
|
397
396
|
"env": {
|
|
398
|
-
"
|
|
397
|
+
"BRAVE_PATH": "/usr/bin/brave-browser"
|
|
399
398
|
}
|
|
400
399
|
```
|
|
401
|
-
Alternative Linux paths: `/usr/bin/
|
|
400
|
+
Alternative Linux paths: `/usr/bin/brave`, `/snap/bin/brave`
|
|
402
401
|
|
|
403
402
|
|
|
404
403
|
#### Testing Cursor IDE Setup
|
|
@@ -423,9 +422,9 @@ If successful, you should see:
|
|
|
423
422
|
- Ensure Node.js 18+ is installed
|
|
424
423
|
|
|
425
424
|
2. **"Browser failed to launch" on Windows**
|
|
426
|
-
- Add explicit
|
|
425
|
+
- Add explicit Brave path in `executablePath`
|
|
427
426
|
- Try running Cursor IDE as Administrator
|
|
428
|
-
- Check Windows Defender isn't blocking
|
|
427
|
+
- Check Windows Defender isn't blocking Brave
|
|
429
428
|
|
|
430
429
|
3. **"Permission denied"**
|
|
431
430
|
- Use `sudo npm install -g brave-real-browser-mcp-server` on Linux/Mac
|
|
@@ -548,7 +547,7 @@ AI: I'll set up the browser with your proxy configuration.
|
|
|
548
547
|
The server includes intelligent element discovery capabilities through the `find_selector` tool:
|
|
549
548
|
|
|
550
549
|
- **Text-based element finding**: Automatically locates elements containing specific text
|
|
551
|
-
- **Smart CSS selector generation**: Creates unique, robust CSS selectors similar to
|
|
550
|
+
- **Smart CSS selector generation**: Creates unique, robust CSS selectors similar to browser DevTools
|
|
552
551
|
- **Element type filtering**: Optionally restrict search to specific HTML elements (e.g., buttons, links)
|
|
553
552
|
- **Exact or partial text matching**: Choose between precise text matching or substring searches
|
|
554
553
|
- **Universal compatibility**: Works across any website without hardcoded selectors
|
|
@@ -586,27 +585,27 @@ brave-real-browser implementation.
|
|
|
586
585
|
|
|
587
586
|
## Configuration
|
|
588
587
|
|
|
589
|
-
### Automatic
|
|
588
|
+
### Automatic Brave Path Detection
|
|
590
589
|
|
|
591
|
-
The server automatically detects
|
|
590
|
+
The server automatically detects Brave Browser installation paths across different operating systems:
|
|
592
591
|
|
|
593
|
-
- **Windows
|
|
594
|
-
- Registry-based detection for installed
|
|
595
|
-
- Searches
|
|
596
|
-
- Support for
|
|
597
|
-
- Environment variable detection (`
|
|
598
|
-
- Detailed troubleshooting guidance when
|
|
592
|
+
- **Windows**:
|
|
593
|
+
- Registry-based detection for installed Brave versions
|
|
594
|
+
- Searches 13+ common installation directories including Program Files, user-specific locations, and portable installations
|
|
595
|
+
- Support for Brave Nightly fallback
|
|
596
|
+
- Environment variable detection (`BRAVE_PATH`)
|
|
597
|
+
- Detailed troubleshooting guidance when Brave is not found
|
|
599
598
|
|
|
600
|
-
- **macOS**: Looks for
|
|
599
|
+
- **macOS**: Looks for Brave in `/Applications/Brave Browser.app/` and Brave Nightly locations
|
|
601
600
|
|
|
602
|
-
- **Linux**: Checks multiple locations including `/usr/bin/
|
|
601
|
+
- **Linux**: Checks multiple locations including `/usr/bin/brave-browser`, `/usr/bin/brave`, and snap installations
|
|
603
602
|
|
|
604
|
-
**Windows Registry Detection
|
|
605
|
-
The server
|
|
603
|
+
**Windows Registry Detection**:
|
|
604
|
+
The server queries Windows Registry to find Brave installations, making detection more reliable across different installation types.
|
|
606
605
|
|
|
607
|
-
If
|
|
608
|
-
1. Environment variable: `set
|
|
609
|
-
2. Browser init option: `customConfig.
|
|
606
|
+
If Brave is not found automatically, you can specify a custom path using:
|
|
607
|
+
1. Environment variable: `set BRAVE_PATH="C:\Your\Brave\Path\brave.exe"`
|
|
608
|
+
2. Browser init option: `customConfig.bravePath` when initializing the browser
|
|
610
609
|
|
|
611
610
|
### Configuring Custom Options (like headless mode)
|
|
612
611
|
Custom options like headless mode are **not configured in the MCP config file**. Instead, they're passed when initializing the browser using the `browser_init` tool:
|
|
@@ -633,7 +632,7 @@ When initializing with `browser_init`, you can configure:
|
|
|
633
632
|
|
|
634
633
|
- `headless`: true/false (Set to true for headless operation)
|
|
635
634
|
- `disableXvfb`: true/false (Disable X Virtual Framebuffer)
|
|
636
|
-
- `ignoreAllFlags`: true/false (Ignore all
|
|
635
|
+
- `ignoreAllFlags`: true/false (Ignore all browser flags)
|
|
637
636
|
- `proxy`: "https://proxy:8080" (Proxy server URL)
|
|
638
637
|
- `plugins`: ["plugin1", "plugin2"] (Array of plugins to load)
|
|
639
638
|
- `connectOption`: Additional connection options like:
|
|
@@ -662,11 +661,11 @@ When initializing the browser with `browser_init`, you can configure:
|
|
|
662
661
|
|
|
663
662
|
### Advanced Configuration Examples
|
|
664
663
|
|
|
665
|
-
#### Specifying Custom
|
|
664
|
+
#### Specifying Custom Brave Path
|
|
666
665
|
```json
|
|
667
666
|
{
|
|
668
667
|
"customConfig": {
|
|
669
|
-
"
|
|
668
|
+
"bravePath": "C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe"
|
|
670
669
|
}
|
|
671
670
|
}
|
|
672
671
|
```
|
|
@@ -709,14 +708,14 @@ For advanced users, you can modify the server behavior by editing the source cod
|
|
|
709
708
|
|
|
710
709
|
Version 1.3.0 includes comprehensive fixes for the `connect ECONNREFUSED 127.0.0.1:60725` error commonly experienced on Windows systems:
|
|
711
710
|
|
|
712
|
-
**Enhanced
|
|
713
|
-
- Added Windows Registry-based
|
|
714
|
-
- Expanded search to
|
|
715
|
-
- Added support for
|
|
716
|
-
- Environment variable support (`
|
|
711
|
+
**Enhanced Brave Path Detection:**
|
|
712
|
+
- Added Windows Registry-based Brave detection
|
|
713
|
+
- Expanded search to 13+ Windows installation locations including portable installations
|
|
714
|
+
- Added support for Brave Nightly fallback
|
|
715
|
+
- Environment variable support (`BRAVE_PATH`)
|
|
717
716
|
|
|
718
717
|
**Windows-Specific Launch Optimizations:**
|
|
719
|
-
- 20+ Windows-specific
|
|
718
|
+
- 20+ Windows-specific browser flags for better compatibility
|
|
720
719
|
- Multiple fallback strategies (5 different connection approaches)
|
|
721
720
|
- Progressive retry logic with exponential backoff
|
|
722
721
|
- Enhanced timeout handling (120s for Windows vs 90s for other platforms)
|
|
@@ -731,12 +730,12 @@ Version 1.3.0 includes comprehensive fixes for the `connect ECONNREFUSED 127.0.0
|
|
|
731
730
|
|
|
732
731
|
1. **Environment Variables (Recommended):**
|
|
733
732
|
```bash
|
|
734
|
-
set
|
|
733
|
+
set BRAVE_PATH="C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe"
|
|
735
734
|
```
|
|
736
735
|
|
|
737
|
-
2. **Manual
|
|
736
|
+
2. **Manual Brave Path Configuration:**
|
|
738
737
|
```text
|
|
739
|
-
Ask Claude: "Initialize browser with custom
|
|
738
|
+
Ask Claude: "Initialize browser with custom Brave path at C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe"
|
|
740
739
|
```
|
|
741
740
|
|
|
742
741
|
3. **Network Troubleshooting:**
|
|
@@ -750,10 +749,10 @@ Version 1.3.0 includes comprehensive fixes for the `connect ECONNREFUSED 127.0.0
|
|
|
750
749
|
# Ensure: 127.0.0.1 localhost
|
|
751
750
|
```
|
|
752
751
|
|
|
753
|
-
4. **
|
|
752
|
+
4. **Brave Process Management:**
|
|
754
753
|
```bash
|
|
755
|
-
# Kill existing
|
|
756
|
-
taskkill /f /im
|
|
754
|
+
# Kill existing Brave processes
|
|
755
|
+
taskkill /f /im brave.exe
|
|
757
756
|
```
|
|
758
757
|
|
|
759
758
|
### Common Issues
|
|
@@ -812,20 +811,20 @@ Version 1.3.0 includes comprehensive fixes for the `connect ECONNREFUSED 127.0.0
|
|
|
812
811
|
- Check your PATH includes npm global binaries: `npm config get prefix`
|
|
813
812
|
|
|
814
813
|
3. **Browser won't start**
|
|
815
|
-
- Check if
|
|
814
|
+
- Check if Brave Browser is installed in standard locations
|
|
816
815
|
- **Windows specific troubleshooting**:
|
|
817
816
|
|
|
818
|
-
**Step 1: Verify
|
|
817
|
+
**Step 1: Verify Brave Installation Paths**
|
|
819
818
|
Check these locations in order:
|
|
820
|
-
- `C:\Program Files\
|
|
821
|
-
- `C:\Program Files (x86)\
|
|
822
|
-
- `%LOCALAPPDATA%\
|
|
823
|
-
- `%PROGRAMFILES%\
|
|
819
|
+
- `C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe`
|
|
820
|
+
- `C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application\brave.exe`
|
|
821
|
+
- `%LOCALAPPDATA%\BraveSoftware\Brave-Browser\Application\brave.exe`
|
|
822
|
+
- `%PROGRAMFILES%\BraveSoftware\Brave-Browser\Application\brave.exe`
|
|
824
823
|
|
|
825
824
|
**Step 2: Manual Path Configuration**
|
|
826
|
-
If
|
|
825
|
+
If Brave is in a different location, specify it manually:
|
|
827
826
|
```
|
|
828
|
-
Ask Claude: "Initialize browser with custom
|
|
827
|
+
Ask Claude: "Initialize browser with custom Brave path at C:\Your\Brave\Path\brave.exe"
|
|
829
828
|
```
|
|
830
829
|
|
|
831
830
|
**Step 3: Windows Launch Arguments**
|
|
@@ -836,15 +835,15 @@ Version 1.3.0 includes comprehensive fixes for the `connect ECONNREFUSED 127.0.0
|
|
|
836
835
|
|
|
837
836
|
**Step 4: Windows-Specific Solutions**
|
|
838
837
|
- **Run as Administrator**: Try running your IDE/terminal as Administrator
|
|
839
|
-
- **Windows Defender**: Add
|
|
840
|
-
- **Antivirus Software**: Temporarily disable antivirus to test if it's blocking
|
|
838
|
+
- **Windows Defender**: Add Brave and Node.js to Windows Defender exclusions
|
|
839
|
+
- **Antivirus Software**: Temporarily disable antivirus to test if it's blocking Brave
|
|
841
840
|
- **User Account Control**: Lower UAC settings temporarily for testing
|
|
842
|
-
- **
|
|
841
|
+
- **Brave Processes**: Kill any existing Brave processes in Task Manager
|
|
843
842
|
|
|
844
|
-
**Step 5: Alternative
|
|
845
|
-
If
|
|
846
|
-
- Download
|
|
847
|
-
- Install to default location (`C:\Program Files\
|
|
843
|
+
**Step 5: Alternative Brave Installation**
|
|
844
|
+
If Brave detection still fails:
|
|
845
|
+
- Download Brave directly from [brave.com/download](https://brave.com/download/)
|
|
846
|
+
- Install to default location (`C:\Program Files\BraveSoftware\Brave-Browser\`)
|
|
848
847
|
- Restart your IDE after installation
|
|
849
848
|
|
|
850
849
|
**Step 6: PowerShell vs Command Prompt**
|
|
@@ -857,10 +856,10 @@ Version 1.3.0 includes comprehensive fixes for the `connect ECONNREFUSED 127.0.0
|
|
|
857
856
|
- Clear npm cache: `npm cache clean --force`
|
|
858
857
|
- Reinstall global packages: `npm install -g brave-real-browser-mcp-server@latest`
|
|
859
858
|
|
|
860
|
-
- **Linux**: Install
|
|
861
|
-
- **macOS**: Ensure
|
|
859
|
+
- **Linux**: Install Brave: `sudo apt install brave-browser`
|
|
860
|
+
- **macOS**: Ensure Brave is in `/Applications/Brave Browser.app`
|
|
862
861
|
- Try with `headless: true` first
|
|
863
|
-
- Check console output for
|
|
862
|
+
- Check console output for Brave path detection messages
|
|
864
863
|
|
|
865
864
|
4. **Claude doesn't see the MCP server**
|
|
866
865
|
- Verify `claude_desktop_config.json` is in the correct location
|
|
@@ -886,7 +885,7 @@ Version 1.3.0 includes comprehensive fixes for the `connect ECONNREFUSED 127.0.0
|
|
|
886
885
|
- Check if server status shows "connected" or error messages
|
|
887
886
|
|
|
888
887
|
- **Environment Variables**:
|
|
889
|
-
- If using custom environment variables (
|
|
888
|
+
- If using custom environment variables (Brave path, proxy), verify they're correctly set
|
|
890
889
|
- Test without environment variables first: `claude mcp add brave-real-browser -- npx brave-real-browser-mcp-server@latest`
|
|
891
890
|
|
|
892
891
|
- **Node.js and npx Issues**:
|
|
@@ -917,7 +916,7 @@ Version 1.3.0 includes comprehensive fixes for the `connect ECONNREFUSED 127.0.0
|
|
|
917
916
|
- **JSON Syntax Validation**:
|
|
918
917
|
- Use [jsonlint.com](https://jsonlint.com/) to validate JSON syntax
|
|
919
918
|
- Common issues: missing commas, incorrect quotes, trailing commas
|
|
920
|
-
- Ensure proper escaping of Windows paths: `"C:/Program Files/
|
|
919
|
+
- Ensure proper escaping of Windows paths: `"C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"`
|
|
921
920
|
|
|
922
921
|
- **Cursor IDE Restart Process**:
|
|
923
922
|
- Close Cursor IDE completely (check Task Manager on Windows)
|
|
@@ -1009,11 +1008,11 @@ A: Supports reCAPTCHA, hCaptcha, and Cloudflare Turnstile through brave-real-bro
|
|
|
1009
1008
|
**Q: Is this detectable by websites?**
|
|
1010
1009
|
A: brave-real-browser includes anti-detection features, but no solution is 100% undetectable.
|
|
1011
1010
|
|
|
1012
|
-
**Q: Can I use custom
|
|
1011
|
+
**Q: Can I use custom browser extensions?**
|
|
1013
1012
|
A: Yes, through the `plugins` option in browser_init.
|
|
1014
1013
|
|
|
1015
1014
|
**Q: Does it work on all operating systems?**
|
|
1016
|
-
A: Yes, tested on Windows, macOS, and Linux. The server automatically detects
|
|
1015
|
+
A: Yes, tested on Windows, macOS, and Linux. The server automatically detects Brave installations on all platforms.
|
|
1017
1016
|
|
|
1018
1017
|
**Q: What's the difference between Claude Desktop, Claude Code CLI, and Cursor IDE configurations?**
|
|
1019
1018
|
A: Here's a comparison:
|
|
@@ -1034,30 +1033,30 @@ A: Here's a comparison:
|
|
|
1034
1033
|
- **Claude Code CLI**: `claude mcp add brave-real-browser -- npx brave-real-browser-mcp-server@latest`
|
|
1035
1034
|
- **Cursor IDE**: One-click install or manual JSON config
|
|
1036
1035
|
|
|
1037
|
-
**Q: What if
|
|
1038
|
-
A:
|
|
1039
|
-
1. Set environment variable: `set
|
|
1040
|
-
2. Use the `customConfig.
|
|
1041
|
-
|
|
1042
|
-
**Q: Why am I getting "
|
|
1043
|
-
A:
|
|
1044
|
-
- `C:\Program Files\
|
|
1045
|
-
- `C:\Program Files (x86)\
|
|
1046
|
-
- `%LOCALAPPDATA%\
|
|
1047
|
-
- `%USERPROFILE%\AppData\Local\
|
|
1048
|
-
-
|
|
1049
|
-
- Portable
|
|
1036
|
+
**Q: What if Brave is installed in a non-standard location?**
|
|
1037
|
+
A: The server dramatically improves Brave detection by searching 13+ locations including portable installations and using Windows Registry detection. If Brave is still not found automatically, you can:
|
|
1038
|
+
1. Set environment variable: `set BRAVE_PATH="C:\Your\Brave\Path\brave.exe"`
|
|
1039
|
+
2. Use the `customConfig.bravePath` option: `{"customConfig": {"bravePath": "C:\\Custom\\Brave\\brave.exe"}}`
|
|
1040
|
+
|
|
1041
|
+
**Q: Why am I getting "Brave not found" or ECONNREFUSED errors on Windows?**
|
|
1042
|
+
A: The server includes comprehensive fixes for Windows Brave detection and connection issues. The server now automatically searches these locations and more:
|
|
1043
|
+
- `C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe`
|
|
1044
|
+
- `C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application\brave.exe`
|
|
1045
|
+
- `%LOCALAPPDATA%\BraveSoftware\Brave-Browser\Application\brave.exe`
|
|
1046
|
+
- `%USERPROFILE%\AppData\Local\BraveSoftware\Brave-Browser\Application\brave.exe`
|
|
1047
|
+
- Brave Nightly installations
|
|
1048
|
+
- Portable Brave installations
|
|
1050
1049
|
- Registry-detected installations
|
|
1051
1050
|
|
|
1052
|
-
The server also implements multiple connection strategies with automatic fallback between localhost and 127.0.0.1, plus enhanced Windows-specific
|
|
1051
|
+
The server also implements multiple connection strategies with automatic fallback between localhost and 127.0.0.1, plus enhanced Windows-specific browser flags for better compatibility.
|
|
1053
1052
|
|
|
1054
|
-
**Q: I'm still getting ECONNREFUSED errors
|
|
1053
|
+
**Q: I'm still getting ECONNREFUSED errors. What should I do?**
|
|
1055
1054
|
A: Try these steps in order:
|
|
1056
|
-
1. Set the `
|
|
1057
|
-
2. Kill all existing
|
|
1055
|
+
1. Set the `BRAVE_PATH` environment variable to your Brave location
|
|
1056
|
+
2. Kill all existing Brave processes: `taskkill /f /im brave.exe`
|
|
1058
1057
|
3. Check your Windows hosts file contains: `127.0.0.1 localhost`
|
|
1059
1058
|
4. Try running your IDE as Administrator
|
|
1060
|
-
5. Add
|
|
1059
|
+
5. Add Brave to Windows Defender exclusions
|
|
1061
1060
|
6. If using a VPN/proxy, try disabling it temporarily
|
|
1062
1061
|
|
|
1063
1062
|
### Debug Mode
|
|
@@ -1156,7 +1155,7 @@ npm run test:debug # Environment diagnostics and troubleshooting
|
|
|
1156
1155
|
|
|
1157
1156
|
Debug tools provide:
|
|
1158
1157
|
- Environment validation (Node.js version, platform, memory)
|
|
1159
|
-
-
|
|
1158
|
+
- Brave installation detection with specific paths
|
|
1160
1159
|
- Quick server health check with startup timing
|
|
1161
1160
|
- Network connectivity validation
|
|
1162
1161
|
- Build status verification
|
package/dist/browser-manager.js
CHANGED
|
@@ -165,28 +165,28 @@ export function isCircuitBreakerOpen() {
|
|
|
165
165
|
}
|
|
166
166
|
return false;
|
|
167
167
|
}
|
|
168
|
-
// Windows Registry
|
|
169
|
-
function
|
|
168
|
+
// Windows Registry Brave detection
|
|
169
|
+
function getWindowsBraveFromRegistry() {
|
|
170
170
|
if (process.platform !== 'win32')
|
|
171
171
|
return null;
|
|
172
172
|
try {
|
|
173
173
|
const { execSync } = require('child_process');
|
|
174
174
|
const registryQueries = [
|
|
175
|
-
'reg query "HKEY_CURRENT_USER\\Software\\
|
|
176
|
-
'reg query "HKEY_LOCAL_MACHINE\\Software\\
|
|
177
|
-
'reg query "HKEY_LOCAL_MACHINE\\Software\\WOW6432Node\\
|
|
175
|
+
'reg query "HKEY_CURRENT_USER\\Software\\BraveSoftware\\Brave-Browser\\BLBeacon" /v version 2>nul',
|
|
176
|
+
'reg query "HKEY_LOCAL_MACHINE\\Software\\BraveSoftware\\Brave-Browser\\BLBeacon" /v version 2>nul',
|
|
177
|
+
'reg query "HKEY_LOCAL_MACHINE\\Software\\WOW6432Node\\BraveSoftware\\Brave-Browser\\BLBeacon" /v version 2>nul',
|
|
178
178
|
];
|
|
179
179
|
for (const query of registryQueries) {
|
|
180
180
|
try {
|
|
181
181
|
const result = execSync(query, { encoding: 'utf8', timeout: 5000 });
|
|
182
182
|
if (result) {
|
|
183
183
|
const standardPaths = [
|
|
184
|
-
'C:\\Program Files\\
|
|
185
|
-
'C:\\Program Files (x86)\\
|
|
184
|
+
'C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe',
|
|
185
|
+
'C:\\Program Files (x86)\\BraveSoftware\\Brave-Browser\\Application\\brave.exe'
|
|
186
186
|
];
|
|
187
187
|
for (const standardPath of standardPaths) {
|
|
188
188
|
if (fs.existsSync(standardPath)) {
|
|
189
|
-
console.error(`✓ Found
|
|
189
|
+
console.error(`✓ Found Brave via Registry detection: ${standardPath}`);
|
|
190
190
|
return standardPath;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -197,11 +197,11 @@ function getWindowsChromeFromRegistry() {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
try {
|
|
200
|
-
const installDirQuery = 'reg query "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\
|
|
200
|
+
const installDirQuery = 'reg query "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\brave.exe" /ve 2>nul';
|
|
201
201
|
const result = execSync(installDirQuery, { encoding: 'utf8', timeout: 5000 });
|
|
202
202
|
const match = result.match(/REG_SZ\s+(.+\.exe)/);
|
|
203
203
|
if (match && match[1] && fs.existsSync(match[1])) {
|
|
204
|
-
console.error(`✓ Found
|
|
204
|
+
console.error(`✓ Found Brave via App Paths registry: ${match[1]}`);
|
|
205
205
|
return match[1];
|
|
206
206
|
}
|
|
207
207
|
}
|
|
@@ -210,39 +210,35 @@ function getWindowsChromeFromRegistry() {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
catch (error) {
|
|
213
|
-
console.error('Windows Registry
|
|
213
|
+
console.error('Windows Registry Brave detection failed:', error instanceof Error ? error.message : String(error));
|
|
214
214
|
}
|
|
215
215
|
return null;
|
|
216
216
|
}
|
|
217
|
-
//
|
|
218
|
-
export function
|
|
217
|
+
// Brave path detection for cross-platform support with enhanced Windows support
|
|
218
|
+
export function detectBravePath() {
|
|
219
219
|
const platform = process.platform;
|
|
220
220
|
// Check environment variables first
|
|
221
|
-
const
|
|
222
|
-
if (
|
|
223
|
-
console.error(`✓ Found
|
|
224
|
-
return
|
|
221
|
+
const envBravePath = process.env.BRAVE_PATH || process.env.PUPPETEER_EXECUTABLE_PATH;
|
|
222
|
+
if (envBravePath && fs.existsSync(envBravePath)) {
|
|
223
|
+
console.error(`✓ Found Brave via environment variable: ${envBravePath}`);
|
|
224
|
+
return envBravePath;
|
|
225
225
|
}
|
|
226
226
|
let possiblePaths = [];
|
|
227
227
|
switch (platform) {
|
|
228
228
|
case 'win32':
|
|
229
229
|
possiblePaths = [
|
|
230
|
-
'C:\\Program Files\\
|
|
231
|
-
'C:\\Program Files (x86)\\
|
|
232
|
-
path.join(process.env.LOCALAPPDATA || '', '
|
|
233
|
-
path.join(process.env.USERPROFILE || '', 'AppData\\Local\\
|
|
234
|
-
path.join(process.env.PROGRAMFILES || '', '
|
|
235
|
-
path.join(process.env['PROGRAMFILES(X86)'] || '', '
|
|
236
|
-
|
|
237
|
-
'C:\\
|
|
238
|
-
'C:\\
|
|
239
|
-
path.join(process.env.APPDATA || '', 'Google\\Chrome\\Application\\chrome.exe'),
|
|
240
|
-
'C:\\Chrome\\chrome.exe',
|
|
241
|
-
'C:\\google\\chrome\\chrome.exe',
|
|
242
|
-
'C:\\PortableApps\\GoogleChromePortable\\App\\Chrome-bin\\chrome.exe',
|
|
230
|
+
'C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe',
|
|
231
|
+
'C:\\Program Files (x86)\\BraveSoftware\\Brave-Browser\\Application\\brave.exe',
|
|
232
|
+
path.join(process.env.LOCALAPPDATA || '', 'BraveSoftware\\Brave-Browser\\Application\\brave.exe'),
|
|
233
|
+
path.join(process.env.USERPROFILE || '', 'AppData\\Local\\BraveSoftware\\Brave-Browser\\Application\\brave.exe'),
|
|
234
|
+
path.join(process.env.PROGRAMFILES || '', 'BraveSoftware\\Brave-Browser\\Application\\brave.exe'),
|
|
235
|
+
path.join(process.env['PROGRAMFILES(X86)'] || '', 'BraveSoftware\\Brave-Browser\\Application\\brave.exe'),
|
|
236
|
+
'C:\\Users\\Public\\Desktop\\Brave Browser.lnk',
|
|
237
|
+
'C:\\Brave\\brave.exe',
|
|
238
|
+
'C:\\portable\\Brave\\brave.exe',
|
|
243
239
|
];
|
|
244
240
|
try {
|
|
245
|
-
const registryPath =
|
|
241
|
+
const registryPath = getWindowsBraveFromRegistry();
|
|
246
242
|
if (registryPath) {
|
|
247
243
|
possiblePaths.unshift(registryPath);
|
|
248
244
|
}
|
|
@@ -253,31 +249,28 @@ export function detectChromePath() {
|
|
|
253
249
|
break;
|
|
254
250
|
case 'darwin':
|
|
255
251
|
possiblePaths = [
|
|
256
|
-
'/Applications/
|
|
257
|
-
'/Applications/
|
|
258
|
-
'/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary'
|
|
252
|
+
'/Applications/Brave Browser.app/Contents/MacOS/Brave Browser',
|
|
253
|
+
'/Applications/Brave Browser Nightly.app/Contents/MacOS/Brave Browser Nightly',
|
|
259
254
|
];
|
|
260
255
|
break;
|
|
261
256
|
case 'linux':
|
|
262
257
|
possiblePaths = [
|
|
263
|
-
'/usr/bin/
|
|
264
|
-
'/usr/bin/
|
|
265
|
-
'/
|
|
266
|
-
'/
|
|
267
|
-
'/
|
|
268
|
-
'/usr/bin/chrome',
|
|
269
|
-
'/opt/google/chrome/chrome'
|
|
258
|
+
'/usr/bin/brave-browser',
|
|
259
|
+
'/usr/bin/brave',
|
|
260
|
+
'/snap/bin/brave',
|
|
261
|
+
'/var/lib/snapd/snap/bin/brave',
|
|
262
|
+
'/opt/brave.com/brave/brave',
|
|
270
263
|
];
|
|
271
264
|
break;
|
|
272
265
|
default:
|
|
273
|
-
console.error(`Platform ${platform} not explicitly supported for
|
|
266
|
+
console.error(`Platform ${platform} not explicitly supported for Brave path detection`);
|
|
274
267
|
return null;
|
|
275
268
|
}
|
|
276
|
-
for (const
|
|
269
|
+
for (const bravePath of possiblePaths) {
|
|
277
270
|
try {
|
|
278
|
-
if (fs.existsSync(
|
|
279
|
-
console.error(`✓ Found
|
|
280
|
-
return
|
|
271
|
+
if (fs.existsSync(bravePath)) {
|
|
272
|
+
console.error(`✓ Found Brave at: ${bravePath}`);
|
|
273
|
+
return bravePath;
|
|
281
274
|
}
|
|
282
275
|
}
|
|
283
276
|
catch (error) {
|
|
@@ -285,7 +278,7 @@ export function detectChromePath() {
|
|
|
285
278
|
}
|
|
286
279
|
}
|
|
287
280
|
if (platform === 'win32') {
|
|
288
|
-
console.error(`❌
|
|
281
|
+
console.error(`❌ Brave not found at any expected Windows paths:`);
|
|
289
282
|
console.error(` Searched ${possiblePaths.length} locations:`);
|
|
290
283
|
possiblePaths.slice(0, 8).forEach(path => console.error(` - ${path}`));
|
|
291
284
|
if (possiblePaths.length > 8) {
|
|
@@ -293,23 +286,23 @@ export function detectChromePath() {
|
|
|
293
286
|
}
|
|
294
287
|
console.error(`\n 🔧 Windows Troubleshooting Solutions:`);
|
|
295
288
|
console.error(` 1. Environment Variables (Recommended):`);
|
|
296
|
-
console.error(` - Set
|
|
297
|
-
console.error(` - Example: set
|
|
289
|
+
console.error(` - Set BRAVE_PATH environment variable to your Brave location`);
|
|
290
|
+
console.error(` - Example: set BRAVE_PATH=\"C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe\"`);
|
|
298
291
|
console.error(` - For Cursor IDE: Add env vars to MCP configuration`);
|
|
299
|
-
console.error(`\n 2.
|
|
300
|
-
console.error(` - Download/reinstall
|
|
301
|
-
console.error(` - Check if
|
|
302
|
-
console.error(` - Try
|
|
292
|
+
console.error(`\n 2. Brave Installation:`);
|
|
293
|
+
console.error(` - Download/reinstall Brave: https://brave.com/download/`);
|
|
294
|
+
console.error(` - Check if Brave is installed for all users vs current user only`);
|
|
295
|
+
console.error(` - Try Brave Nightly if regular Brave fails`);
|
|
303
296
|
console.error(`\n 3. Permissions & Security:`);
|
|
304
297
|
console.error(` - Run IDE/terminal as Administrator`);
|
|
305
|
-
console.error(` - Add
|
|
306
|
-
console.error(` - Check if antivirus software is blocking
|
|
298
|
+
console.error(` - Add Brave to Windows Defender exclusions`);
|
|
299
|
+
console.error(` - Check if antivirus software is blocking Brave`);
|
|
307
300
|
console.error(`\n 4. Custom Configuration:`);
|
|
308
|
-
console.error(` - Use customConfig.
|
|
309
|
-
console.error(` - Example: {"customConfig": {"
|
|
301
|
+
console.error(` - Use customConfig.bravePath parameter in browser_init`);
|
|
302
|
+
console.error(` - Example: {\"customConfig\": {\"bravePath\": \"C:\\\\\\custom\\\\\\path\\\\\\brave.exe\"}}`);
|
|
310
303
|
}
|
|
311
304
|
else {
|
|
312
|
-
console.error(`❌
|
|
305
|
+
console.error(`❌ Brave not found at any expected paths for platform: ${platform}`);
|
|
313
306
|
console.error(` Searched locations:`);
|
|
314
307
|
possiblePaths.forEach(path => console.error(` - ${path}`));
|
|
315
308
|
}
|
|
@@ -396,10 +389,10 @@ export async function initializeBrowser(options) {
|
|
|
396
389
|
await closeBrowser();
|
|
397
390
|
}
|
|
398
391
|
}
|
|
399
|
-
const
|
|
392
|
+
const detectedBravePath = detectBravePath();
|
|
400
393
|
const customConfig = options?.customConfig ?? {};
|
|
401
394
|
const platform = process.platform;
|
|
402
|
-
const
|
|
395
|
+
const getOptimalBrowserFlags = (isWindows, isRetry = false) => {
|
|
403
396
|
// 2025 best practices: Minimal, secure, performance-focused flags
|
|
404
397
|
const baseFlags = [
|
|
405
398
|
'--no-first-run',
|
|
@@ -426,16 +419,16 @@ export async function initializeBrowser(options) {
|
|
|
426
419
|
// When ignoreAllFlags=true, brave-real-browser skips DEFAULT_FLAGS modification
|
|
427
420
|
// which causes the analytics popup issue
|
|
428
421
|
const useIgnoreAllFlags = options?.ignoreAllFlags ?? false;
|
|
429
|
-
// Don't pass
|
|
430
|
-
const
|
|
422
|
+
// Don't pass braveFlags in customConfig - let brave-real-browser handle it via ignoreAllFlags=false
|
|
423
|
+
const browserConfig = {
|
|
431
424
|
...customConfig
|
|
432
425
|
};
|
|
433
|
-
if (
|
|
434
|
-
|
|
426
|
+
if (detectedBravePath && !browserConfig.bravePath) {
|
|
427
|
+
browserConfig.bravePath = detectedBravePath;
|
|
435
428
|
}
|
|
436
429
|
const connectOptions = {
|
|
437
430
|
headless: options?.headless ?? false,
|
|
438
|
-
customConfig:
|
|
431
|
+
customConfig: browserConfig,
|
|
439
432
|
turnstile: true,
|
|
440
433
|
disableXvfb: options?.disableXvfb ?? true,
|
|
441
434
|
// CRITICAL: Must be false by default to allow brave-real-browser to modify flags
|
|
@@ -448,7 +441,8 @@ export async function initializeBrowser(options) {
|
|
|
448
441
|
},
|
|
449
442
|
};
|
|
450
443
|
if (options?.proxy) {
|
|
451
|
-
connectOptions.customConfig.
|
|
444
|
+
connectOptions.customConfig.braveFlags = connectOptions.customConfig.braveFlags || [];
|
|
445
|
+
connectOptions.customConfig.braveFlags.push(`--proxy-server=${options.proxy}`);
|
|
452
446
|
}
|
|
453
447
|
if (options?.plugins && Array.isArray(options.plugins)) {
|
|
454
448
|
connectOptions.plugins = options.plugins;
|
|
@@ -470,10 +464,10 @@ export async function initializeBrowser(options) {
|
|
|
470
464
|
...connectOptions,
|
|
471
465
|
...modifications,
|
|
472
466
|
customConfig: {
|
|
473
|
-
...
|
|
467
|
+
...browserConfig,
|
|
474
468
|
...modifications.customConfig,
|
|
475
|
-
|
|
476
|
-
...(modifications.customConfig?.
|
|
469
|
+
braveFlags: [
|
|
470
|
+
...(modifications.customConfig?.braveFlags || browserConfig.braveFlags || []),
|
|
477
471
|
...(availablePort ? [`--remote-debugging-port=${availablePort}`] : ['--remote-debugging-port=0'])
|
|
478
472
|
]
|
|
479
473
|
}
|
|
@@ -484,7 +478,7 @@ export async function initializeBrowser(options) {
|
|
|
484
478
|
const primaryStrategy = {
|
|
485
479
|
strategyName: 'User-Defined Configuration',
|
|
486
480
|
strategy: {
|
|
487
|
-
executablePath:
|
|
481
|
+
executablePath: detectedBravePath,
|
|
488
482
|
headless: options?.headless ?? false,
|
|
489
483
|
turnstile: true,
|
|
490
484
|
args: [
|
|
@@ -493,7 +487,7 @@ export async function initializeBrowser(options) {
|
|
|
493
487
|
disableXvfb: true,
|
|
494
488
|
// CRITICAL: Must be false to allow brave-real-browser to process DEFAULT_FLAGS
|
|
495
489
|
ignoreAllFlags: false,
|
|
496
|
-
customConfig:
|
|
490
|
+
customConfig: browserConfig,
|
|
497
491
|
connectOption: {
|
|
498
492
|
defaultViewport: null,
|
|
499
493
|
},
|
|
@@ -505,7 +499,7 @@ export async function initializeBrowser(options) {
|
|
|
505
499
|
createConnectionStrategy('Minimal Configuration', {
|
|
506
500
|
customConfig: {
|
|
507
501
|
ignoreDefaultFlags: false,
|
|
508
|
-
|
|
502
|
+
braveFlags: [
|
|
509
503
|
'--no-first-run',
|
|
510
504
|
'--no-default-browser-check',
|
|
511
505
|
'--disable-default-apps',
|
|
@@ -517,7 +511,7 @@ export async function initializeBrowser(options) {
|
|
|
517
511
|
createConnectionStrategy('Optimal Configuration', {
|
|
518
512
|
customConfig: {
|
|
519
513
|
ignoreDefaultFlags: false,
|
|
520
|
-
|
|
514
|
+
braveFlags: [
|
|
521
515
|
'--no-first-run',
|
|
522
516
|
'--no-default-browser-check',
|
|
523
517
|
'--disable-default-apps',
|
|
@@ -529,7 +523,7 @@ export async function initializeBrowser(options) {
|
|
|
529
523
|
createConnectionStrategy('Network Fallback', {
|
|
530
524
|
customConfig: {
|
|
531
525
|
ignoreDefaultFlags: false,
|
|
532
|
-
|
|
526
|
+
braveFlags: [
|
|
533
527
|
'--no-first-run',
|
|
534
528
|
'--no-default-browser-check',
|
|
535
529
|
'--disable-default-apps',
|
|
@@ -552,8 +546,8 @@ export async function initializeBrowser(options) {
|
|
|
552
546
|
console.error(` Strategy config: ${JSON.stringify({
|
|
553
547
|
headless: strategy.headless,
|
|
554
548
|
ignoreAllFlags: strategy.ignoreAllFlags,
|
|
555
|
-
|
|
556
|
-
|
|
549
|
+
braveFlags: strategy.customConfig?.braveFlags || 'none',
|
|
550
|
+
bravePath: strategy.customConfig?.bravePath || 'default'
|
|
557
551
|
})}`);
|
|
558
552
|
const connectResult = await connect(strategy);
|
|
559
553
|
console.error(` ✅ Connection successful with ${strategyName}`);
|
|
@@ -569,8 +563,8 @@ export async function initializeBrowser(options) {
|
|
|
569
563
|
...strategy,
|
|
570
564
|
customConfig: {
|
|
571
565
|
...strategy.customConfig,
|
|
572
|
-
|
|
573
|
-
...strategy.customConfig.
|
|
566
|
+
braveFlags: [
|
|
567
|
+
...(strategy.customConfig.braveFlags || []).filter((flag) => !flag.includes('remote-debugging-address')),
|
|
574
568
|
`--remote-debugging-address=${fallbackHost}`
|
|
575
569
|
]
|
|
576
570
|
}
|
|
@@ -592,13 +586,13 @@ export async function initializeBrowser(options) {
|
|
|
592
586
|
lastError = error instanceof Error ? error : new Error(String(error));
|
|
593
587
|
console.error(`❌ ${strategyName} failed:`, lastError.message);
|
|
594
588
|
if (lastError.message.includes('ECONNREFUSED')) {
|
|
595
|
-
console.error(` 🔍 ECONNREFUSED detected - likely
|
|
589
|
+
console.error(` 🔍 ECONNREFUSED detected - likely Brave connection/port issue`);
|
|
596
590
|
}
|
|
597
591
|
else if (lastError.message.includes('ENOENT') || lastError.message.includes('spawn')) {
|
|
598
|
-
console.error(` 🔍
|
|
592
|
+
console.error(` 🔍 Brave executable issue detected`);
|
|
599
593
|
}
|
|
600
594
|
else if (lastError.message.includes('timeout')) {
|
|
601
|
-
console.error(` 🔍 Connection timeout -
|
|
595
|
+
console.error(` 🔍 Connection timeout - Brave may be slow to start`);
|
|
602
596
|
}
|
|
603
597
|
if (strategyIndex < connectionStrategies.length - 1) {
|
|
604
598
|
const delayMs = 2000 + (strategyIndex * 1000);
|
|
@@ -609,7 +603,7 @@ export async function initializeBrowser(options) {
|
|
|
609
603
|
}
|
|
610
604
|
updateCircuitBreakerOnFailure();
|
|
611
605
|
const errorMessage = lastError ? lastError.message : 'Unknown connection error';
|
|
612
|
-
if (errorMessage.includes('ENOENT') || errorMessage.includes('spawn') || errorMessage.includes('
|
|
606
|
+
if (errorMessage.includes('ENOENT') || errorMessage.includes('spawn') || errorMessage.includes('ECONNREFUSED')) {
|
|
613
607
|
if (platform === 'win32') {
|
|
614
608
|
console.error(`❌ All browser connection strategies failed on Windows:`);
|
|
615
609
|
console.error(` Final Error: ${errorMessage}`);
|
|
@@ -617,34 +611,33 @@ export async function initializeBrowser(options) {
|
|
|
617
611
|
if (errorMessage.includes('ECONNREFUSED')) {
|
|
618
612
|
console.error(`\n 🚨 ECONNREFUSED Error Specific Solutions:`);
|
|
619
613
|
console.error(` 1. Port/Connection Issues:`);
|
|
620
|
-
console.error(` -
|
|
621
|
-
console.error(` - Add
|
|
614
|
+
console.error(` - Browser DevTools Protocol port is being blocked`);
|
|
615
|
+
console.error(` - Add Brave to Windows Firewall exceptions`);
|
|
622
616
|
console.error(` - Check if localhost resolves to 127.0.0.1 (run: ping localhost)`);
|
|
623
|
-
console.error(` - Try different
|
|
617
|
+
console.error(` - Try different browser flags: --remote-debugging-port=0`);
|
|
624
618
|
console.error(`\n 2. Network Configuration:`);
|
|
625
619
|
console.error(` - Disable VPN/proxy temporarily`);
|
|
626
620
|
console.error(` - Check Windows hosts file (C:\\Windows\\System32\\drivers\\etc\\hosts)`);
|
|
627
621
|
console.error(` - Ensure localhost points to 127.0.0.1`);
|
|
628
|
-
console.error(`\n 3.
|
|
629
|
-
console.error(` - Kill all
|
|
630
|
-
console.error(` - Clear
|
|
631
|
-
console.error(` - Try running
|
|
622
|
+
console.error(`\n 3. Browser Process Management:`);
|
|
623
|
+
console.error(` - Kill all brave.exe processes in Task Manager`);
|
|
624
|
+
console.error(` - Clear Brave user data: %LOCALAPPDATA%\\BraveSoftware\\Brave-Browser\\User Data`);
|
|
625
|
+
console.error(` - Try running Brave manually to test: brave.exe --remote-debugging-port=9222`);
|
|
632
626
|
}
|
|
633
627
|
console.error(`\n 🔧 General Solutions:`);
|
|
634
628
|
console.error(` 1. Environment Variables (Recommended):`);
|
|
635
|
-
console.error(` - Set
|
|
636
|
-
console.error(` - Example: set
|
|
637
|
-
console.error(`\n 2.
|
|
638
|
-
console.error(` - Download/reinstall
|
|
639
|
-
console.error(` - Try
|
|
629
|
+
console.error(` - Set BRAVE_PATH environment variable`);
|
|
630
|
+
console.error(` - Example: set BRAVE_PATH="C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe"`);
|
|
631
|
+
console.error(`\n 2. Brave Installation:`);
|
|
632
|
+
console.error(` - Download/reinstall Brave: https://brave.com/download/`);
|
|
633
|
+
console.error(` - Try Brave Nightly: https://brave.com/download-nightly/`);
|
|
640
634
|
console.error(`\n 3. Permissions & Security:`);
|
|
641
635
|
console.error(` - Run as Administrator`);
|
|
642
|
-
console.error(` - Add
|
|
636
|
+
console.error(` - Add Brave to Windows Defender exclusions`);
|
|
643
637
|
console.error(` - Temporarily disable antivirus software`);
|
|
644
638
|
console.error(`\n 4. Advanced Configuration:`);
|
|
645
|
-
console.error(` - Use customConfig.
|
|
639
|
+
console.error(` - Use customConfig.bravePath in browser_init`);
|
|
646
640
|
console.error(` - Try headless mode: {"headless": true}`);
|
|
647
|
-
console.error(` - Use environment variable: PUPPETEER_EXECUTABLE_PATH`);
|
|
648
641
|
}
|
|
649
642
|
else {
|
|
650
643
|
console.error(`❌ Browser launch failed on ${platform}:`);
|
|
@@ -702,21 +695,23 @@ export async function closeBrowser() {
|
|
|
702
695
|
}
|
|
703
696
|
}
|
|
704
697
|
}
|
|
705
|
-
// Force kill all
|
|
706
|
-
export async function
|
|
698
|
+
// Force kill all Brave processes system-wide
|
|
699
|
+
export async function forceKillAllBrowserProcesses() {
|
|
707
700
|
try {
|
|
708
701
|
const { spawn } = await import('child_process');
|
|
709
702
|
if (process.platform !== 'win32') {
|
|
710
|
-
|
|
711
|
-
spawn('pkill', ['-f', '
|
|
703
|
+
// Brave processes
|
|
704
|
+
spawn('pkill', ['-f', 'Brave Browser'], { stdio: 'ignore' });
|
|
705
|
+
spawn('pkill', ['-f', 'brave'], { stdio: 'ignore' });
|
|
712
706
|
}
|
|
713
707
|
else {
|
|
714
|
-
|
|
715
|
-
spawn('taskkill', ['/F', '/IM', '
|
|
708
|
+
// Brave on Windows
|
|
709
|
+
spawn('taskkill', ['/F', '/IM', 'brave.exe'], { stdio: 'ignore' });
|
|
710
|
+
spawn('taskkill', ['/F', '/IM', 'Brave.exe'], { stdio: 'ignore' });
|
|
716
711
|
}
|
|
717
712
|
}
|
|
718
713
|
catch (error) {
|
|
719
|
-
console.error('Error force-killing
|
|
714
|
+
console.error('Error force-killing browser processes:', error);
|
|
720
715
|
}
|
|
721
716
|
}
|
|
722
717
|
// Getters for browser instances
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* - AAA Pattern (Arrange-Act-Assert)
|
|
6
6
|
* - Behavior-focused testing with proper mocking
|
|
7
7
|
* - Error categorization and circuit breaker testing
|
|
8
|
-
* -
|
|
8
|
+
* - Brave detection and network utilities testing
|
|
9
9
|
*/
|
|
10
10
|
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
11
11
|
import * as fs from 'fs';
|
|
12
12
|
import * as net from 'net';
|
|
13
|
-
import { BrowserErrorType, categorizeError, withTimeout, isPortAvailable, testHostConnectivity, findAvailablePort, updateCircuitBreakerOnFailure, updateCircuitBreakerOnSuccess, isCircuitBreakerOpen,
|
|
13
|
+
import { BrowserErrorType, categorizeError, withTimeout, isPortAvailable, testHostConnectivity, findAvailablePort, updateCircuitBreakerOnFailure, updateCircuitBreakerOnSuccess, isCircuitBreakerOpen, detectBravePath, validateSession, findAuthElements, getBrowserInstance, getPageInstance, getContentPriorityConfig, updateContentPriorityConfig, forceKillAllBrowserProcesses } from './browser-manager.js';
|
|
14
14
|
// Mock external dependencies
|
|
15
15
|
vi.mock('fs');
|
|
16
16
|
vi.mock('net');
|
|
@@ -256,58 +256,58 @@ describe('Browser Manager', () => {
|
|
|
256
256
|
Date.now = originalNow;
|
|
257
257
|
});
|
|
258
258
|
});
|
|
259
|
-
describe('
|
|
259
|
+
describe('Brave Path Detection', () => {
|
|
260
260
|
it('should return environment variable path when available', () => {
|
|
261
261
|
// Arrange: Set environment variable and mock file exists
|
|
262
|
-
const
|
|
263
|
-
process.env.
|
|
262
|
+
const bravePath = '/custom/brave/path';
|
|
263
|
+
process.env.BRAVE_PATH = bravePath;
|
|
264
264
|
vi.mocked(fs.existsSync).mockReturnValue(true);
|
|
265
|
-
// Act: Detect
|
|
266
|
-
const result =
|
|
265
|
+
// Act: Detect Brave path
|
|
266
|
+
const result = detectBravePath();
|
|
267
267
|
// Assert: Should return environment path
|
|
268
|
-
expect(result).toBe(
|
|
269
|
-
expect(fs.existsSync).toHaveBeenCalledWith(
|
|
268
|
+
expect(result).toBe(bravePath);
|
|
269
|
+
expect(fs.existsSync).toHaveBeenCalledWith(bravePath);
|
|
270
270
|
// Cleanup
|
|
271
|
-
delete process.env.
|
|
271
|
+
delete process.env.BRAVE_PATH;
|
|
272
272
|
});
|
|
273
|
-
it('should return null when
|
|
273
|
+
it('should return null when Brave is not found', () => {
|
|
274
274
|
// Arrange: Mock file system to return false for all paths
|
|
275
275
|
vi.mocked(fs.existsSync).mockReturnValue(false);
|
|
276
|
-
delete process.env.
|
|
276
|
+
delete process.env.BRAVE_PATH;
|
|
277
277
|
delete process.env.PUPPETEER_EXECUTABLE_PATH;
|
|
278
|
-
// Act: Detect
|
|
279
|
-
const result =
|
|
278
|
+
// Act: Detect Brave path
|
|
279
|
+
const result = detectBravePath();
|
|
280
280
|
// Assert: Should return null
|
|
281
281
|
expect(result).toBe(null);
|
|
282
282
|
});
|
|
283
|
-
it('should detect
|
|
283
|
+
it('should detect Brave on macOS platform', () => {
|
|
284
284
|
// Arrange: Mock platform and file system
|
|
285
285
|
Object.defineProperty(process, 'platform', { value: 'darwin' });
|
|
286
|
-
const expectedPath = '/Applications/
|
|
286
|
+
const expectedPath = '/Applications/Brave Browser.app/Contents/MacOS/Brave Browser';
|
|
287
287
|
vi.mocked(fs.existsSync).mockImplementation((path) => path === expectedPath);
|
|
288
|
-
delete process.env.
|
|
289
|
-
// Act: Detect
|
|
290
|
-
const result =
|
|
291
|
-
// Assert: Should return macOS
|
|
288
|
+
delete process.env.BRAVE_PATH;
|
|
289
|
+
// Act: Detect Brave path
|
|
290
|
+
const result = detectBravePath();
|
|
291
|
+
// Assert: Should return macOS Brave path
|
|
292
292
|
expect(result).toBe(expectedPath);
|
|
293
293
|
});
|
|
294
|
-
it('should detect
|
|
294
|
+
it('should detect Brave on Linux platform', () => {
|
|
295
295
|
// Arrange: Mock platform and file system
|
|
296
296
|
Object.defineProperty(process, 'platform', { value: 'linux' });
|
|
297
|
-
const expectedPath = '/usr/bin/
|
|
297
|
+
const expectedPath = '/usr/bin/brave-browser';
|
|
298
298
|
vi.mocked(fs.existsSync).mockImplementation((path) => path === expectedPath);
|
|
299
|
-
delete process.env.
|
|
300
|
-
// Act: Detect
|
|
301
|
-
const result =
|
|
302
|
-
// Assert: Should return Linux
|
|
299
|
+
delete process.env.BRAVE_PATH;
|
|
300
|
+
// Act: Detect Brave path
|
|
301
|
+
const result = detectBravePath();
|
|
302
|
+
// Assert: Should return Linux Brave path
|
|
303
303
|
expect(result).toBe(expectedPath);
|
|
304
304
|
});
|
|
305
305
|
it('should return null for unsupported platform', () => {
|
|
306
306
|
// Arrange: Mock unsupported platform
|
|
307
307
|
Object.defineProperty(process, 'platform', { value: 'freebsd' });
|
|
308
|
-
delete process.env.
|
|
309
|
-
// Act: Detect
|
|
310
|
-
const result =
|
|
308
|
+
delete process.env.BRAVE_PATH;
|
|
309
|
+
// Act: Detect Brave path
|
|
310
|
+
const result = detectBravePath();
|
|
311
311
|
// Assert: Should return null
|
|
312
312
|
expect(result).toBe(null);
|
|
313
313
|
});
|
|
@@ -377,17 +377,17 @@ describe('Browser Manager', () => {
|
|
|
377
377
|
expect(page).toBe(null);
|
|
378
378
|
});
|
|
379
379
|
});
|
|
380
|
-
describe('Force Kill
|
|
380
|
+
describe('Force Kill Browser Processes', () => {
|
|
381
381
|
it('should execute without throwing errors', async () => {
|
|
382
|
-
// Arrange & Act: Force kill
|
|
382
|
+
// Arrange & Act: Force kill browser processes
|
|
383
383
|
// Act & Assert: Should not throw error regardless of platform
|
|
384
|
-
await expect(
|
|
384
|
+
await expect(forceKillAllBrowserProcesses()).resolves.toBeUndefined();
|
|
385
385
|
});
|
|
386
386
|
it('should handle different platforms', async () => {
|
|
387
387
|
// Arrange: Test with current platform
|
|
388
388
|
const originalPlatform = process.platform;
|
|
389
389
|
// Act: Execute force kill
|
|
390
|
-
await
|
|
390
|
+
await forceKillAllBrowserProcesses();
|
|
391
391
|
// Assert: Should complete without error
|
|
392
392
|
expect(process.platform).toBe(originalPlatform);
|
|
393
393
|
});
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { TOOLS, SERVER_INFO, CAPABILITIES, TOOL_NAMES } from './tool-definitions
|
|
|
13
13
|
console.error('🔍 [DEBUG] Loading system utils...');
|
|
14
14
|
import { withErrorHandling } from './system-utils.js';
|
|
15
15
|
console.error('🔍 [DEBUG] Loading browser manager...');
|
|
16
|
-
import { closeBrowser,
|
|
16
|
+
import { closeBrowser, forceKillAllBrowserProcesses } from './browser-manager.js';
|
|
17
17
|
console.error('🔍 [DEBUG] Loading core infrastructure...');
|
|
18
18
|
import { setupProcessCleanup } from './core-infrastructure.js';
|
|
19
19
|
// Import handlers
|
|
@@ -266,7 +266,7 @@ async function main() {
|
|
|
266
266
|
setupProcessCleanup(async () => {
|
|
267
267
|
console.error('🔍 [DEBUG] Process cleanup triggered');
|
|
268
268
|
await closeBrowser();
|
|
269
|
-
await
|
|
269
|
+
await forceKillAllBrowserProcesses();
|
|
270
270
|
});
|
|
271
271
|
// Create and start the server transport
|
|
272
272
|
console.error('🔍 [DEBUG] Creating StdioServerTransport...');
|
package/dist/tool-definitions.js
CHANGED
|
@@ -25,7 +25,7 @@ export const DEFAULT_CONTENT_PRIORITY_CONFIG = {
|
|
|
25
25
|
export const TOOLS = [
|
|
26
26
|
{
|
|
27
27
|
name: 'browser_init',
|
|
28
|
-
description: 'Initialize a new browser instance with anti-detection features and automatic
|
|
28
|
+
description: 'Initialize a new browser instance with anti-detection features and automatic Brave Browser path detection',
|
|
29
29
|
inputSchema: {
|
|
30
30
|
type: 'object',
|
|
31
31
|
properties: {
|
|
@@ -41,7 +41,7 @@ export const TOOLS = [
|
|
|
41
41
|
},
|
|
42
42
|
ignoreAllFlags: {
|
|
43
43
|
type: 'boolean',
|
|
44
|
-
description: 'Ignore all
|
|
44
|
+
description: 'Ignore all browser flags (recommended: true for clean startup without --no-sandbox)',
|
|
45
45
|
default: true,
|
|
46
46
|
},
|
|
47
47
|
proxy: {
|
|
@@ -62,11 +62,11 @@ export const TOOLS = [
|
|
|
62
62
|
},
|
|
63
63
|
customConfig: {
|
|
64
64
|
type: 'object',
|
|
65
|
-
description: 'Custom configuration for
|
|
65
|
+
description: 'Custom configuration for Brave launcher. Use bravePath to specify custom Brave executable path',
|
|
66
66
|
properties: {
|
|
67
|
-
|
|
67
|
+
bravePath: {
|
|
68
68
|
type: 'string',
|
|
69
|
-
description: 'Custom path to
|
|
69
|
+
description: 'Custom path to Brave executable (auto-detected if not specified)',
|
|
70
70
|
},
|
|
71
71
|
},
|
|
72
72
|
additionalProperties: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brave-real-browser-mcp-server",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.14",
|
|
4
4
|
"description": "MCP server for brave-real-browser",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"test:integration": "vitest run test/integration",
|
|
29
29
|
"test:e2e": "vitest run --config vitest.e2e.config.ts",
|
|
30
30
|
"test:e2e:watch": "vitest --config vitest.e2e.config.ts",
|
|
31
|
-
"test:
|
|
31
|
+
"test:brave:cleanup": "pkill -f 'Brave Browser' || true"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@modelcontextprotocol/sdk": "^1.20.0",
|