@liqi0816/chrome-devtools-mcp-rebrowser 1.0.2 → 1.0.3
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 +21 -17
- package/launch.mjs +2 -1
- package/package.json +7 -5
- package/postinstall.mjs +62 -2
package/README.md
CHANGED
|
@@ -18,7 +18,6 @@ Code is MIT. What license applies to human-AI conversation transcripts is an ope
|
|
|
18
18
|
|
|
19
19
|
- **Node.js** ≥ 20.19.0 LTS
|
|
20
20
|
- **Chrome** running with remote debugging enabled (go to `chrome://inspect/#remote-debugging`)
|
|
21
|
-
- **Git** installed (provides `patch.exe` on Windows, needed for applying patches)
|
|
22
21
|
|
|
23
22
|
### Usage via `npx` (recommended)
|
|
24
23
|
|
|
@@ -83,7 +82,7 @@ Then configure the MCP server to use the local entry point:
|
|
|
83
82
|
|
|
84
83
|
## How It Works
|
|
85
84
|
|
|
86
|
-
`chrome-devtools-mcp` is Google's official MCP server for Chrome DevTools. It bundles its own copy of Puppeteer
|
|
85
|
+
`chrome-devtools-mcp` is Google's official MCP server for Chrome DevTools. It bundles its own copy of Puppeteer internally. This project intercepts its `puppeteer.connect()` and `puppeteer.launch()` calls and redirects them through a separately installed, rebrowser-patched version of `puppeteer-core`.
|
|
87
86
|
|
|
88
87
|
### Architecture
|
|
89
88
|
|
|
@@ -91,7 +90,7 @@ Then configure the MCP server to use the local entry point:
|
|
|
91
90
|
launch.mjs (entry point)
|
|
92
91
|
│
|
|
93
92
|
├─ Imports patched puppeteer-core (node_modules/puppeteer-core)
|
|
94
|
-
│ └─ puppeteer-core@24.
|
|
93
|
+
│ └─ puppeteer-core@24.40.0 + rebrowser-patches applied
|
|
95
94
|
│
|
|
96
95
|
├─ Imports bundled puppeteer from chrome-devtools-mcp
|
|
97
96
|
│ └─ node_modules/chrome-devtools-mcp/build/src/third_party/index.js
|
|
@@ -116,8 +115,16 @@ DevToolsConnectionAdapter.js (patched)
|
|
|
116
115
|
### Why the Monkey-Patching?
|
|
117
116
|
|
|
118
117
|
- `chrome-devtools-mcp` bundles Puppeteer in a single rollup file (`third_party/index.js`), so you can't simply swap out `puppeteer-core` via `package.json`.
|
|
119
|
-
- `rebrowser-puppeteer` (the drop-in replacement) is only available up to v24.8.1, but `chrome-devtools-mcp
|
|
120
|
-
- Solution: install `puppeteer-core
|
|
118
|
+
- `rebrowser-puppeteer` (the drop-in replacement) is only available up to v24.8.1, but recent `chrome-devtools-mcp` releases require newer Puppeteer APIs (e.g., `page.emulateFocusedPage()` from v24.39+).
|
|
119
|
+
- Solution: install a compatible `puppeteer-core` separately, apply `rebrowser-patches` to it, then redirect the bundled Puppeteer's calls through the patched version.
|
|
120
|
+
|
|
121
|
+
### Why `puppeteer-core` and `rebrowser-patches` are pinned to exact versions
|
|
122
|
+
|
|
123
|
+
You'll see `"puppeteer-core": "24.40.0"` and `"rebrowser-patches": "1.0.19"` (no caret) in `package.json`. This is deliberate — these two **must** move in lockstep:
|
|
124
|
+
|
|
125
|
+
`rebrowser-patches` is a set of **line-by-line unified diffs** against puppeteer-core's compiled output. Any upstream puppeteer-core release can add/remove lines near a hunk and make the patch stop applying — even patch-level releases. For example, `rebrowser-patches@1.0.19` was cut against puppeteer-core 24.40.x, and newer puppeteer-core (24.41+) adds fields to `IsolatedWorld.js` that break hunks (see [issue #4](https://github.com/liqi0816/chrome-devtools-mcp-rebrowser/issues/4)). Conversely, a newer `rebrowser-patches` release could target a different puppeteer-core line layout and stop applying to 24.40.0.
|
|
126
|
+
|
|
127
|
+
Both pins are bumped together whenever a new `rebrowser-patches` release catches up to a newer puppeteer-core. The remaining dependencies (`chrome-devtools-mcp`, `diff`) still float on `^` ranges because their APIs are stable and the patches we apply use fuzzy matching.
|
|
121
128
|
|
|
122
129
|
## Flags
|
|
123
130
|
|
|
@@ -187,20 +194,17 @@ This is an acceptable tradeoff since `Runtime.enable` is the primary CDP detecti
|
|
|
187
194
|
- Check that `DevToolsActivePort` file exists in Chrome's user data directory
|
|
188
195
|
|
|
189
196
|
### Patch fails with "FAILED" hunks
|
|
190
|
-
-
|
|
197
|
+
- The installed `puppeteer-core` version drifted past what `rebrowser-patches` knows how to patch. `postinstall.mjs` prints the exact installed versions and a link to [issue #4](https://github.com/liqi0816/chrome-devtools-mcp-rebrowser/issues/4) when this happens. Re-run with `npx -y @liqi0816/chrome-devtools-mcp-rebrowser@latest` — the pinned `puppeteer-core` and `rebrowser-patches` in `package.json` should keep the install reproducible.
|
|
191
198
|
|
|
192
199
|
### "emulateFocusedPage is not a function" (or similar)
|
|
193
|
-
- Version mismatch: ensure `puppeteer-core` in `package.json`
|
|
194
|
-
|
|
195
|
-
### Postinstall fails — "`patch` command not found"
|
|
196
|
-
- On Linux/macOS: `patch` is usually pre-installed. If not: `sudo apt install patch` or `brew install gpatch`.
|
|
197
|
-
- On Windows: Install [Git for Windows](https://gitforwindows.org/) — it bundles `patch.exe` at `C:\Program Files\Git\usr\bin\patch.exe`. Make sure it's on your PATH.
|
|
200
|
+
- Version mismatch: ensure `puppeteer-core` in `package.json` is a version whose API is supported by the bundled Puppeteer inside `chrome-devtools-mcp` (see the Version Compatibility table below).
|
|
198
201
|
|
|
199
202
|
## Version Compatibility
|
|
200
203
|
|
|
201
|
-
| Package | Version |
|
|
202
|
-
|
|
203
|
-
| chrome-devtools-mcp | 0.
|
|
204
|
-
| puppeteer-core | 24.
|
|
205
|
-
| rebrowser-patches | 1.0.19 |
|
|
206
|
-
|
|
|
204
|
+
| Package | Version | Pinned? |
|
|
205
|
+
|---------|---------|---------|
|
|
206
|
+
| chrome-devtools-mcp | ^0.22.0 | floats (fuzzy patch) |
|
|
207
|
+
| puppeteer-core | 24.40.0 | **exact** ([why](#why-puppeteer-core-and-rebrowser-patches-are-pinned-to-exact-versions)) |
|
|
208
|
+
| rebrowser-patches | 1.0.19 | **exact** ([why](#why-puppeteer-core-and-rebrowser-patches-are-pinned-to-exact-versions)) |
|
|
209
|
+
| diff | ^8.0.4 | floats |
|
|
210
|
+
| Node.js | ≥ 20.19.0 | — |
|
package/launch.mjs
CHANGED
|
@@ -8,7 +8,8 @@ const require = createRequire(import.meta.url);
|
|
|
8
8
|
// ---------------------------------------------------------------------------
|
|
9
9
|
// Step 1: Import the patched puppeteer-core
|
|
10
10
|
// ---------------------------------------------------------------------------
|
|
11
|
-
// This is puppeteer-core
|
|
11
|
+
// This is puppeteer-core (pinned in package.json — currently 24.40.0) with
|
|
12
|
+
// rebrowser-patches applied in-place by postinstall.mjs.
|
|
12
13
|
// The patches disable Runtime.Enable (the primary CDP detection vector),
|
|
13
14
|
// change sourceURL from pptr:... to app.js, and rename the utility world.
|
|
14
15
|
import puppeteerCore from 'puppeteer-core';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liqi0816/chrome-devtools-mcp-rebrowser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Chrome DevTools MCP server with rebrowser anti-detection patches — undetectable by Cloudflare, DataDome, and other anti-bot systems",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -35,13 +35,15 @@
|
|
|
35
35
|
],
|
|
36
36
|
"scripts": {
|
|
37
37
|
"postinstall": "node postinstall.mjs",
|
|
38
|
-
"start": "node launch.mjs"
|
|
38
|
+
"start": "node launch.mjs",
|
|
39
|
+
"smoke-test": "node smoke-test.mjs",
|
|
40
|
+
"prepublishOnly": "npm run smoke-test"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
|
-
"chrome-devtools-mcp": "^0.
|
|
43
|
+
"chrome-devtools-mcp": "^0.22.0",
|
|
42
44
|
"diff": "^8.0.4",
|
|
43
|
-
"puppeteer-core": "
|
|
44
|
-
"rebrowser-patches": "
|
|
45
|
+
"puppeteer-core": "24.40.0",
|
|
46
|
+
"rebrowser-patches": "1.0.19"
|
|
45
47
|
},
|
|
46
48
|
"publishConfig": {
|
|
47
49
|
"access": "public"
|
package/postinstall.mjs
CHANGED
|
@@ -134,6 +134,52 @@ async function applyMultiPatch(targetDir, patchContent, { maxFuzz , filter } = {
|
|
|
134
134
|
// Main
|
|
135
135
|
// ---------------------------------------------------------------------------
|
|
136
136
|
|
|
137
|
+
/**
|
|
138
|
+
* Read the installed version of a package, or 'unknown' if it can't be resolved.
|
|
139
|
+
* @param {string} packageName
|
|
140
|
+
*/
|
|
141
|
+
function pkgVersion(packageName) {
|
|
142
|
+
try { return require(`${packageName}/package.json`).version; }
|
|
143
|
+
catch { return 'unknown'; }
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Print a big, impossible-to-miss error block with diagnostic info and a link to
|
|
148
|
+
* the known-compatibility issue. Tuned specifically for issue #4: a
|
|
149
|
+
* `puppeteer-core` / `rebrowser-patches` version mismatch silently produces an
|
|
150
|
+
* unpatchable install. Both are now pinned exact in package.json, so this path
|
|
151
|
+
* should only fire if a user has overridden the pins or is running from a fork.
|
|
152
|
+
*
|
|
153
|
+
* @param {string} stage — human-readable stage name that failed
|
|
154
|
+
* @param {string[]} failed — list of patch target files that did not apply
|
|
155
|
+
* @param {Record<string, string>} versions — installed versions for context
|
|
156
|
+
*/
|
|
157
|
+
function printPatchFailureReport(stage, failed, versions) {
|
|
158
|
+
const lines = [
|
|
159
|
+
'',
|
|
160
|
+
'━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━',
|
|
161
|
+
`✘ chrome-devtools-mcp-rebrowser postinstall: ${stage} FAILED`,
|
|
162
|
+
'━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━',
|
|
163
|
+
'',
|
|
164
|
+
'The following patch targets could not be applied:',
|
|
165
|
+
...failed.map(f => ` • ${f}`),
|
|
166
|
+
'',
|
|
167
|
+
'Installed versions:',
|
|
168
|
+
...Object.entries(versions).map(([k, v]) => ` • ${k}: ${v}`),
|
|
169
|
+
'',
|
|
170
|
+
'This usually means one of the patched dependencies was upgraded past',
|
|
171
|
+
'what rebrowser-patches knows how to handle. See:',
|
|
172
|
+
' https://github.com/liqi0816/chrome-devtools-mcp-rebrowser/issues/4',
|
|
173
|
+
'',
|
|
174
|
+
'Quickest workaround: pin the known-good versions locally, e.g.',
|
|
175
|
+
' npx -y @liqi0816/chrome-devtools-mcp-rebrowser@1.0.3',
|
|
176
|
+
'(or whatever the latest published version is).',
|
|
177
|
+
'━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━',
|
|
178
|
+
'',
|
|
179
|
+
];
|
|
180
|
+
console.error(lines.join('\n'));
|
|
181
|
+
}
|
|
182
|
+
|
|
137
183
|
async function main() {
|
|
138
184
|
console.log('\n🔧 chrome-devtools-mcp-rebrowser: postinstall\n');
|
|
139
185
|
|
|
@@ -144,6 +190,14 @@ async function main() {
|
|
|
144
190
|
dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/i, '$1')),
|
|
145
191
|
);
|
|
146
192
|
|
|
193
|
+
const versions = {
|
|
194
|
+
'puppeteer-core': pkgVersion('puppeteer-core'),
|
|
195
|
+
'rebrowser-patches': pkgVersion('rebrowser-patches'),
|
|
196
|
+
'chrome-devtools-mcp': pkgVersion('chrome-devtools-mcp'),
|
|
197
|
+
};
|
|
198
|
+
console.log('Installed:', Object.entries(versions).map(([k, v]) => `${k}@${v}`).join(', '));
|
|
199
|
+
console.log('');
|
|
200
|
+
|
|
147
201
|
// 1. Apply rebrowser-patches to puppeteer-core
|
|
148
202
|
console.log('--- Applying rebrowser-patches to puppeteer-core ---');
|
|
149
203
|
const rebrowserPatch = await readFile(
|
|
@@ -154,7 +208,10 @@ async function main() {
|
|
|
154
208
|
filter: ({ oldFileName }) => !oldFileName.startsWith('a/lib/es5-iife')
|
|
155
209
|
});
|
|
156
210
|
console.log(` ✔ ${r1.applied} applied, ${r1.skipped} skipped`);
|
|
157
|
-
if (r1.failed.length)
|
|
211
|
+
if (r1.failed.length) {
|
|
212
|
+
printPatchFailureReport('rebrowser-patches → puppeteer-core', r1.failed, versions);
|
|
213
|
+
throw new Error(`Failed patches: ${r1.failed.join(', ')}`);
|
|
214
|
+
}
|
|
158
215
|
|
|
159
216
|
// 2. Apply DevToolsConnectionAdapter patch to chrome-devtools-mcp
|
|
160
217
|
console.log('--- Applying DevToolsConnectionAdapter patch ---');
|
|
@@ -163,7 +220,10 @@ async function main() {
|
|
|
163
220
|
);
|
|
164
221
|
const r2 = await applyMultiPatch(chromeDevtoolsMcpDir, adapterPatch, { maxFuzz: 2 });
|
|
165
222
|
console.log(` ✔ ${r2.applied} applied, ${r2.skipped} skipped`);
|
|
166
|
-
if (r2.failed.length)
|
|
223
|
+
if (r2.failed.length) {
|
|
224
|
+
printPatchFailureReport('DevToolsConnectionAdapter patch → chrome-devtools-mcp', r2.failed, versions);
|
|
225
|
+
throw new Error(`Failed patches: ${r2.failed.join(', ')}`);
|
|
226
|
+
}
|
|
167
227
|
|
|
168
228
|
console.log('\n✅ All patches applied. Ready to use!\n');
|
|
169
229
|
}
|