brave-mcp 0.4.0 → 0.5.0
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 +29 -20
- package/build/src/bin/brave-devtools.js +22 -5
- package/build/src/browser.js +16 -3
- package/build/src/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -96,7 +96,9 @@ If Brave is not detected automatically, set `BRAVE_PATH`:
|
|
|
96
96
|
"mcpServers": {
|
|
97
97
|
"brave-devtools": {
|
|
98
98
|
"command": "node",
|
|
99
|
-
"args": [
|
|
99
|
+
"args": [
|
|
100
|
+
"/absolute/path/to/brave-devtools-mcp/build/src/bin/brave-devtools-mcp.js"
|
|
101
|
+
],
|
|
100
102
|
"env": {
|
|
101
103
|
"BRAVE_PATH": "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
|
|
102
104
|
}
|
|
@@ -139,7 +141,12 @@ brave-browser --remote-debugging-port=9222
|
|
|
139
141
|
"mcpServers": {
|
|
140
142
|
"brave-devtools": {
|
|
141
143
|
"command": "npx",
|
|
142
|
-
"args": [
|
|
144
|
+
"args": [
|
|
145
|
+
"-y",
|
|
146
|
+
"brave-mcp@latest",
|
|
147
|
+
"--browserUrl",
|
|
148
|
+
"http://localhost:9222"
|
|
149
|
+
]
|
|
143
150
|
}
|
|
144
151
|
}
|
|
145
152
|
}
|
|
@@ -154,7 +161,8 @@ Or if running from source:
|
|
|
154
161
|
"command": "node",
|
|
155
162
|
"args": [
|
|
156
163
|
"/absolute/path/to/brave-devtools-mcp/build/src/bin/brave-devtools-mcp.js",
|
|
157
|
-
"--browserUrl",
|
|
164
|
+
"--browserUrl",
|
|
165
|
+
"http://localhost:9222"
|
|
158
166
|
]
|
|
159
167
|
}
|
|
160
168
|
}
|
|
@@ -198,7 +206,8 @@ If you are interested in only basic browser tasks, use `--slim` mode:
|
|
|
198
206
|
"command": "node",
|
|
199
207
|
"args": [
|
|
200
208
|
"/absolute/path/to/brave-devtools-mcp/build/src/bin/brave-devtools-mcp.js",
|
|
201
|
-
"--slim",
|
|
209
|
+
"--slim",
|
|
210
|
+
"--headless"
|
|
202
211
|
]
|
|
203
212
|
}
|
|
204
213
|
}
|
|
@@ -650,16 +659,16 @@ The Brave DevTools MCP server supports the following configuration options:
|
|
|
650
659
|
<!-- BEGIN AUTO GENERATED OPTIONS -->
|
|
651
660
|
|
|
652
661
|
- **`--autoConnect`/ `--auto-connect`**
|
|
653
|
-
If specified, automatically connects to a
|
|
662
|
+
If specified, automatically connects to a Brave instance running locally from the user data directory identified by the channel param (default channel is release). Requires the remote debugging server to be started in the Brave instance via brave://inspect/#remote-debugging.
|
|
654
663
|
- **Type:** boolean
|
|
655
664
|
- **Default:** `false`
|
|
656
665
|
|
|
657
666
|
- **`--browserUrl`/ `--browser-url`, `-u`**
|
|
658
|
-
Connect to a running, debuggable
|
|
667
|
+
Connect to a running, debuggable Brave instance (e.g. `http://127.0.0.1:9222`).
|
|
659
668
|
- **Type:** string
|
|
660
669
|
|
|
661
670
|
- **`--wsEndpoint`/ `--ws-endpoint`, `-w`**
|
|
662
|
-
WebSocket endpoint to connect to a running
|
|
671
|
+
WebSocket endpoint to connect to a running Brave instance (e.g., ws://127.0.0.1:9222/devtools/browser/<id>). Alternative to --browserUrl.
|
|
663
672
|
- **Type:** string
|
|
664
673
|
|
|
665
674
|
- **`--wsHeaders`/ `--ws-headers`**
|
|
@@ -672,7 +681,7 @@ The Brave DevTools MCP server supports the following configuration options:
|
|
|
672
681
|
- **Default:** `false`
|
|
673
682
|
|
|
674
683
|
- **`--executablePath`/ `--executable-path`, `-e`**
|
|
675
|
-
Path to custom
|
|
684
|
+
Path to custom Brave executable. Can also be set via BRAVE_PATH environment variable.
|
|
676
685
|
- **Type:** string
|
|
677
686
|
|
|
678
687
|
- **`--isolated`**
|
|
@@ -680,24 +689,24 @@ The Brave DevTools MCP server supports the following configuration options:
|
|
|
680
689
|
- **Type:** boolean
|
|
681
690
|
|
|
682
691
|
- **`--userDataDir`/ `--user-data-dir`**
|
|
683
|
-
Path to the user data directory for
|
|
692
|
+
Path to the user data directory for Brave. Default is $HOME/.cache/brave-devtools-mcp/brave-profile$CHANNEL_SUFFIX_IF_NON_RELEASE
|
|
684
693
|
- **Type:** string
|
|
685
694
|
|
|
686
695
|
- **`--channel`**
|
|
687
|
-
Specify a different
|
|
696
|
+
Specify a different Brave channel that should be used. The default is the release channel.
|
|
688
697
|
- **Type:** string
|
|
689
|
-
- **Choices:** `
|
|
698
|
+
- **Choices:** `release`, `beta`, `nightly`, `dev`
|
|
690
699
|
|
|
691
700
|
- **`--logFile`/ `--log-file`**
|
|
692
701
|
Path to a file to write debug logs to. Set the env variable `DEBUG` to `*` to enable verbose logs. Useful for submitting bug reports.
|
|
693
702
|
- **Type:** string
|
|
694
703
|
|
|
695
704
|
- **`--viewport`**
|
|
696
|
-
Initial viewport size for the
|
|
705
|
+
Initial viewport size for the Brave instances started by the server. For example, `1280x720`. In headless mode, max size is 3840x2160px.
|
|
697
706
|
- **Type:** string
|
|
698
707
|
|
|
699
708
|
- **`--proxyServer`/ `--proxy-server`**
|
|
700
|
-
Proxy server configuration for
|
|
709
|
+
Proxy server configuration for Brave passed as --proxy-server when launching the browser. See https://www.chromium.org/developers/design-documents/network-settings/ for details.
|
|
701
710
|
- **Type:** string
|
|
702
711
|
|
|
703
712
|
- **`--acceptInsecureCerts`/ `--accept-insecure-certs`**
|
|
@@ -717,15 +726,15 @@ The Brave DevTools MCP server supports the following configuration options:
|
|
|
717
726
|
- **Type:** string
|
|
718
727
|
|
|
719
728
|
- **`--categoryExperimentalWebmcp`/ `--category-experimental-webmcp`**
|
|
720
|
-
Set to true to enable debugging WebMCP tools. Requires
|
|
729
|
+
Set to true to enable debugging WebMCP tools. Requires Brave with the following flags: `--enable-features=WebMCPTesting,DevToolsWebMCPSupport`
|
|
721
730
|
- **Type:** boolean
|
|
722
731
|
|
|
723
|
-
- **`--
|
|
724
|
-
Additional arguments for
|
|
732
|
+
- **`--braveArg`/ `--brave-arg`**
|
|
733
|
+
Additional arguments for Brave. Only applies when Brave is launched by brave-devtools-mcp.
|
|
725
734
|
- **Type:** array
|
|
726
735
|
|
|
727
|
-
- **`--
|
|
728
|
-
Explicitly disable default arguments for
|
|
736
|
+
- **`--ignoreDefaultBraveArg`/ `--ignore-default-brave-arg`**
|
|
737
|
+
Explicitly disable default arguments for Brave. Only applies when Brave is launched by brave-devtools-mcp.
|
|
729
738
|
- **Type:** array
|
|
730
739
|
|
|
731
740
|
- **`--categoryEmulation`/ `--category-emulation`**
|
|
@@ -759,9 +768,9 @@ The Brave DevTools MCP server supports the following configuration options:
|
|
|
759
768
|
- **Default:** `true`
|
|
760
769
|
|
|
761
770
|
- **`--usageStatistics`/ `--usage-statistics`**
|
|
762
|
-
|
|
771
|
+
Usage statistics collection (disabled by default in this fork).
|
|
763
772
|
- **Type:** boolean
|
|
764
|
-
- **Default:** `
|
|
773
|
+
- **Default:** `false`
|
|
765
774
|
|
|
766
775
|
- **`--slim`**
|
|
767
776
|
Exposes a "slim" set of 3 tools covering navigation, script execution and screenshots only. Useful for basic browser tasks.
|
|
@@ -65,12 +65,29 @@ y.command('start', 'Start or restart brave-devtools-mcp', y => y
|
|
|
65
65
|
if (isDaemonRunning(argv.sessionId)) {
|
|
66
66
|
await stopDaemon(argv.sessionId);
|
|
67
67
|
}
|
|
68
|
-
// Defaults
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
// Defaults only apply to *spawn* mode. Skip / clear them when
|
|
69
|
+
// attaching to an existing browser, otherwise `status` shows
|
|
70
|
+
// misleading args like `--browserUrl X --headless --isolated`
|
|
71
|
+
// together (the runtime ignores headless/isolated under attach,
|
|
72
|
+
// but storing them anyway is a footgun if the resolver order ever
|
|
73
|
+
// changes — and confuses anyone reading `status` output).
|
|
74
|
+
const isAttachMode = argv.browserUrl !== undefined ||
|
|
75
|
+
argv.wsEndpoint !== undefined ||
|
|
76
|
+
argv.autoConnect === true;
|
|
77
|
+
if (isAttachMode) {
|
|
78
|
+
// Strip spawn-mode flags so serializeArgs doesn't emit them.
|
|
79
|
+
// Headless has `default: true` in the CLI override, so this is
|
|
80
|
+
// necessary even when the user didn't pass `--headless`.
|
|
81
|
+
delete argv.headless;
|
|
82
|
+
delete argv.isolated;
|
|
71
83
|
}
|
|
72
|
-
|
|
73
|
-
argv.
|
|
84
|
+
else {
|
|
85
|
+
if (argv.isolated === undefined && argv.userDataDir === undefined) {
|
|
86
|
+
argv.isolated = true;
|
|
87
|
+
}
|
|
88
|
+
if (argv.headless === undefined) {
|
|
89
|
+
argv.headless = true;
|
|
90
|
+
}
|
|
74
91
|
}
|
|
75
92
|
const args = serializeArgs(cliOptions, argv);
|
|
76
93
|
await start(args, argv.sessionId);
|
package/build/src/browser.js
CHANGED
|
@@ -10,6 +10,13 @@ import path from 'node:path';
|
|
|
10
10
|
import { logger } from './logger.js';
|
|
11
11
|
import { puppeteer } from './third_party/index.js';
|
|
12
12
|
let browser;
|
|
13
|
+
// Heavy pages (e.g. Studio module dev bundles >100MB) cannot ack
|
|
14
|
+
// `Network.enable` and other auto-attached domain calls within
|
|
15
|
+
// puppeteer's default 180s. Once that fires, the CDP connection is
|
|
16
|
+
// marked dead and every subsequent call throws — only daemon restart
|
|
17
|
+
// recovers. Bumping the ceiling to 10min covers realistic loads;
|
|
18
|
+
// override via env for power users.
|
|
19
|
+
const PROTOCOL_TIMEOUT_MS = parseInt(process.env.BRAVE_DEVTOOLS_PROTOCOL_TIMEOUT_MS ?? '600000', 10);
|
|
13
20
|
function makeTargetFilter(enableExtensions = false) {
|
|
14
21
|
const ignoredPrefixes = new Set([
|
|
15
22
|
'chrome://',
|
|
@@ -20,10 +27,12 @@ function makeTargetFilter(enableExtensions = false) {
|
|
|
20
27
|
ignoredPrefixes.add('chrome-extension://');
|
|
21
28
|
}
|
|
22
29
|
return function targetFilter(target) {
|
|
23
|
-
if (target.url() === 'brave://newtab/' ||
|
|
30
|
+
if (target.url() === 'brave://newtab/' ||
|
|
31
|
+
target.url() === 'chrome://newtab/') {
|
|
24
32
|
return true;
|
|
25
33
|
}
|
|
26
|
-
if (target.url().startsWith('brave://inspect') ||
|
|
34
|
+
if (target.url().startsWith('brave://inspect') ||
|
|
35
|
+
target.url().startsWith('chrome://inspect')) {
|
|
27
36
|
return true;
|
|
28
37
|
}
|
|
29
38
|
for (const prefix of ignoredPrefixes) {
|
|
@@ -66,7 +75,9 @@ function resolveBraveExecutablePath(channel) {
|
|
|
66
75
|
const candidates = paths[channel ?? 'release'];
|
|
67
76
|
for (const candidate of candidates) {
|
|
68
77
|
try {
|
|
69
|
-
const resolvedPath = execSync(`which ${candidate}`, {
|
|
78
|
+
const resolvedPath = execSync(`which ${candidate}`, {
|
|
79
|
+
encoding: 'utf8',
|
|
80
|
+
}).trim();
|
|
70
81
|
if (resolvedPath) {
|
|
71
82
|
return resolvedPath;
|
|
72
83
|
}
|
|
@@ -151,6 +162,7 @@ export async function ensureBrowserConnected(options) {
|
|
|
151
162
|
targetFilter: makeTargetFilter(enableExtensions),
|
|
152
163
|
defaultViewport: null,
|
|
153
164
|
handleDevToolsAsPage: true,
|
|
165
|
+
protocolTimeout: PROTOCOL_TIMEOUT_MS,
|
|
154
166
|
};
|
|
155
167
|
let autoConnect = false;
|
|
156
168
|
if (options.wsEndpoint) {
|
|
@@ -262,6 +274,7 @@ export async function launch(options) {
|
|
|
262
274
|
acceptInsecureCerts: options.acceptInsecureCerts,
|
|
263
275
|
handleDevToolsAsPage: true,
|
|
264
276
|
enableExtensions: options.enableExtensions,
|
|
277
|
+
protocolTimeout: PROTOCOL_TIMEOUT_MS,
|
|
265
278
|
});
|
|
266
279
|
if (options.logFile) {
|
|
267
280
|
browser.process()?.stderr?.pipe(options.logFile);
|
package/build/src/version.js
CHANGED