brave-real-browser-mcp-server 2.18.2 โ 2.18.4
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 +10 -0
- package/dist/browser-manager.js +54 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -165,5 +165,15 @@ PROXY_URL=http://user:pass@host:port
|
|
|
165
165
|
|
|
166
166
|
---
|
|
167
167
|
|
|
168
|
+
## ๐งช Testing
|
|
169
|
+
|
|
170
|
+
To run the End-to-End (E2E) tests for the project:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
npx vitest run test/e2e/visual-browser.test.ts --reporter=verbose 2>&1
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
168
178
|
## ๐ License
|
|
169
179
|
MIT License
|
package/dist/browser-manager.js
CHANGED
|
@@ -27,6 +27,49 @@ export function setPage(page) {
|
|
|
27
27
|
}
|
|
28
28
|
// Check environment variable for testing override
|
|
29
29
|
const disableContentPriority = process.env.DISABLE_CONTENT_PRIORITY === 'true' || process.env.NODE_ENV === 'test';
|
|
30
|
+
// ============================================
|
|
31
|
+
// HEADLESS CONFIGURATION - Single Source of Truth
|
|
32
|
+
// ============================================
|
|
33
|
+
// Control via environment variable: HEADLESS=true or HEADLESS=false
|
|
34
|
+
// ENV has HIGHEST PRIORITY - overrides any code/API settings
|
|
35
|
+
// Default: false (browser GUI visible) when ENV not set
|
|
36
|
+
const HEADLESS_ENV_SET = process.env.HEADLESS !== undefined;
|
|
37
|
+
export const IS_HEADLESS = process.env.HEADLESS === 'true';
|
|
38
|
+
// Helper: Get headless value (ENV always wins if set)
|
|
39
|
+
export const getHeadlessValue = (optionsHeadless) => {
|
|
40
|
+
if (HEADLESS_ENV_SET) {
|
|
41
|
+
return IS_HEADLESS; // ENV has highest priority
|
|
42
|
+
}
|
|
43
|
+
return optionsHeadless ?? false; // Fallback to options or false
|
|
44
|
+
};
|
|
45
|
+
// ============================================
|
|
46
|
+
// DISABLE_XVFB CONFIGURATION - Single Source of Truth
|
|
47
|
+
// ============================================
|
|
48
|
+
// Control via environment variable: DISABLE_XVFB=true or DISABLE_XVFB=false
|
|
49
|
+
// ENV has HIGHEST PRIORITY - overrides any code/API settings
|
|
50
|
+
// Default: true (Xvfb disabled) when ENV not set
|
|
51
|
+
const DISABLE_XVFB_ENV_SET = process.env.DISABLE_XVFB !== undefined;
|
|
52
|
+
export const IS_XVFB_DISABLED = process.env.DISABLE_XVFB !== 'false'; // Default true
|
|
53
|
+
// Helper: Get disableXvfb value (ENV always wins if set)
|
|
54
|
+
export const getDisableXvfbValue = (optionsDisableXvfb) => {
|
|
55
|
+
if (DISABLE_XVFB_ENV_SET) {
|
|
56
|
+
return IS_XVFB_DISABLED; // ENV has highest priority
|
|
57
|
+
}
|
|
58
|
+
return optionsDisableXvfb ?? true; // Fallback to options or true
|
|
59
|
+
};
|
|
60
|
+
// ============================================
|
|
61
|
+
// PROXY CONFIGURATION - Single Source of Truth
|
|
62
|
+
// ============================================
|
|
63
|
+
// Control via environment variable: PROXY_URL=http://proxy:8080
|
|
64
|
+
// ENV has HIGHEST PRIORITY - overrides any code/API settings
|
|
65
|
+
export const ENV_PROXY_URL = process.env.PROXY_URL || '';
|
|
66
|
+
// Helper: Get proxy value (ENV always wins if set)
|
|
67
|
+
export const getProxyValue = (optionsProxy) => {
|
|
68
|
+
if (ENV_PROXY_URL) {
|
|
69
|
+
return ENV_PROXY_URL; // ENV has highest priority
|
|
70
|
+
}
|
|
71
|
+
return optionsProxy; // Fallback to options
|
|
72
|
+
};
|
|
30
73
|
let contentPriorityConfig = {
|
|
31
74
|
prioritizeContent: !disableContentPriority,
|
|
32
75
|
autoSuggestGetContent: !disableContentPriority
|
|
@@ -490,10 +533,10 @@ export async function initializeBrowser(options) {
|
|
|
490
533
|
braveConfig.chromePath = detectedBravePath;
|
|
491
534
|
}
|
|
492
535
|
const connectOptions = {
|
|
493
|
-
headless: options?.headless
|
|
536
|
+
headless: getHeadlessValue(options?.headless),
|
|
494
537
|
customConfig: braveConfig,
|
|
495
538
|
turnstile: true,
|
|
496
|
-
disableXvfb: options?.disableXvfb
|
|
539
|
+
disableXvfb: getDisableXvfbValue(options?.disableXvfb),
|
|
497
540
|
// CRITICAL: Must be false by default to allow brave-real-browser to modify flags
|
|
498
541
|
ignoreAllFlags: options?.ignoreAllFlags ?? false,
|
|
499
542
|
args: [],
|
|
@@ -503,8 +546,13 @@ export async function initializeBrowser(options) {
|
|
|
503
546
|
...(options?.connectOption ?? {}),
|
|
504
547
|
},
|
|
505
548
|
};
|
|
506
|
-
|
|
507
|
-
|
|
549
|
+
// Proxy: ENV has highest priority
|
|
550
|
+
const proxyUrl = getProxyValue(options?.proxy);
|
|
551
|
+
if (proxyUrl) {
|
|
552
|
+
if (!connectOptions.customConfig.chromeFlags) {
|
|
553
|
+
connectOptions.customConfig.chromeFlags = [];
|
|
554
|
+
}
|
|
555
|
+
connectOptions.customConfig.chromeFlags.push(`--proxy-server=${proxyUrl}`);
|
|
508
556
|
}
|
|
509
557
|
// Explicitly enforce headless mode via flags if enabled
|
|
510
558
|
// This fixes issues where brave-real-browser might default to GUI
|
|
@@ -549,13 +597,13 @@ export async function initializeBrowser(options) {
|
|
|
549
597
|
strategyName: 'User-Defined Configuration',
|
|
550
598
|
strategy: {
|
|
551
599
|
executablePath: detectedBravePath,
|
|
552
|
-
headless: options?.headless
|
|
600
|
+
headless: getHeadlessValue(options?.headless),
|
|
553
601
|
turnstile: true,
|
|
554
602
|
args: [
|
|
555
603
|
"--start-maximized",
|
|
556
604
|
...uBlockArgs // Add uBlock args to primary strategy
|
|
557
605
|
],
|
|
558
|
-
disableXvfb:
|
|
606
|
+
disableXvfb: getDisableXvfbValue(options?.disableXvfb),
|
|
559
607
|
// CRITICAL: Must be false to allow brave-real-browser to process DEFAULT_FLAGS
|
|
560
608
|
ignoreAllFlags: false,
|
|
561
609
|
customConfig: braveConfig,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brave-real-browser-mcp-server",
|
|
3
|
-
"version": "2.18.
|
|
3
|
+
"version": "2.18.4",
|
|
4
4
|
"description": "Universal AI IDE MCP Server - Auto-detects and supports all AI IDEs (Claude Desktop, Cursor, Windsurf, Cline, Zed, VSCode, Qoder AI, etc.) with Brave browser automation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|