real-browser-mcp-server 1.1.1 → 1.3.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/lib/cjs/index.js CHANGED
@@ -181,7 +181,22 @@ async function connect({
181
181
  headless = getDefaultHeadless(),
182
182
  proxy = {},
183
183
  turnstile = false,
184
+ disableXvfb = false,
184
185
  } = {}) {
186
+ let xvfbInstance = null;
187
+ if (process.platform === 'linux' && !process.env.DISPLAY && !disableXvfb) {
188
+ try {
189
+ const Xvfb = require('xvfb');
190
+ xvfbInstance = new Xvfb({
191
+ silent: true,
192
+ xvfb_args: ['-screen', '0', '1280x1024x24', '-ac']
193
+ });
194
+ xvfbInstance.startSync();
195
+ } catch (err) {
196
+ console.error('[xvfb] Failed to start Xvfb server automatically:', err.message);
197
+ }
198
+ }
199
+
185
200
  let playwrightProxy = undefined;
186
201
  if (proxy && proxy.host && proxy.port) {
187
202
  playwrightProxy = {
@@ -212,6 +227,25 @@ async function connect({
212
227
  plugins: [recommended()]
213
228
  });
214
229
 
230
+ if (xvfbInstance) {
231
+ browser.on('disconnected', () => {
232
+ try {
233
+ xvfbInstance.stopSync();
234
+ } catch (e) {
235
+ console.error('[xvfb] Failed to stop Xvfb server:', e.message);
236
+ }
237
+ });
238
+ const originalClose = browser.close.bind(browser);
239
+ browser.close = async () => {
240
+ await originalClose();
241
+ try {
242
+ xvfbInstance.stopSync();
243
+ } catch (e) {
244
+ console.error('[xvfb] Failed to stop Xvfb server during close:', e.message);
245
+ }
246
+ };
247
+ }
248
+
215
249
  // Ensure ad blocker is ready
216
250
  await getAdBlocker();
217
251
 
package/lib/esm/index.mjs CHANGED
@@ -4,6 +4,7 @@ const { chromium } = playwright;
4
4
  import { PlaywrightBlocker } from "@ghostery/adblocker-playwright";
5
5
  import { pageController } from "./module/pageController.mjs";
6
6
  import { fileURLToPath } from 'url';
7
+ import Xvfb from "xvfb";
7
8
  import * as fs from 'fs';
8
9
  import * as path from 'path';
9
10
 
@@ -184,7 +185,21 @@ export async function connect({
184
185
  headless = getDefaultHeadless(),
185
186
  proxy = {},
186
187
  turnstile = false,
188
+ disableXvfb = false,
187
189
  } = {}) {
190
+ let xvfbInstance = null;
191
+ if (process.platform === 'linux' && !process.env.DISPLAY && !disableXvfb) {
192
+ try {
193
+ xvfbInstance = new Xvfb({
194
+ silent: true,
195
+ xvfb_args: ['-screen', '0', '1280x1024x24', '-ac']
196
+ });
197
+ xvfbInstance.startSync();
198
+ } catch (err) {
199
+ console.error('[xvfb] Failed to start Xvfb server automatically:', err.message);
200
+ }
201
+ }
202
+
188
203
  let playwrightProxy = undefined;
189
204
  if (proxy && proxy.host && proxy.port) {
190
205
  playwrightProxy = {
@@ -210,6 +225,25 @@ export async function connect({
210
225
  plugins: [recommended()]
211
226
  });
212
227
 
228
+ if (xvfbInstance) {
229
+ browser.on('disconnected', () => {
230
+ try {
231
+ xvfbInstance.stopSync();
232
+ } catch (e) {
233
+ console.error('[xvfb] Failed to stop Xvfb server:', e.message);
234
+ }
235
+ });
236
+ const originalClose = browser.close.bind(browser);
237
+ browser.close = async () => {
238
+ await originalClose();
239
+ try {
240
+ xvfbInstance.stopSync();
241
+ } catch (e) {
242
+ console.error('[xvfb] Failed to stop Xvfb server during close:', e.message);
243
+ }
244
+ };
245
+ }
246
+
213
247
  // Ensure ad blocker is ready
214
248
  await getAdBlocker();
215
249
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "real-browser-mcp-server",
3
- "version": "1.1.1",
3
+ "version": "1.3.0",
4
4
  "description": "MCP Server for Real Browser - Patchright (undetected Playwright fork) with Stealth Mode, Ad Blocker, and Turnstile Auto-Solver for undetectable web automation.",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/esm/index.mjs",
@@ -28,7 +28,8 @@
28
28
  "test": "npm run cjs_test && npm run esm_test",
29
29
  "esm_test": "node ./test/esm/test.js",
30
30
  "cjs_test": "node ./test/cjs/test.js",
31
- "build": "echo 'No build step required for this package.'"
31
+ "build": "echo 'No build step required for this package.'",
32
+ "postinstall": "npx patchright install chromium"
32
33
  },
33
34
  "keywords": [
34
35
  "mcp-server",
@@ -45,6 +46,7 @@
45
46
  "@ghostery/adblocker-playwright": "latest",
46
47
  "@modelcontextprotocol/sdk": "latest",
47
48
  "patchright": "latest",
48
- "playwright-ghost": "latest"
49
+ "playwright-ghost": "^0.18.0",
50
+ "xvfb": "^0.4.0"
49
51
  }
50
52
  }