New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

brave-real-browser-mcp-server

Package Overview
Dependencies
Maintainers
1
Versions
355
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

brave-real-browser-mcp-server

MCP Server for Brave Real Browser - Puppeteer with Brave Browser, Stealth Mode, Ad Blocker, and Turnstile Auto-Solver for undetectable web automation.

latest
Source
npmnpm
Version
2.45.29
Version published
Weekly downloads
82
-88.81%
Maintainers
1
Weekly downloads
Ā 
Created
Source

Brave Real Browser MCP Server

npm version Auto-Update Monorepo Publish Node.js License: ISC

MCP Server for Puppeteer + Brave Browser + Stealth + Ad Blocker + Turnstile Auto-Solver

A production-ready MCP (Model Context Protocol) server that combines Puppeteer with Brave Browser for undetectable web automation. Passes all major bot detectors including Cloudflare, DataDome, and reCAPTCHA v3.

Key Features

FeatureDescription
MCP ServerModel Context Protocol compatible server with 23 optimized tools
LSP ServerLanguage Server Protocol for IDE code intelligence
AI CoreAutomatic AI enhancement for all tools (auto-healing, smart retry)
Brave BrowserUses Brave instead of Chromium for better privacy
50+ Stealth FeaturesPasses all major bot detectors
Built-in Ad Blocker45+ filter sources, 100/100 score, auto-update
Turnstile Auto-SolverCloudflare CAPTCHA bypass
Real CursorGhost-cursor for human-like movements
Plugin SupportPuppeteer-extra plugins compatible
Proxy SupportBuilt-in proxy with authentication
Auto-InstallBrave auto-installs if missing
TypeScript SupportFull type definitions included
ESM + CJSDual module support
Multi-languageEnglish & Hindi language support
Auto-UpdateDaily automatic dependency updates
Auto-PublishAutomatic NPM publishing on updates
Monoreponpm workspaces with linked packages
Singleton BlockerSingle shared blocker instance
Decoder UtilitiesURL, Base64, AES decryption built-in
Batch OperationsExtract from multiple URLs/pages at once
Nested Iframe SupportScan 3+ levels deep in iframes

MCP Server (Model Context Protocol)

This package is a fully-featured MCP Server with 23 optimized browser automation tools for AI assistants like Claude, Cursor, Copilot, and other MCP-compatible clients. Tools intelligently merged for maximum efficiency with AI auto-healing capabilities.

Quick Start MCP Server

# Start the MCP server
npm run dev

# Or with verbose mode (shows all tool details)
npm run mcp:verbose

MCP Configuration

Add to your MCP client configuration (e.g., Claude Desktop):

{
  "mcpServers": {
    "brave-real-browser-mcp-server": {
      "command": "node",
      "args": [
        "C:/Users/Admin/Desktop/Brave-Real-Browser-Mcp-Server/dist/index.js"
      ],
      "env": {
        "HEADLESS": "false"
      }
    }
  }
}
"mcp": {
    "brave-real-browser-mcp-server": {
      "type": "local",
      "command": ["node", "c:\\Users\\Admin\\Desktop\\Brave-Real-Browser-Mcp-Server\\dist\\index.js"],
      "environment": {
        "HEADLESS": "false"
      },
      "enabled": true
    }
  },

Or if installed globally:

{
  "mcpServers": {
    "brave-browser": {
      "command": "brave-mcp"
    }
  }
}

Available MCP Tools (23 Optimized)

#ToolDescriptionStatus
1browser_init šŸš€Initialize Brave browser with 50+ stealth features, anti-detection, Turnstile auto-solver, proxy support, ad blocker, AI auto-healingāœ…
2navigate 🧭Navigate to URL with smart retry (3 attempts), context recovery, AI healing, customizable wait strategies (load/DOMContentLoaded/networkidle)āœ…
3get_content šŸ“„Get page content in 4 formats: html (full HTML), text (plain), markdown (formatted), rawHttp (raw HTTP without JS — fast, bypasses JS protections). AI selector healing + attribute extractionāœ… Enhanced
4wait ā³Smart wait: selector, navigation, timeout, networkidle, or AI-predicted optimal timingāœ…
5click šŸ‘†Human-like click with ghost cursor, AI healing, iframe support, hover-first for dynamic controls, auto video player detection (JWPlayer/VideoJS/Plyr/VidStack/DooPlayer)āœ…
6type āŒØļøType with human speed variation, smart clearing, iframe support, optional Enter key pressāœ…
7browser_close šŸ”“Close browser with cleanup, optional session save (cookies + storage)āœ…
8solve_captcha šŸ”“Auto-solve: Turnstile, reCAPTCHA, hCaptcha (JS-based) + Text/Image OCR. Merged with form automation — AI field matching, human-like typing, auto-submitāœ…
9random_scroll šŸ“œHuman-like scroll with AI pattern detection, lazy-load trigger, direction: up/down/random/smartāœ…
10find_element šŸ”Find elements by CSS selector, XPath, or text content. AI auto-heals broken selectors, extracts smart attributesāœ…
11save_content_as_markdown šŸ“Save page as AI-cleaned Markdown file — removes ads/clutter, includes images and metaāœ…
12redirect_tracer šŸ”€Trace full redirect chains: HTTP 301/302 + JS navigations (window.location, setTimeout) + meta refresh. Auto-decodes encoded URLs, returns status codes + headersāœ…
13extract_data šŸ”Ž8 modes: regex, json, meta, structured, auto, deobfuscate (JS decode: _0x arrays, hex, unicode, eval, webpack, terser, string concat, rotation), apiDiscovery (hidden APIs via runtime interception), decrypt (Base64 chain, hex, URL, ROT13, AES-256-CBC + auto key extract)āœ… Power
14press_key šŸŽ¹Press keyboard keys with human-like timing, modifier support (Ctrl/Shift/Alt), repeat countāœ…
15progress_tracker šŸ“ˆTrack automation progress (0-100%), AI estimates remaining timeāœ…
16deep_analysis 🧠Deep page analysis: DOM structure, scripts, anti-bot detection (Cloudflare/DataDome/reCAPTCHA), tech stack, SEO tags, security headers, AI scraping strategy recommendationsāœ…
17network_recorder šŸ“”9 actions: start (+ inject API interceptors for fetch/XHR/sendBeacon + WebSocket interceptor), stop, get, clear, get_media (HLS/DASH/video), get_navigations (JS redirects), get_api_calls (with full request/response bodies), get_intercepted_apis (runtime monkey-patched calls), get_websockets (all WS connections + messages)āœ… Power
18link_harvester šŸ”—Extract all links: hidden (display:none), Base64/URL encoded, obfuscated (data attrs, JS vars), iframe links (multi-level), dynamic links. Auto-decode enabledāœ…
19cookie_manager šŸŖCookie CRUD: get/set/delete/clear/export/import. AI optimizes session persistenceāœ…
20file_downloader ā¬‡ļøDownload files with resume support, batch download (multiple URLs), auto-decode Base64/URL encoded URLs, AES decryption for encrypted filesāœ…
21media_extractor šŸŽ¬6 actions: extract (video/audio/HLS/DASH/download from page + 3+ level nested iframes), list_iframes, switch_iframe, player_control (JWPlayer/VideoJS/Plyr/VidStack/DooPlayer — play/pause/seek/sources), decode_url (auto/url/base64/aes), batch_extractāœ… New
22execute_js šŸ’»Execute custom JavaScript: async support, error handling, iframe context execution (by index or selector), configurable timeoutāœ…
23form_automator šŸ“‹Smart form automation: AI field detection and matching, human-like typing, auto-fill, captcha integration, validation before submitāœ…

Tool Optimization Summary

Merged Tools (5 → 2):

  • āœ… iframe_handler + stream_extractor + player_api_hook → media_extractor
  • āœ… search_regex + extract_json + scrape_meta_tags → extract_data
  • āœ… get_content enhanced with js_scrape features

Benefits:

  • šŸŽÆ 18% reduction in tool count (28 → 23)
  • šŸš€ Simpler API for AI agents
  • šŸ’Ŗ More powerful combined features
  • šŸ¤– AI-first design with auto-healing
  • šŸ“¦ Decoder utilities built-in (URL, Base64, AES)

MCP Example Usage

User: Open a browser and go to example.com

AI: I'll use browser_init to start the browser, then navigate to the URL.

[Calls browser_init] -> Browser started
[Calls navigate with url="https://example.com"] -> Page loaded

User: Get all links on the page

AI: [Calls link_harvester] -> Found 15 links...

User: Download the main image

AI: [Calls file_downloader with url="..."] -> Downloaded to ./downloads/image.png

LSP Server (Language Server Protocol)

This package also includes a full-featured LSP Server for IDE code intelligence when writing browser automation scripts.

Quick Start LSP Server

# Start the LSP server
npm run lsp

LSP Capabilities

FeatureDescription
AutocompleteTool names, parameters, and enum values
HoverFull documentation on hover
DiagnosticsError & warning detection (missing browser_init, etc.)
SnippetsCode templates for common workflows
RefactoringQuick fixes (add browser_init, try-catch, etc.)
SimulationWorkflow simulation in IDE
Multi-languageEnglish & Hindi support

VS Code Setup

Create .vscode/settings.json in your project:

{
  "braveRealBrowser.language": "en",
  "braveRealBrowser.maxDiagnostics": 100,
  "braveRealBrowser.enableSnippets": true,
  "braveRealBrowser.enableSimulation": true,
  "braveRealBrowser.enableRefactoring": true
}

Diagnostic Features

The LSP detects common issues:

  • Missing browser_init() before page operations
  • Missing navigate() before content extraction
  • Invalid selectors and URLs
  • Missing required parameters
  • Unclosed browser sessions
  • Security issues (eval usage, etc.)

Quick Fixes

When diagnostics are detected, quick fixes are offered:

  • Add browser_init() at start
  • Add navigate() before page tools
  • Add browser_close() at end
  • Wrap in try-catch
  • Extract to function

AI Core (Automatic Enhancement)

All 23 tools are automatically enhanced with AI capabilities. No configuration needed - AI features work transparently.

How It Works

AI Agent calls any tool (e.g., click, type, find_element)
                │
                ā–¼
        ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
        │   AI Core Check   │
        │ (Lazy initialize) │
        ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                │
                ā–¼
        Execute Original Tool
                │
        ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
        │               │
     Success         Failed (selector not found)
        │               │
        ā–¼               ā–¼
   Return result    ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
   with _ai meta    │ AI Auto-Healing │
                    │ - Find alts     │
                    │ - Try healed    │
                    │ - Retry op      │
                    ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                            │
                            ā–¼
                    Return healed result

AI Features

FeatureDescription
Auto-Healing SelectorsIf a CSS selector fails, AI finds alternative selectors
Smart RetryFailed operations are automatically retried with AI assistance
Confidence ScoringAI provides confidence scores for healed selectors
CachingHealed selectors are cached for performance
Zero ConfigurationWorks out of the box with all 23 tools

Example Response with AI Metadata

When AI heals a broken selector:

{
  "success": true,
  "selector": "#new-login-btn",
  "clicked": true,
  "_ai": {
    "enabled": true,
    "healed": true,
    "originalSelector": "#old-login-button",
    "healedSelector": "#new-login-btn",
    "duration": 245
  }
}

AI Modules

ModuleDescription
AICoreCentral AI intelligence singleton
ElementFinderSmart element finding with multiple strategies
SelectorHealerAuto-fix broken CSS selectors
PageAnalyzerPage structure analysis
ActionParserNatural language command parsing

Programmatic Access

For advanced usage, you can access AI features directly:

const { getAICore, aiEnhancedSelector } = require('./src/mcp/handlers');

// Get AI Core instance
const ai = getAICore();

// Use AI-enhanced selector finding
const { element, selector, healed } = await aiEnhancedSelector(page, '#old-selector', 'click');

Unified Architecture

Both MCP and LSP servers share the same tool definitions:

src/
ā”œā”€ā”€ shared/
│   └── tools.js         # Single source of truth (28 tools)
ā”œā”€ā”€ ai/                  # AI Core Module (Auto-enhancement)
│   ā”œā”€ā”€ index.js         # AI module exports
│   ā”œā”€ā”€ core.js          # AI Core singleton
│   ā”œā”€ā”€ element-finder.js# Smart element finding
│   ā”œā”€ā”€ selector-healer.js# Auto-heal selectors
│   ā”œā”€ā”€ page-analyzer.js # Page analysis
│   └── action-parser.js # NL command parsing
ā”œā”€ā”€ mcp/
│   ā”œā”€ā”€ server.js        # MCP server for AI agents
│   └── handlers.js      # Tool implementations + AI integration
ā”œā”€ā”€ lsp/
│   ā”œā”€ā”€ server.js        # LSP server for IDEs
│   └── capabilities/    # Autocomplete, hover, diagnostics, etc.
└── index.js             # Unified entry point

Decoder Utilities (Built-in)

Powerful decoding capabilities for obfuscated content extraction:

DecoderDescriptionUse Cases
URL DecoderMulti-layer URL decodingObfuscated links, redirect chains
Base64 DecoderStandard, URL-safe, padded variantsEncoded parameters, tokens
AES DecryptorAES-256-CBC/ECB decryptionEncrypted streams, secure tokens
tryAll()Attempts all decoders automaticallyUnknown encoding detection

Usage Examples

// Automatic decoder (via media_extractor)
{
  "action": "decode_url",
  "encodedData": "aHR0cHM6Ly9leGFtcGxlLmNvbQ==",
  "decoderType": "auto"  // Tries all decoders
}

// Manual decoding options
{
  "action": "decode_url",
  "encodedData": "U2Fsd2Fy...",
  "decoderType": "aes",
  "aesKey": "my-secret-key",
  "aesIV": "initialization-vec"
}

Real-World Example: Movie Download Chain

// 1. Navigate to movie page
{ "tool": "navigate", "params": { "url": "https://moviesdrive.surf/movies/dhurandhar-2025/" }}

// 2. Click download button to get redirect
{ "tool": "click", "params": { "selector": "#hubcloud-480p" }}

// 3. Trace full redirect chain
{ "tool": "redirect_tracer", "params": { "url": "current_page_url", "followJS": true }}

// 4. Extract and decode obfuscated links
{ "tool": "extract_data", "params": { 
  "type": "regex", 
  "pattern": "hubcloud\\.fans/drive/[^\"']+",
  "autoDecode": true  // Auto-decode found URLs
}}

// 5. Get direct download link from nested iframes
{ "tool": "media_extractor", "params": { 
  "action": "extract",
  "types": ["download"],
  "deep": true  // Scan nested iframes
}}

šŸ”„ Deep Scraping Power Features

Advanced capabilities for bypassing obfuscation, intercepting hidden APIs, and decrypting encoded data.

1. Raw HTTP Mode (get_content)

Fetch raw HTML without JavaScript rendering — fast, lightweight, bypasses JS-based protections:

{ "tool": "get_content", "params": { "format": "rawHttp" }}
// Returns: raw HTML source code via Node.js fetch (no browser needed)

2. Enhanced Deobfuscation (extract_data)

Decode obfuscated JavaScript from any page:

{ "tool": "extract_data", "params": { "type": "deobfuscate" }}
CapabilityPattern
String arraysvar _0x3f0cd6 = [...]
Hex strings'\x68\x74\x74\x70' → http
Unicode escapes'\u0066\u0065\u0074\u0063\u0068' → fetch
Eval unpackereval(function(p,a,c,k,e,d){...})
Webpack modules__webpack_require__, module.exports
Terser mappingsvar a="fetch",b="POST"
String concat"htt"+"ps://"+"api" → https://api
Array rotationpush(arr.shift()) patterns

3. API Discovery (extract_data)

Find hidden API endpoints via static analysis + runtime interception:

{ "tool": "extract_data", "params": { "type": "apiDiscovery" }}
// Returns: fetchEndpoints, xhrEndpoints, formActions, scriptSources, dynamicApis

4. Response Auto-Decryption (extract_data)

Auto-detect and decode encrypted/encoded data:

// Auto-decrypt with key extraction from page scripts
{ "tool": "extract_data", "params": { "type": "decrypt", "encryptedData": "base64string..." }}

// With explicit AES key
{ "tool": "extract_data", "params": { "type": "decrypt", "encryptedData": "...", "aesKey": "secret" }}
DecoderDescription
Base64 chainRecursive decode up to 5 levels, auto-detect JSON
Hex68747470733a2f2f → https://
URL decodeMulti-level %2F%2F → //
ROT13Caesar cipher (reports if result contains URLs)
AES-256-CBCWith user key or auto-extracted key from CryptoJS patterns

5. Runtime API Interception (network_recorder)

Capture API calls from obfuscated/webpack code via pre-page-load monkey-patching:

// Start recording (injects interceptors via evaluateOnNewDocument)
{ "tool": "network_recorder", "params": { "action": "start" }}

// Navigate to page...

// Get intercepted APIs (caught from monkey-patched fetch/XHR/sendBeacon)
{ "tool": "network_recorder", "params": { "action": "get_intercepted_apis" }}
// Returns: { type, url, method, headers, body, timestamp }

6. WebSocket Recording (network_recorder)

Capture WebSocket connections and messages:

{ "tool": "network_recorder", "params": { "action": "get_websockets" }}
// Returns: { count, totalMessages, websockets: [{ id, url, status, messages }] }

7. XHR Body Capture (network_recorder)

Capture full request/response bodies for API calls:

{ "tool": "network_recorder", "params": { "action": "start", "captureXhrBody": true }}
// Later:
{ "tool": "network_recorder", "params": { "action": "get_api_calls" }}
// Returns: requestBody, responseBody, responseJson for each API call

Unified CLI

# List all tools (23 optimized)
node src/index.js --list

# Start MCP server (default)
node src/index.js mcp

# Start LSP server
node src/index.js lsp

# Show help
node src/index.js --help

Tool Categories

CategoryToolsDescription
Browser3Browser lifecycle (init, close, cookies)
Navigation1Page navigation with smart retry
Interaction4User actions with AI healing (click, type, scroll, key press)
Extraction5Content scraping (get_content, extract_data, link_harvester, media_extractor, deep_analysis)
Network3Network operations (recorder, download, trace)
Analysis2Page analysis and form automation
Utility5Helpers (wait, progress, elements, cookies, JavaScript)

Monorepo Ecosystem

brave-real-browser-mcp-server (Top Level - MCP Server)
    └── brave-real-puppeteer-core (Stealth patches)
        └── brave-real-launcher (Browser launch)
            └── brave-real-blocker (Ad/Tracker blocking - Singleton)

Package Details

PackageDescriptionnpm
brave-real-browser-mcp-serverMCP Server + Puppeteer integrationnpm
brave-real-puppeteer-core50+ stealth patches for Puppeteer/Playwrightnpm
brave-real-launcherBrave Browser launcher with auto-detectionnpm
brave-real-blockeruBlock Origin-based ad/tracker blocker (45+ filter sources, 100/100 score)npm

Ad Blocker Features (brave-real-blocker)

CategoryDetails
Filter Sources45+ lists (uBlock Origin, EasyList, AdGuard, Anti-Adblock, etc.)
Built-in Rules200+ aggressive blocking rules
Protection Layers5 layers (Ad blocking, Stealth, Scriptlets, Cosmetic, Redirect)
Test ScoreAdBlock Tester: 100/100
Auto-UpdateFilter lists cached 7 days, auto-refresh
SingletonSingle shared instance across ecosystem

Automation & CI/CD

GitHub Actions Workflows

WorkflowScheduleDescription
auto-update-deps.ymlDaily 6 AM UTCAuto-updates all dependencies across all packages
monorepo-publish.ymlDaily 6 AM UTC + Push/PRVersion bump + NPM publish for all packages

Auto-Update Flow

Daily 6 AM UTC
      ↓
Check all packages for outdated dependencies
      ↓
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│  brave-real-blocker                      │
│  brave-real-launcher                     │
│  brave-real-puppeteer-core               │
│  brave-real-browser-mcp-server           │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
      ↓
Update found? → Install → Build → Test → Commit → Push
      ↓
Trigger NPM Publish Workflow
      ↓
All packages published to NPM automatically

Dependencies Auto-Updated

PackageAuto-Updated Dependencies
blocker@cliqz/adblocker-puppeteer, cross-fetch, fs-extra
launcherwhich, escape-string-regexp, is-wsl
puppeteer-corepuppeteer-core, playwright-core, yargs
rootghost-cursor, puppeteer-extra, puppeteer-extra-plugin-stealth

Installation

npm install brave-real-browser-mcp-server

For Linux (required for headless mode):

sudo apt-get install xvfb

Quick Start

CommonJS

const { connect } = require('brave-real-browser-mcp-server');

(async () => {
  const { browser, page, blocker } = await connect({
    headless: false,
    turnstile: true,  // Auto-solve Cloudflare
  });

  await page.goto('https://example.com');

  // Human-like click with ghost-cursor
  await page.realClick('#button');

  await browser.close();
})();

ESM

import { connect } from 'brave-real-browser-mcp-server';

const { browser, page, blocker } = await connect({
  headless: false,
  turnstile: true,
});

await page.goto('https://example.com');
await page.realClick('#button');
await browser.close();

Connect Options

OptionTypeDefaultDescription
headlessboolean | 'new'falseHeadless mode (also respects .env HEADLESS variable)
argsstring[][]Additional Chrome flags
customConfigobject{}Brave launcher options
proxyProxyOptions{}Proxy configuration
turnstilebooleanfalseAuto-solve Cloudflare Turnstile
connectOptionobject{}Puppeteer connect options
disableXvfbbooleanfalseDisable virtual display (Linux)
pluginsarray[]Puppeteer-extra plugins
ignoreAllFlagsbooleanfalseOverride all default flags
enableBlockerbooleantrueEnable ad/tracker blocker
blockerOptionsBlockerOptions{}Blocker configuration

BlockerOptions

OptionTypeDefaultDescription
enableAdBlockingbooleantrueNetwork request blocking (Ads/Trackers)
enableStealthbooleantrueStealth evasions (Navigator, WebGL, etc.)
enableCosmeticFilteringbooleantrueElement hiding (CSS-based)
enableRedirectBlockingbooleantruePopup and redirect blocking
enableScriptletsbooleantrueScriptlet injection for anti-adblock
customFiltersPathstringnullPath to custom filter list file
enableFilterAutoUpdatebooleantrueAuto-update uBlock Origin filters

ProxyOptions

OptionTypeRequiredDescription
hoststringYesProxy host
portnumberYesProxy port
usernamestringNoProxy username
passwordstringNoProxy password

Usage Examples

Proxy Configuration

const { browser, page } = await connect({
  proxy: {
    host: '127.0.0.1',
    port: 8080,
    username: 'user',     // Optional
    password: 'pass'      // Optional
  }
});

Custom Brave Path

const { browser, page } = await connect({
  customConfig: {
    bravePath: 'C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe',
    userDataDir: './my-profile'
  }
});

Disable Blocker

const { browser, page } = await connect({
  enableBlocker: false,  // Disable all blocking
});

Custom Blocker Options

const { browser, page, blocker } = await connect({
  blockerOptions: {
    enableAdBlocking: true,
    enableStealth: true,
    enableCosmeticFiltering: true,
    enableRedirectBlocking: true,
    enableScriptlets: true,
    customFiltersPath: './my-filters.txt',
    enableFilterAutoUpdate: true,
  }
});

Real Cursor (Ghost-Cursor)

Built-in ghost-cursor for human-like mouse movements:

const { browser, page } = await connect();

// Human-like click
await page.realClick('#submit-button');

// Full cursor control
await page.realCursor.move('#element');
await page.realCursor.click('#button');

Turnstile Auto-Solver

Automatically solves Cloudflare Turnstile challenges:

const { browser, page } = await connect({
  turnstile: true
});

await page.goto('https://site-with-turnstile.com');
// Turnstile is automatically solved!

Puppeteer-Extra Plugins

const clickAndWait = require('puppeteer-extra-plugin-click-and-wait')();

const { browser, page } = await connect({
  plugins: [clickAndWait]
});

Singleton Blocker Usage

The blocker is a singleton - only one instance is created and shared:

// From brave-real-blocker package
import { 
  getBraveBlockerSingleton, 
  initBraveBlockerSingleton,
  isBraveBlockerInitialized 
} from 'brave-real-blocker/singleton';

// Initialize once at startup
const blocker = await initBraveBlockerSingleton({
  enableAdBlocking: true,
  enableStealth: true,
});

// Get the same instance anywhere else
const sameBlocker = getBraveBlockerSingleton();
console.log(blocker === sameBlocker); // true

Commands

Root Level

CommandDescription
npm startStart unified server (MCP by default)
npm run devStart MCP server
npm run mcpStart MCP server (alias)
npm run mcp:verboseStart MCP server with tool details
npm run lspStart LSP server for IDE intelligence
npm run lsp:tcpStart LSP server on TCP port 7777
npm run listList all 23 optimized tools with categories
npm installInstall dependencies + auto-build workspaces + Brave check
npm testRun all tests (CJS + ESM)
npm run cjs_testRun CommonJS tests only
npm run esm_testRun ESM tests only
npm run buildBuild root package (pre-built lib/)
npm run build:allBuild all workspace packages (blocker, launcher, puppeteer-core)
npm run clean:allClean all workspace build outputs
npm run test:allRun tests for all workspace packages
npm run update-depsManually check for dependency updates
npm run upstream-patchUpdate to latest upstream (puppeteer-core, playwright-core)
npm run lintRun linter

Note: npm install automatically runs npm run build:all to compile TypeScript packages (brave-real-blocker, brave-real-launcher) before the auto-update check. This ensures the browser tools work immediately after installation.

Workspace Scripts

CommandDescription
node scripts/prepare-publish.jsSync dependency versions before publish
node scripts/restore-workspace.jsVerify workspace linking
node scripts/version-bump.js patchIncrement all versions (patch/minor/major)

Package: brave-real-puppeteer-core

CommandDescription
npm run patch-puppeteerApply stealth patches to puppeteer-core
npm run patch-playwrightApply stealth patches to playwright-core
npm run patch-bothApply patches to both engines
npm run setup-puppeteerFull puppeteer setup with patches
npm run test-bot-detectorRun bot detection tests
npm run ai-agentRun AI agent tests

Package: brave-real-launcher

CommandDescription
npm run buildBuild the launcher
npm run test:detectionTest Brave browser detection

Package: brave-real-blocker

CommandDescription
npm run buildBuild the blocker
npm run visual-testRun visual blocking tests

Testing

# Run all 7 bot detector tests
npm test

# Run CJS tests only
npm run cjs_test

# Run ESM tests only
npm run esm_test

Test Coverage

All 7 bot detection tests pass:

TestDescriptionStatus
DrissionPage DetectorChinese bot detectorāœ… Pass
Sannysoft WebDriverWebDriver detectionāœ… Pass
Cloudflare WAFFull page challengeāœ… Pass
Cloudflare TurnstileCAPTCHA widgetāœ… Pass
FingerprintJSBrowser fingerprintingāœ… Pass
DatadomeAnti-bot detectionāœ… Pass
reCAPTCHA v3Google score test (0.7+)āœ… Pass

Docker

Build and Run

# Build the image
docker build -t brave-real-browser-mcp-server .

# Run tests in container
docker run brave-real-browser-mcp-server

# Run with custom command
docker run brave-real-browser-mcp-server npm run esm_test

Docker Features

  • Multi-stage build for smaller image size
  • Node.js 20 LTS (pinned version)
  • Non-root user for security
  • Health check included
  • Headless mode enabled by default

Project Structure

brave-real-browser-mcp-server/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ shared/
│   │   └── tools.js              # Single source of truth (23 optimized tools)
│   ā”œā”€ā”€ mcp/                      # MCP Server
│   │   ā”œā”€ā”€ index.js              # Entry point with startup logs
│   │   ā”œā”€ā”€ server.js             # MCP server with STDIO transport
│   │   ā”œā”€ā”€ handlers.js           # 23 optimized tool implementations + decoders
│   │   └── tools.js              # Re-export from shared
│   ā”œā”€ā”€ lsp/                      # LSP Server
│   │   ā”œā”€ā”€ server.js             # LSP server for IDE intelligence
│   │   └── capabilities/         # Autocomplete, hover, diagnostics
│   └── ai/                       # AI Core Module
│       ā”œā”€ā”€ core.js               # AI Core singleton
│       ā”œā”€ā”€ element-finder.js     # Smart element finding
│       ā”œā”€ā”€ selector-healer.js    # Auto-heal broken selectors
│       ā”œā”€ā”€ page-analyzer.js      # Page analysis
│       └── action-parser.js      # Natural language parsing
ā”œā”€ā”€ lib/
│   ā”œā”€ā”€ cjs/                      # CommonJS build
│   └── esm/                      # ESM build
ā”œā”€ā”€ packages/
│   ā”œā”€ā”€ brave-real-blocker/       # Ad/Tracker blocker (singleton)
│   │   ā”œā”€ā”€ src/
│   │   │   ā”œā”€ā”€ brave-blocker.ts
│   │   │   ā”œā”€ā”€ singleton.ts      # Singleton pattern
│   │   │   ā”œā”€ā”€ stealth.ts
│   │   │   ā”œā”€ā”€ cosmetic.ts
│   │   │   └── scriptlets.ts
│   │   └── package.json
│   ā”œā”€ā”€ brave-real-launcher/      # Browser launcher
│   │   └── package.json
│   └── brave-real-puppeteer-core/  # Stealth patches
│       └── package.json
ā”œā”€ā”€ scripts/
│   ā”œā”€ā”€ prepare-publish.js        # Sync versions before publish
│   ā”œā”€ā”€ restore-workspace.js      # Verify workspace
│   └── version-bump.js           # Version management
ā”œā”€ā”€ .github/
│   └── workflows/
│       ā”œā”€ā”€ auto-update-deps.yml      # Daily dependency updates
│       └── monorepo-publish.yml      # Auto-publish to NPM
ā”œā”€ā”€ test/
│   ā”œā”€ā”€ cjs/                      # CJS tests
│   └── esm/                      # ESM tests
ā”œā”€ā”€ Dockerfile
ā”œā”€ā”€ typings.d.ts
└── package.json                  # Root with workspaces

Environment Variables

Create a .env file in your project root:

# Headless mode (true = headless, false = GUI)
HEADLESS=true

The library automatically reads .env files and respects the HEADLESS variable.

Re-exports

Access brave-real-launcher features directly:

const { 
  connect,
  launcher,      // brave-real-launcher module
  launch,        // Direct browser launch
  killAll,       // Kill all browsers
  getBravePath,  // Get Brave path
  DEFAULT_FLAGS  // Default browser flags
} = require('brave-real-browser-mcp-server');

TypeScript

Full TypeScript support with type definitions:

import { connect, Options, ConnectResult } from 'brave-real-browser-mcp-server';

const options: Options = {
  headless: false,
  turnstile: true,
  enableBlocker: true,
  blockerOptions: {
    enableAdBlocking: true,
    enableStealth: true,
  }
};

const { browser, page, blocker }: ConnectResult = await connect(options);

Real-World Examples

Example 1: Complete Movie Download Chain

Use Case: Extract download links from movie streaming sites with multi-layer redirects

// Step 1: Initialize browser with all protections
{
  "tool": "browser_init",
  "params": {
    "headless": false,
    "turnstile": true,
    "enableBlocker": true
  }
}

// Step 2: Navigate to movie page
{
  "tool": "navigate",
  "params": {
    "url": "https://moviesdrive.surf/movies/dhurandhar-2025/",
    "waitUntil": "networkidle2",
    "smartWait": true
  }
}

// Step 3: Find and click quality selector
{
  "tool": "click",
  "params": {
    "selector": "a[href*='hubcloud']",
    "humanLike": true,
    "aiHeal": true
  }
}

// Step 4: Wait for redirect chain to complete
{
  "tool": "wait",
  "params": {
    "type": "smart",
    "value": "2000",
    "aiOptimize": true
  }
}

// Step 5: Trace complete redirect chain
{
  "tool": "redirect_tracer",
  "params": {
    "url": "current",
    "followJS": true,
    "followMeta": true,
    "decodeURLs": true
  }
}

// Step 6: Extract obfuscated download links
{
  "tool": "extract_data",
  "params": {
    "type": "regex",
    "pattern": "https?://[^\"'<>\\s]+\\.(mkv|mp4|avi)",
    "autoDecode": true,
    "source": "all"
  }
}

// Step 7: Extract from nested iframes if present
{
  "tool": "media_extractor",
  "params": {
    "action": "extract",
    "types": ["download", "video"],
    "deep": true,
    "aiOptimize": true
  }
}

// Step 8: Download the file
{
  "tool": "file_downloader",
  "params": {
    "url": "extracted_download_link",
    "directory": "./downloads",
    "resume": true
  }
}

// Step 9: Cleanup
{
  "tool": "browser_close",
  "params": {
    "saveSession": false
  }
}

Example 2: TV Show Episode Batch Extraction

Use Case: Extract all episodes from a TV show season

// Navigate to TV show page
{
  "tool": "navigate",
  "params": { "url": "https://multimovies.gripe/tvshows/sacred-games/" }
}

// Extract all episode links
{
  "tool": "extract_data",
  "params": {
    "type": "structured",
    "selector": ".episode-item a",
    "extractAttributes": true
  }
}

// For each episode, extract streaming sources
{
  "tool": "media_extractor",
  "params": {
    "action": "batch_extract",
    "urls": ["episode1_url", "episode2_url", "..."],
    "types": ["hls", "dash", "download"],
    "deep": true
  }
}

// Get network recorded streams
{
  "tool": "network_recorder",
  "params": {
    "action": "get_media",
    "aiDetectStreams": true
  }
}

Use Case: Find hidden/obfuscated links on complex pages

// Navigate to target
{
  "tool": "navigate",
  "params": { "url": "https://example-site.com/protected-content/" }
}

// Harvest all links including hidden/encoded ones
{
  "tool": "link_harvester",
  "params": {
    "includeHidden": true,
    "autoDecode": true,
    "detectObfuscation": true,
    "searchIframes": true,
    "types": ["all"]
  }
}

// Decode any obfuscated links found
{
  "tool": "media_extractor",
  "params": {
    "action": "decode_url",
    "encodedData": "aHR0cHM6Ly9leGFtcGxlLmNvbQ==",
    "decoderType": "auto"
  }
}

Example 4: Form Automation with AI Detection

Use Case: Automatically fill and submit complex forms

// Navigate to form page
{
  "tool": "navigate",
  "params": { "url": "https://example.com/contact-form/" }
}

// AI-powered form detection and filling
{
  "tool": "form_automator",
  "params": {
    "data": {
      "name": "John Doe",
      "email": "john@example.com",
      "message": "Hello, this is a test message",
      "country": "United States"
    },
    "aiMatch": true,
    "aiValidate": true,
    "humanLike": true,
    "captcha": true,
    "submit": true
  }
}

Example 5: Streaming Media Extraction

Use Case: Extract video streams from JWPlayer, VideoJS, custom players

// Navigate to video page
{
  "tool": "navigate",
  "params": { 
    "url": "https://multimovies.gripe/movies/movie-name/",
    "waitUntil": "networkidle0"
  }
}

// Start recording network
{
  "tool": "network_recorder",
  "params": { "action": "start", "aiDetectStreams": true }
}

// Extract all media types
{
  "tool": "media_extractor",
  "params": {
    "action": "extract",
    "types": ["hls", "dash", "video", "audio", "download"],
    "quality": "all",
    "deep": true
  }
}

// Get all recorded streams
{
  "tool": "network_recorder",
  "params": { 
    "action": "get_media",
    "filter": { "type": "m3u8" }
  }
}

// Control player if needed
{
  "tool": "media_extractor",
  "params": {
    "action": "player_control",
    "playerAction": "sources"
  }
}

FAQ

Why can't I pass reCAPTCHA v3?

When there's no Google session, reCAPTCHA identifies you as a bot. This is a known limitation - log into a Google account first.

page.setViewport not working?

Set defaultViewport in connectOption:

const { browser, page } = await connect({
  connectOption: { defaultViewport: null }
});

Mouse positions don't match?

This is automatically patched. Use page.realClick() for best results.

How to disable ad blocker?

const { browser, page } = await connect({
  enableBlocker: false
});

How to use custom filter lists?

const { browser, page } = await connect({
  blockerOptions: {
    customFiltersPath: './my-custom-filters.txt'
  }
});

How does the singleton blocker work?

The blocker uses a global Symbol-based singleton pattern. No matter how many times you import it, the same instance is shared across the entire Node.js process, preventing duplicate filter loading and saving memory.

How does npm workspaces linking work?

When packages are listed in the root package.json workspaces array, npm automatically creates symlinks to local packages instead of downloading from npm registry. This enables seamless local development.

Requirements

  • Node.js >= 18.0.0
  • Brave Browser (auto-installed if missing)
  • Linux: xvfb package for headless mode

License

ISC - See LICENSE

Credits

  • rebrowser - Runtime patches
  • ghost-cursor - Human-like mouse movements
  • brave-real-launcher - Brave Browser launcher
  • @cliqz/adblocker-puppeteer - Ad blocking engine
  • uBlock Origin - Filter lists

Contributing

  • Fork the repository
  • Create your feature branch (git checkout -b feature/amazing-feature)
  • Commit your changes (git commit -m 'Add amazing feature')
  • Push to the branch (git push origin feature/amazing-feature)
  • Open a Pull Request

Support

Changelog

See Releases for version history and changes.

Keywords

mcp-server

FAQs

Package last updated on 03 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts