brave-real-browser-mcp-server 2.37.2 → 2.37.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 +591 -43
- package/package.json +2 -2
- package/packages/brave-real-blocker/package.json +2 -2
- package/packages/brave-real-launcher/package.json +2 -2
- package/packages/brave-real-puppeteer-core/package.json +2 -2
- package/src/mcp/handlers.js +1680 -2682
- package/src/shared/tools.js +208 -502
- package/test/cjs/test.js +33 -91
- package/test/esm/test.js +15 -37
- package/data/.gitkeep +0 -2
- package/src/ai/error-collector.js +0 -498
- package/src/ai/hindi-suggester.js +0 -505
- package/src/ai/pattern-learner.js +0 -561
- package/src/ai/result-validator.js +0 -666
- package/src/mcp/handlers-fixed.js +0 -2499
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ A production-ready MCP (Model Context Protocol) server that combines Puppeteer w
|
|
|
14
14
|
|
|
15
15
|
| Feature | Description |
|
|
16
16
|
|---------|-------------|
|
|
17
|
-
| **MCP Server** | Model Context Protocol compatible server with
|
|
17
|
+
| **MCP Server** | Model Context Protocol compatible server with 23 optimized tools |
|
|
18
18
|
| **LSP Server** | Language Server Protocol for IDE code intelligence |
|
|
19
19
|
| **AI Core** | Automatic AI enhancement for all tools (auto-healing, smart retry) |
|
|
20
20
|
| Brave Browser | Uses Brave instead of Chromium for better privacy |
|
|
@@ -32,12 +32,15 @@ A production-ready MCP (Model Context Protocol) server that combines Puppeteer w
|
|
|
32
32
|
| **Auto-Publish** | Automatic NPM publishing on updates |
|
|
33
33
|
| **Monorepo** | npm workspaces with linked packages |
|
|
34
34
|
| **Singleton Blocker** | Single shared blocker instance |
|
|
35
|
+
| **Decoder Utilities** | URL, Base64, AES decryption built-in |
|
|
36
|
+
| **Batch Operations** | Extract from multiple URLs/pages at once |
|
|
37
|
+
| **Nested Iframe Support** | Scan 3+ levels deep in iframes |
|
|
35
38
|
|
|
36
39
|
---
|
|
37
40
|
|
|
38
41
|
## MCP Server (Model Context Protocol)
|
|
39
42
|
|
|
40
|
-
This package is a fully-featured MCP Server with **
|
|
43
|
+
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.
|
|
41
44
|
|
|
42
45
|
### Quick Start MCP Server
|
|
43
46
|
|
|
@@ -76,38 +79,47 @@ Or if installed globally:
|
|
|
76
79
|
}
|
|
77
80
|
```
|
|
78
81
|
|
|
79
|
-
### Available MCP Tools (
|
|
80
|
-
|
|
81
|
-
| # | Tool | Emoji | Description |
|
|
82
|
-
|
|
83
|
-
| 1 | `browser_init` |
|
|
84
|
-
| 2 | `navigate` |
|
|
85
|
-
| 3 | `get_content` |
|
|
86
|
-
| 4 | `wait` |
|
|
87
|
-
| 5 | `click` |
|
|
88
|
-
| 6 | `type` |
|
|
89
|
-
| 7 | `browser_close` |
|
|
90
|
-
| 8 | `solve_captcha` |
|
|
91
|
-
| 9 | `random_scroll` |
|
|
92
|
-
| 10 | `find_element` |
|
|
93
|
-
| 11 | `save_content_as_markdown` |
|
|
94
|
-
| 12 | `redirect_tracer` |
|
|
95
|
-
| 13 |
|
|
96
|
-
| 14 | `
|
|
97
|
-
| 15 | `
|
|
98
|
-
| 16 | `
|
|
99
|
-
| 17 | `
|
|
100
|
-
| 18 | `
|
|
101
|
-
| 19 | `
|
|
102
|
-
| 20 | `
|
|
103
|
-
| 21 |
|
|
104
|
-
| 22 | `
|
|
105
|
-
| 23 | `
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
82
|
+
### Available MCP Tools (23 Optimized)
|
|
83
|
+
|
|
84
|
+
| # | Tool | Emoji | Description | Status |
|
|
85
|
+
|---|------|-------|-------------|--------|
|
|
86
|
+
| 1 | `browser_init` | 🚀 | Initialize Brave browser with stealth, anti-detection & AI healing | ✅ |
|
|
87
|
+
| 2 | `navigate` | 🧭 | Navigate to URL with smart retry, context recovery & AI healing | ✅ |
|
|
88
|
+
| 3 | `get_content` | 📄 | Get page content with JS rendering, smart selectors & AI healing | ✅ Enhanced |
|
|
89
|
+
| 4 | `wait` | ⏳ | Smart wait with AI prediction for optimal timing | ✅ |
|
|
90
|
+
| 5 | `click` | 👆 | Human-like click with AI healing and auto-retry | ✅ |
|
|
91
|
+
| 6 | `type` | ⌨️ | Type text with human speed variation and smart clearing | ✅ |
|
|
92
|
+
| 7 | `browser_close` | 🔴 | Close browser with cleanup and session save | ✅ |
|
|
93
|
+
| 8 | `solve_captcha` | 🔓 | Auto-solve CAPTCHA (Turnstile, reCAPTCHA, hCaptcha) | ✅ |
|
|
94
|
+
| 9 | `random_scroll` | 📜 | Human-like random scrolling with AI pattern detection | ✅ |
|
|
95
|
+
| 10 | `find_element` | 🔍 | Find elements by selector/xpath/text with AI healing | ✅ |
|
|
96
|
+
| 11 | `save_content_as_markdown` | 📝 | Save page as AI-enhanced Markdown file | ✅ |
|
|
97
|
+
| 12 | `redirect_tracer` | 🔀 | Trace all redirects including JS-based and meta refreshes | ✅ |
|
|
98
|
+
| 13 | **`extract_data`** | 🔎 | **MERGED:** Extract data using regex, JSON, meta tags, or structured selectors | ✅ **New** |
|
|
99
|
+
| 14 | `press_key` | 🎹 | Press keyboard keys with human-like timing | ✅ |
|
|
100
|
+
| 15 | `progress_tracker` | 📈 | Track automation progress with AI predictions | ✅ |
|
|
101
|
+
| 16 | `deep_analysis` | 🧠 | Deep page analysis with AI insights and recommendations | ✅ |
|
|
102
|
+
| 17 | `network_recorder` | 📡 | Record network with AI media detection and stream extraction | ✅ |
|
|
103
|
+
| 18 | `link_harvester` | 🔗 | Extract all links including hidden, encoded, and obfuscated | ✅ |
|
|
104
|
+
| 19 | `cookie_manager` | 🍪 | Smart cookie management with AI session persistence | ✅ |
|
|
105
|
+
| 20 | `file_downloader` | ⬇️ | Download files with resume, batch, and auto-decrypt support | ✅ |
|
|
106
|
+
| 21 | **`media_extractor`** | 🎬 | **MERGED:** Universal media extraction (iframes, streams, players, decoders) | ✅ **New** |
|
|
107
|
+
| 22 | `execute_js` | 💻 | Execute custom JavaScript with async support | ✅ |
|
|
108
|
+
| 23 | `form_automator` | 📋 | Smart form automation with AI field detection | ✅ |
|
|
109
|
+
|
|
110
|
+
#### Tool Optimization Summary
|
|
111
|
+
|
|
112
|
+
**Merged Tools (5 → 2):**
|
|
113
|
+
- ✅ `iframe_handler` + `stream_extractor` + `player_api_hook` → **`media_extractor`**
|
|
114
|
+
- ✅ `search_regex` + `extract_json` + `scrape_meta_tags` → **`extract_data`**
|
|
115
|
+
- ✅ `get_content` enhanced with `js_scrape` features
|
|
116
|
+
|
|
117
|
+
**Benefits:**
|
|
118
|
+
- 🎯 **18% reduction** in tool count (28 → 23)
|
|
119
|
+
- 🚀 **Simpler API** for AI agents
|
|
120
|
+
- 💪 **More powerful** combined features
|
|
121
|
+
- 🤖 **AI-first design** with auto-healing
|
|
122
|
+
- 📦 **Decoder utilities** built-in (URL, Base64, AES)
|
|
111
123
|
|
|
112
124
|
### MCP Example Usage
|
|
113
125
|
|
|
@@ -153,9 +165,46 @@ npm run lsp
|
|
|
153
165
|
| **Simulation** | Workflow simulation in IDE |
|
|
154
166
|
| **Multi-language** | English & Hindi support |
|
|
155
167
|
|
|
168
|
+
### VS Code Setup
|
|
169
|
+
|
|
170
|
+
Create `.vscode/settings.json` in your project:
|
|
171
|
+
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"braveRealBrowser.language": "en",
|
|
175
|
+
"braveRealBrowser.maxDiagnostics": 100,
|
|
176
|
+
"braveRealBrowser.enableSnippets": true,
|
|
177
|
+
"braveRealBrowser.enableSimulation": true,
|
|
178
|
+
"braveRealBrowser.enableRefactoring": true
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Diagnostic Features
|
|
183
|
+
|
|
184
|
+
The LSP detects common issues:
|
|
185
|
+
|
|
186
|
+
- Missing `browser_init()` before page operations
|
|
187
|
+
- Missing `navigate()` before content extraction
|
|
188
|
+
- Invalid selectors and URLs
|
|
189
|
+
- Missing required parameters
|
|
190
|
+
- Unclosed browser sessions
|
|
191
|
+
- Security issues (eval usage, etc.)
|
|
192
|
+
|
|
193
|
+
### Quick Fixes
|
|
194
|
+
|
|
195
|
+
When diagnostics are detected, quick fixes are offered:
|
|
196
|
+
|
|
197
|
+
- Add `browser_init()` at start
|
|
198
|
+
- Add `navigate()` before page tools
|
|
199
|
+
- Add `browser_close()` at end
|
|
200
|
+
- Wrap in try-catch
|
|
201
|
+
- Extract to function
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
156
205
|
## AI Core (Automatic Enhancement)
|
|
157
206
|
|
|
158
|
-
All
|
|
207
|
+
All 23 tools are automatically enhanced with AI capabilities. No configuration needed - AI features work transparently.
|
|
159
208
|
|
|
160
209
|
### How It Works
|
|
161
210
|
|
|
@@ -195,7 +244,7 @@ AI Agent calls any tool (e.g., click, type, find_element)
|
|
|
195
244
|
| **Smart Retry** | Failed operations are automatically retried with AI assistance |
|
|
196
245
|
| **Confidence Scoring** | AI provides confidence scores for healed selectors |
|
|
197
246
|
| **Caching** | Healed selectors are cached for performance |
|
|
198
|
-
| **Zero Configuration** | Works out of the box with all
|
|
247
|
+
| **Zero Configuration** | Works out of the box with all 23 tools |
|
|
199
248
|
|
|
200
249
|
### Example Response with AI Metadata
|
|
201
250
|
|
|
@@ -215,6 +264,17 @@ When AI heals a broken selector:
|
|
|
215
264
|
}
|
|
216
265
|
}
|
|
217
266
|
```
|
|
267
|
+
|
|
268
|
+
### AI Modules
|
|
269
|
+
|
|
270
|
+
| Module | Description |
|
|
271
|
+
|--------|-------------|
|
|
272
|
+
| `AICore` | Central AI intelligence singleton |
|
|
273
|
+
| `ElementFinder` | Smart element finding with multiple strategies |
|
|
274
|
+
| `SelectorHealer` | Auto-fix broken CSS selectors |
|
|
275
|
+
| `PageAnalyzer` | Page structure analysis |
|
|
276
|
+
| `ActionParser` | Natural language command parsing |
|
|
277
|
+
|
|
218
278
|
### Programmatic Access
|
|
219
279
|
|
|
220
280
|
For advanced usage, you can access AI features directly:
|
|
@@ -255,10 +315,70 @@ src/
|
|
|
255
315
|
└── index.js # Unified entry point
|
|
256
316
|
```
|
|
257
317
|
|
|
318
|
+
## Decoder Utilities (Built-in)
|
|
319
|
+
|
|
320
|
+
Powerful decoding capabilities for obfuscated content extraction:
|
|
321
|
+
|
|
322
|
+
| Decoder | Description | Use Cases |
|
|
323
|
+
|---------|-------------|-----------|
|
|
324
|
+
| **URL Decoder** | Multi-layer URL decoding | Obfuscated links, redirect chains |
|
|
325
|
+
| **Base64 Decoder** | Standard, URL-safe, padded variants | Encoded parameters, tokens |
|
|
326
|
+
| **AES Decryptor** | AES-256-CBC/ECB decryption | Encrypted streams, secure tokens |
|
|
327
|
+
| **tryAll()** | Attempts all decoders automatically | Unknown encoding detection |
|
|
328
|
+
|
|
329
|
+
### Usage Examples
|
|
330
|
+
|
|
331
|
+
```javascript
|
|
332
|
+
// Automatic decoder (via media_extractor)
|
|
333
|
+
{
|
|
334
|
+
"action": "decode_url",
|
|
335
|
+
"encodedData": "aHR0cHM6Ly9leGFtcGxlLmNvbQ==",
|
|
336
|
+
"decoderType": "auto" // Tries all decoders
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Manual decoding options
|
|
340
|
+
{
|
|
341
|
+
"action": "decode_url",
|
|
342
|
+
"encodedData": "U2Fsd2Fy...",
|
|
343
|
+
"decoderType": "aes",
|
|
344
|
+
"aesKey": "my-secret-key",
|
|
345
|
+
"aesIV": "initialization-vec"
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Real-World Example: Movie Download Chain
|
|
350
|
+
|
|
351
|
+
```javascript
|
|
352
|
+
// 1. Navigate to movie page
|
|
353
|
+
{ "tool": "navigate", "params": { "url": "https://moviesdrive.surf/movies/dhurandhar-2025/" }}
|
|
354
|
+
|
|
355
|
+
// 2. Click download button to get redirect
|
|
356
|
+
{ "tool": "click", "params": { "selector": "#hubcloud-480p" }}
|
|
357
|
+
|
|
358
|
+
// 3. Trace full redirect chain
|
|
359
|
+
{ "tool": "redirect_tracer", "params": { "url": "current_page_url", "followJS": true }}
|
|
360
|
+
|
|
361
|
+
// 4. Extract and decode obfuscated links
|
|
362
|
+
{ "tool": "extract_data", "params": {
|
|
363
|
+
"type": "regex",
|
|
364
|
+
"pattern": "hubcloud\\.fans/drive/[^\"']+",
|
|
365
|
+
"autoDecode": true // Auto-decode found URLs
|
|
366
|
+
}}
|
|
367
|
+
|
|
368
|
+
// 5. Get direct download link from nested iframes
|
|
369
|
+
{ "tool": "media_extractor", "params": {
|
|
370
|
+
"action": "extract",
|
|
371
|
+
"types": ["download"],
|
|
372
|
+
"deep": true // Scan nested iframes
|
|
373
|
+
}}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
258
378
|
### Unified CLI
|
|
259
379
|
|
|
260
380
|
```bash
|
|
261
|
-
# List all tools
|
|
381
|
+
# List all tools (23 optimized)
|
|
262
382
|
node src/index.js --list
|
|
263
383
|
|
|
264
384
|
# Start MCP server (default)
|
|
@@ -270,6 +390,21 @@ node src/index.js lsp
|
|
|
270
390
|
# Show help
|
|
271
391
|
node src/index.js --help
|
|
272
392
|
```
|
|
393
|
+
|
|
394
|
+
### Tool Categories
|
|
395
|
+
|
|
396
|
+
| Category | Tools | Description |
|
|
397
|
+
|----------|-------|-------------|
|
|
398
|
+
| **Browser** | 3 | Browser lifecycle (init, close, cookies) |
|
|
399
|
+
| **Navigation** | 1 | Page navigation with smart retry |
|
|
400
|
+
| **Interaction** | 4 | User actions with AI healing (click, type, scroll, key press) |
|
|
401
|
+
| **Extraction** | 5 | Content scraping (get_content, extract_data, link_harvester, media_extractor, deep_analysis) |
|
|
402
|
+
| **Network** | 3 | Network operations (recorder, download, trace) |
|
|
403
|
+
| **Analysis** | 2 | Page analysis and form automation |
|
|
404
|
+
| **Utility** | 5 | Helpers (wait, progress, elements, cookies, JavaScript) |
|
|
405
|
+
|
|
406
|
+
---
|
|
407
|
+
|
|
273
408
|
## Monorepo Ecosystem
|
|
274
409
|
|
|
275
410
|
```
|
|
@@ -336,6 +471,53 @@ All packages published to NPM automatically
|
|
|
336
471
|
```bash
|
|
337
472
|
npm install brave-real-browser-mcp-server
|
|
338
473
|
```
|
|
474
|
+
|
|
475
|
+
For Linux (required for headless mode):
|
|
476
|
+
```bash
|
|
477
|
+
sudo apt-get install xvfb
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
---
|
|
481
|
+
|
|
482
|
+
## Quick Start
|
|
483
|
+
|
|
484
|
+
### CommonJS
|
|
485
|
+
|
|
486
|
+
```javascript
|
|
487
|
+
const { connect } = require('brave-real-browser-mcp-server');
|
|
488
|
+
|
|
489
|
+
(async () => {
|
|
490
|
+
const { browser, page, blocker } = await connect({
|
|
491
|
+
headless: false,
|
|
492
|
+
turnstile: true, // Auto-solve Cloudflare
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
await page.goto('https://example.com');
|
|
496
|
+
|
|
497
|
+
// Human-like click with ghost-cursor
|
|
498
|
+
await page.realClick('#button');
|
|
499
|
+
|
|
500
|
+
await browser.close();
|
|
501
|
+
})();
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### ESM
|
|
505
|
+
|
|
506
|
+
```javascript
|
|
507
|
+
import { connect } from 'brave-real-browser-mcp-server';
|
|
508
|
+
|
|
509
|
+
const { browser, page, blocker } = await connect({
|
|
510
|
+
headless: false,
|
|
511
|
+
turnstile: true,
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
await page.goto('https://example.com');
|
|
515
|
+
await page.realClick('#button');
|
|
516
|
+
await browser.close();
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
339
521
|
## Connect Options
|
|
340
522
|
|
|
341
523
|
| Option | Type | Default | Description |
|
|
@@ -390,6 +572,104 @@ const { browser, page } = await connect({
|
|
|
390
572
|
});
|
|
391
573
|
```
|
|
392
574
|
|
|
575
|
+
### Custom Brave Path
|
|
576
|
+
|
|
577
|
+
```javascript
|
|
578
|
+
const { browser, page } = await connect({
|
|
579
|
+
customConfig: {
|
|
580
|
+
bravePath: 'C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe',
|
|
581
|
+
userDataDir: './my-profile'
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
### Disable Blocker
|
|
587
|
+
|
|
588
|
+
```javascript
|
|
589
|
+
const { browser, page } = await connect({
|
|
590
|
+
enableBlocker: false, // Disable all blocking
|
|
591
|
+
});
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
### Custom Blocker Options
|
|
595
|
+
|
|
596
|
+
```javascript
|
|
597
|
+
const { browser, page, blocker } = await connect({
|
|
598
|
+
blockerOptions: {
|
|
599
|
+
enableAdBlocking: true,
|
|
600
|
+
enableStealth: true,
|
|
601
|
+
enableCosmeticFiltering: true,
|
|
602
|
+
enableRedirectBlocking: true,
|
|
603
|
+
enableScriptlets: true,
|
|
604
|
+
customFiltersPath: './my-filters.txt',
|
|
605
|
+
enableFilterAutoUpdate: true,
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
### Real Cursor (Ghost-Cursor)
|
|
611
|
+
|
|
612
|
+
Built-in ghost-cursor for human-like mouse movements:
|
|
613
|
+
|
|
614
|
+
```javascript
|
|
615
|
+
const { browser, page } = await connect();
|
|
616
|
+
|
|
617
|
+
// Human-like click
|
|
618
|
+
await page.realClick('#submit-button');
|
|
619
|
+
|
|
620
|
+
// Full cursor control
|
|
621
|
+
await page.realCursor.move('#element');
|
|
622
|
+
await page.realCursor.click('#button');
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
### Turnstile Auto-Solver
|
|
626
|
+
|
|
627
|
+
Automatically solves Cloudflare Turnstile challenges:
|
|
628
|
+
|
|
629
|
+
```javascript
|
|
630
|
+
const { browser, page } = await connect({
|
|
631
|
+
turnstile: true
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
await page.goto('https://site-with-turnstile.com');
|
|
635
|
+
// Turnstile is automatically solved!
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
### Puppeteer-Extra Plugins
|
|
639
|
+
|
|
640
|
+
```javascript
|
|
641
|
+
const clickAndWait = require('puppeteer-extra-plugin-click-and-wait')();
|
|
642
|
+
|
|
643
|
+
const { browser, page } = await connect({
|
|
644
|
+
plugins: [clickAndWait]
|
|
645
|
+
});
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
### Singleton Blocker Usage
|
|
649
|
+
|
|
650
|
+
The blocker is a singleton - only one instance is created and shared:
|
|
651
|
+
|
|
652
|
+
```javascript
|
|
653
|
+
// From brave-real-blocker package
|
|
654
|
+
import {
|
|
655
|
+
getBraveBlockerSingleton,
|
|
656
|
+
initBraveBlockerSingleton,
|
|
657
|
+
isBraveBlockerInitialized
|
|
658
|
+
} from 'brave-real-blocker/singleton';
|
|
659
|
+
|
|
660
|
+
// Initialize once at startup
|
|
661
|
+
const blocker = await initBraveBlockerSingleton({
|
|
662
|
+
enableAdBlocking: true,
|
|
663
|
+
enableStealth: true,
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
// Get the same instance anywhere else
|
|
667
|
+
const sameBlocker = getBraveBlockerSingleton();
|
|
668
|
+
console.log(blocker === sameBlocker); // true
|
|
669
|
+
```
|
|
670
|
+
|
|
671
|
+
---
|
|
672
|
+
|
|
393
673
|
## Commands
|
|
394
674
|
|
|
395
675
|
### Root Level
|
|
@@ -401,7 +681,7 @@ const { browser, page } = await connect({
|
|
|
401
681
|
| `npm run mcp` | Start MCP server (alias) |
|
|
402
682
|
| `npm run mcp:verbose` | Start MCP server with tool details |
|
|
403
683
|
| `npm run lsp` | Start LSP server for IDE intelligence |
|
|
404
|
-
| `npm run list` | List all
|
|
684
|
+
| `npm run list` | List all 23 optimized tools with categories |
|
|
405
685
|
| `npm install` | Install all dependencies with workspace linking |
|
|
406
686
|
| `npm test` | Run all tests (CJS + ESM) |
|
|
407
687
|
| `npm run cjs_test` | Run CommonJS tests only |
|
|
@@ -504,11 +784,22 @@ docker run brave-real-browser-mcp-server npm run esm_test
|
|
|
504
784
|
```
|
|
505
785
|
brave-real-browser-mcp-server/
|
|
506
786
|
├── src/
|
|
507
|
-
│
|
|
508
|
-
│
|
|
509
|
-
│
|
|
510
|
-
│
|
|
511
|
-
│
|
|
787
|
+
│ ├── shared/
|
|
788
|
+
│ │ └── tools.js # Single source of truth (23 optimized tools)
|
|
789
|
+
│ ├── mcp/ # MCP Server
|
|
790
|
+
│ │ ├── index.js # Entry point with startup logs
|
|
791
|
+
│ │ ├── server.js # MCP server with STDIO transport
|
|
792
|
+
│ │ ├── handlers.js # 23 optimized tool implementations + decoders
|
|
793
|
+
│ │ └── tools.js # Re-export from shared
|
|
794
|
+
│ ├── lsp/ # LSP Server
|
|
795
|
+
│ │ ├── server.js # LSP server for IDE intelligence
|
|
796
|
+
│ │ └── capabilities/ # Autocomplete, hover, diagnostics
|
|
797
|
+
│ └── ai/ # AI Core Module
|
|
798
|
+
│ ├── core.js # AI Core singleton
|
|
799
|
+
│ ├── element-finder.js # Smart element finding
|
|
800
|
+
│ ├── selector-healer.js # Auto-heal broken selectors
|
|
801
|
+
│ ├── page-analyzer.js # Page analysis
|
|
802
|
+
│ └── action-parser.js # Natural language parsing
|
|
512
803
|
├── lib/
|
|
513
804
|
│ ├── cjs/ # CommonJS build
|
|
514
805
|
│ └── esm/ # ESM build
|
|
@@ -595,6 +886,263 @@ const { browser, page, blocker }: ConnectResult = await connect(options);
|
|
|
595
886
|
|
|
596
887
|
---
|
|
597
888
|
|
|
889
|
+
## Real-World Examples
|
|
890
|
+
|
|
891
|
+
### Example 1: Complete Movie Download Chain
|
|
892
|
+
|
|
893
|
+
**Use Case:** Extract download links from movie streaming sites with multi-layer redirects
|
|
894
|
+
|
|
895
|
+
```javascript
|
|
896
|
+
// Step 1: Initialize browser with all protections
|
|
897
|
+
{
|
|
898
|
+
"tool": "browser_init",
|
|
899
|
+
"params": {
|
|
900
|
+
"headless": false,
|
|
901
|
+
"turnstile": true,
|
|
902
|
+
"enableBlocker": true
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
// Step 2: Navigate to movie page
|
|
907
|
+
{
|
|
908
|
+
"tool": "navigate",
|
|
909
|
+
"params": {
|
|
910
|
+
"url": "https://moviesdrive.surf/movies/dhurandhar-2025/",
|
|
911
|
+
"waitUntil": "networkidle2",
|
|
912
|
+
"smartWait": true
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
// Step 3: Find and click quality selector
|
|
917
|
+
{
|
|
918
|
+
"tool": "click",
|
|
919
|
+
"params": {
|
|
920
|
+
"selector": "a[href*='hubcloud']",
|
|
921
|
+
"humanLike": true,
|
|
922
|
+
"aiHeal": true
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
// Step 4: Wait for redirect chain to complete
|
|
927
|
+
{
|
|
928
|
+
"tool": "wait",
|
|
929
|
+
"params": {
|
|
930
|
+
"type": "smart",
|
|
931
|
+
"value": "2000",
|
|
932
|
+
"aiOptimize": true
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
// Step 5: Trace complete redirect chain
|
|
937
|
+
{
|
|
938
|
+
"tool": "redirect_tracer",
|
|
939
|
+
"params": {
|
|
940
|
+
"url": "current",
|
|
941
|
+
"followJS": true,
|
|
942
|
+
"followMeta": true,
|
|
943
|
+
"decodeURLs": true
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
// Step 6: Extract obfuscated download links
|
|
948
|
+
{
|
|
949
|
+
"tool": "extract_data",
|
|
950
|
+
"params": {
|
|
951
|
+
"type": "regex",
|
|
952
|
+
"pattern": "https?://[^\"'<>\\s]+\\.(mkv|mp4|avi)",
|
|
953
|
+
"autoDecode": true,
|
|
954
|
+
"source": "all"
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
// Step 7: Extract from nested iframes if present
|
|
959
|
+
{
|
|
960
|
+
"tool": "media_extractor",
|
|
961
|
+
"params": {
|
|
962
|
+
"action": "extract",
|
|
963
|
+
"types": ["download", "video"],
|
|
964
|
+
"deep": true,
|
|
965
|
+
"aiOptimize": true
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
// Step 8: Download the file
|
|
970
|
+
{
|
|
971
|
+
"tool": "file_downloader",
|
|
972
|
+
"params": {
|
|
973
|
+
"url": "extracted_download_link",
|
|
974
|
+
"directory": "./downloads",
|
|
975
|
+
"resume": true
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
// Step 9: Cleanup
|
|
980
|
+
{
|
|
981
|
+
"tool": "browser_close",
|
|
982
|
+
"params": {
|
|
983
|
+
"saveSession": false
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
```
|
|
987
|
+
|
|
988
|
+
### Example 2: TV Show Episode Batch Extraction
|
|
989
|
+
|
|
990
|
+
**Use Case:** Extract all episodes from a TV show season
|
|
991
|
+
|
|
992
|
+
```javascript
|
|
993
|
+
// Navigate to TV show page
|
|
994
|
+
{
|
|
995
|
+
"tool": "navigate",
|
|
996
|
+
"params": { "url": "https://multimovies.gripe/tvshows/sacred-games/" }
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
// Extract all episode links
|
|
1000
|
+
{
|
|
1001
|
+
"tool": "extract_data",
|
|
1002
|
+
"params": {
|
|
1003
|
+
"type": "structured",
|
|
1004
|
+
"selector": ".episode-item a",
|
|
1005
|
+
"extractAttributes": true
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
// For each episode, extract streaming sources
|
|
1010
|
+
{
|
|
1011
|
+
"tool": "media_extractor",
|
|
1012
|
+
"params": {
|
|
1013
|
+
"action": "batch_extract",
|
|
1014
|
+
"urls": ["episode1_url", "episode2_url", "..."],
|
|
1015
|
+
"types": ["hls", "dash", "download"],
|
|
1016
|
+
"deep": true
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
// Get network recorded streams
|
|
1021
|
+
{
|
|
1022
|
+
"tool": "network_recorder",
|
|
1023
|
+
"params": {
|
|
1024
|
+
"action": "get_media",
|
|
1025
|
+
"aiDetectStreams": true
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
```
|
|
1029
|
+
|
|
1030
|
+
### Example 3: Advanced Link Harvesting with Decoding
|
|
1031
|
+
|
|
1032
|
+
**Use Case:** Find hidden/obfuscated links on complex pages
|
|
1033
|
+
|
|
1034
|
+
```javascript
|
|
1035
|
+
// Navigate to target
|
|
1036
|
+
{
|
|
1037
|
+
"tool": "navigate",
|
|
1038
|
+
"params": { "url": "https://example-site.com/protected-content/" }
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
// Harvest all links including hidden/encoded ones
|
|
1042
|
+
{
|
|
1043
|
+
"tool": "link_harvester",
|
|
1044
|
+
"params": {
|
|
1045
|
+
"includeHidden": true,
|
|
1046
|
+
"autoDecode": true,
|
|
1047
|
+
"detectObfuscation": true,
|
|
1048
|
+
"searchIframes": true,
|
|
1049
|
+
"types": ["all"]
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
// Decode any obfuscated links found
|
|
1054
|
+
{
|
|
1055
|
+
"tool": "media_extractor",
|
|
1056
|
+
"params": {
|
|
1057
|
+
"action": "decode_url",
|
|
1058
|
+
"encodedData": "aHR0cHM6Ly9leGFtcGxlLmNvbQ==",
|
|
1059
|
+
"decoderType": "auto"
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
```
|
|
1063
|
+
|
|
1064
|
+
### Example 4: Form Automation with AI Detection
|
|
1065
|
+
|
|
1066
|
+
**Use Case:** Automatically fill and submit complex forms
|
|
1067
|
+
|
|
1068
|
+
```javascript
|
|
1069
|
+
// Navigate to form page
|
|
1070
|
+
{
|
|
1071
|
+
"tool": "navigate",
|
|
1072
|
+
"params": { "url": "https://example.com/contact-form/" }
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
// AI-powered form detection and filling
|
|
1076
|
+
{
|
|
1077
|
+
"tool": "form_automator",
|
|
1078
|
+
"params": {
|
|
1079
|
+
"data": {
|
|
1080
|
+
"name": "John Doe",
|
|
1081
|
+
"email": "john@example.com",
|
|
1082
|
+
"message": "Hello, this is a test message",
|
|
1083
|
+
"country": "United States"
|
|
1084
|
+
},
|
|
1085
|
+
"aiMatch": true,
|
|
1086
|
+
"aiValidate": true,
|
|
1087
|
+
"humanLike": true,
|
|
1088
|
+
"captcha": true,
|
|
1089
|
+
"submit": true
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
```
|
|
1093
|
+
|
|
1094
|
+
### Example 5: Streaming Media Extraction
|
|
1095
|
+
|
|
1096
|
+
**Use Case:** Extract video streams from JWPlayer, VideoJS, custom players
|
|
1097
|
+
|
|
1098
|
+
```javascript
|
|
1099
|
+
// Navigate to video page
|
|
1100
|
+
{
|
|
1101
|
+
"tool": "navigate",
|
|
1102
|
+
"params": {
|
|
1103
|
+
"url": "https://multimovies.gripe/movies/movie-name/",
|
|
1104
|
+
"waitUntil": "networkidle0"
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
// Start recording network
|
|
1109
|
+
{
|
|
1110
|
+
"tool": "network_recorder",
|
|
1111
|
+
"params": { "action": "start", "aiDetectStreams": true }
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
// Extract all media types
|
|
1115
|
+
{
|
|
1116
|
+
"tool": "media_extractor",
|
|
1117
|
+
"params": {
|
|
1118
|
+
"action": "extract",
|
|
1119
|
+
"types": ["hls", "dash", "video", "audio", "download"],
|
|
1120
|
+
"quality": "all",
|
|
1121
|
+
"deep": true
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
// Get all recorded streams
|
|
1126
|
+
{
|
|
1127
|
+
"tool": "network_recorder",
|
|
1128
|
+
"params": {
|
|
1129
|
+
"action": "get_media",
|
|
1130
|
+
"filter": { "type": "m3u8" }
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
// Control player if needed
|
|
1135
|
+
{
|
|
1136
|
+
"tool": "media_extractor",
|
|
1137
|
+
"params": {
|
|
1138
|
+
"action": "player_control",
|
|
1139
|
+
"playerAction": "sources"
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
```
|
|
1143
|
+
|
|
1144
|
+
---
|
|
1145
|
+
|
|
598
1146
|
## FAQ
|
|
599
1147
|
|
|
600
1148
|
### Why can't I pass reCAPTCHA v3?
|