brave-real-browser-mcp-server 2.17.2 → 2.17.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 CHANGED
@@ -4,15 +4,15 @@
4
4
 
5
5
  <div align="center">
6
6
 
7
- ![Version](https://img.shields.io/badge/version-2.15.4-blue.svg)
7
+ ![Version](https://img.shields.io/badge/version-2.15.5-blue.svg)
8
8
  ![Node](https://img.shields.io/badge/node-%3E%3D18.0.0-green.svg)
9
- ![Tools](https://img.shields.io/badge/tools-66-purple.svg)
9
+ ![Tools](https://img.shields.io/badge/tools-48-purple.svg)
10
10
  ![IDEs](https://img.shields.io/badge/AI_IDEs-15+-orange.svg)
11
11
  ![License](https://img.shields.io/badge/license-MIT-red.svg)
12
12
 
13
- **सभी AI IDEs के लिए Universal MCP Server | 66+ Tools | Browser Automation | Web Scraping | CAPTCHA Solving**
13
+ **सभी AI IDEs के लिए Universal MCP Server | 48 Tools | Browser Automation | Web Scraping | CAPTCHA Solving**
14
14
 
15
- [Installation](#-installation) | [Quick Start](#-quick-start) | [Qoder AI Setup](#-qoder-ai---complete-integration-guide) | [Tools](#-available-tools-66) | [IDE Configurations](#-ide-configurations)
15
+ [Installation](#-installation) | [Quick Start](#-quick-start) | [Features](#-key-features) | [Tools](#-available-tools-48) | [IDE Configurations](#-ide-configurations)
16
16
 
17
17
  </div>
18
18
 
@@ -20,73 +20,117 @@
20
20
 
21
21
  ## 🎯 What is This?
22
22
 
23
- **Brave Real Browser MCP Server** एक powerful automation tool है जो:
23
+ **Brave Real Browser MCP Server** एक powerful automation tool है जो **Real Brave Browser** का उपयोग करता है। यह साधारण ऑटोमेशन नहीं है, इसमें **In-built Anti-Detection**, **Ad-Blocking**, और **Smart Auto-Install** फीचर्स हैं।
24
24
 
25
- - **20+ AI IDEs में काम करता है** (Antigravity, Warp AI, Zed, Cursor, Claude, Windsurf, Cline, Qoder AI, etc.)
26
- - ✅ **66+ Automation Tools** - Browser control, scraping, CAPTCHA solving, video extraction
27
- - ✅ **MCP Protocol (STDIO)** - Fast and secure local communication
28
- - ✅ **Auto-Detection** - Automatically detects your IDE
29
- - ✅ **Real Brave Browser** - Anti-detection features, bypass Cloudflare
30
- - ✅ **Universal API** - Works with any programming language (JS, Python, PHP, Go, etc.)
25
+ ### Key Features (मुख्य विशेषताएँ)
26
+
27
+ - ✅ **Automatic Brave Installation**: यदि आपके Windows, Linux, या Mac पर Brave Browser नहीं है, तो यह इसे **अपने आप डाउनलोड और इंस्टॉल** कर लेता है।
28
+ - ✅ **Built-in Ad-Blocker (uBlock Origin)**: इसमें **uBlock Origin** पहले से इंस्टॉल आता है जो सभी विज्ञापनों और ट्रैकर्स को ब्लॉक करता है, जिससे पेज तेज़ी से लोड होते हैं और डिटेक्शन का खतरा कम होता है।
29
+ - ✅ **Universal Compatibility**: यह Windows, Mac, और Linux तीनों पर समान रूप से काम करता है।
30
+ - ✅ **Advanced Video Extraction**: जटिल वीडियो और स्ट्रीमिंग साइटों से वीडियो लिंक निकालने के लिए विशेष टूल्स।
31
+ - ✅ **Anti-Detection**: Cloudflare और अन्य सुरक्षा प्रणालियों को बायपास करने में सक्षम।
31
32
 
32
33
  ---
33
34
 
34
35
  ## 🚀 Quick Start
35
36
 
36
- ### ⚡ Quick Setup Summary
37
-
38
- **Choose your setup based on your AI Editor:**
39
-
40
- | Editor | Setup Time | Protocol | Method |
41
- |--------|-----------|----------|--------|
42
- | **Claude Desktop** | 2 min | MCP | Add config → Restart |
43
- | **Cursor AI** | 2 min | MCP | Add config → Restart |
44
- | **Windsurf** | 2 min | MCP | Add config → Restart |
45
- | **Antigravity IDE** | 1 min | MCP | Auto-Detect |
46
- | **Warp AI** | 2 min | MCP | Add config |
47
- | **Zed AI** | 2 min | MCP | Add config |
48
- | **Qoder AI** | 3 min | MCP (STDIO) | Add config → Restart |
49
-
50
- **Quick Commands:**
37
+ ### ⚡ Installation
51
38
 
52
39
  ```bash
53
- # Auto-detect environment
40
+ # Recommended: Use directly with npx (No install needed)
54
41
  npx brave-real-browser-mcp-server@latest
55
42
  ```
56
43
 
57
44
  ---
58
45
 
59
- ### Installation
60
-
61
- ```bash
62
- # Recommended: Use directly with npx (No install needed)
63
- npx brave-real-browser-mcp-server@latest
64
-
65
- # Alternative: Install globally
66
- npm install -g brave-real-browser-mcp-server@latest
67
- ```
46
+ ## 🛠️ Available Tools (48)
47
+
48
+ ### 🌐 Core Browser & Navigation (7 tools)
49
+ | Tool | Description |
50
+ |------|-------------|
51
+ | `browser_init` | Initialize browser with auto-install & ad-blocking |
52
+ | `browser_close` | Close the browser instance |
53
+ | `navigate` | Navigate to a URL with smart wait |
54
+ | `wait` | Wait for selectors, navigation, or time |
55
+ | `breadcrumb_navigator` | Navigate using site breadcrumbs |
56
+ | `url_redirect_tracer` | Trace standard URL redirects |
57
+ | `multi_layer_redirect_trace` | Trace complex/hidden redirects |
58
+
59
+ ### 🖱️ Interaction & Input (5 tools)
60
+ | Tool | Description |
61
+ |------|-------------|
62
+ | `click` | Smart click on elements |
63
+ | `type` | Human-like typing with delays |
64
+ | `press_key` | Simulate keyboard key presses |
65
+ | `random_scroll` | Human-like random scrolling |
66
+ | `progress_tracker` | Track automation progress |
67
+
68
+ ### 📄 Content Extraction (8 tools)
69
+ | Tool | Description |
70
+ |------|-------------|
71
+ | `get_content` | **Primary Tool** for page content (HTML/Text) |
72
+ | `save_content_as_markdown` | Save page as clean Markdown |
73
+ | `find_selector` | Find elements containing text |
74
+ | `html_elements_extractor` | Extract detailed element info |
75
+ | `extract_json` | Extract embedded JSON/API data |
76
+ | `scrape_meta_tags` | Extract SEO & Open Graph tags |
77
+ | `extract_schema` | Extract Schema.org structured data |
78
+ | `image_extractor_advanced` | Advanced image extraction |
79
+
80
+ ### 🔍 Search & Discovery (5 tools)
81
+ | Tool | Description |
82
+ |------|-------------|
83
+ | `keyword_search` | Search for keywords in content |
84
+ | `regex_pattern_matcher` | Find patterns using Regex |
85
+ | `xpath_support` | Query elements using XPath |
86
+ | `advanced_css_selectors` | Complex CSS selector support |
87
+ | `api_finder` | Discover hidden API endpoints |
88
+
89
+ ### 🎬 Advanced Video & Media (8 tools)
90
+ | Tool | Description |
91
+ |------|-------------|
92
+ | `advanced_video_extraction` | **Premium** video extractor with ad-bypass |
93
+ | `video_source_extractor` | Extract direct video sources |
94
+ | `video_player_finder` | Locate video players on page |
95
+ | `stream_detector` | Detect HLS/m3u8/DASH streams |
96
+ | `video_download_link_finder` | Find direct download buttons/links |
97
+ | `media_extractor` | Extract generic media (audio/video) |
98
+ | `fetch_xhr` | Capture background XHR requests |
99
+ | `network_recorder` | Record full network traffic |
100
+
101
+ ### 🤖 Smart & AI Features (6 tools)
102
+ | Tool | Description |
103
+ |------|-------------|
104
+ | `smart_selector_generator` | AI-powered selector generation |
105
+ | `content_classification` | Classify page content type |
106
+ | `deobfuscate_js` | Deobfuscate hidden JS code |
107
+ | `ad_protection_detector` | Detect anti-adblock systems |
108
+ | `batch_element_scraper` | Scrape lists of items efficiently |
109
+ | `ajax_content_waiter` | Wait for dynamic AJAX loading |
110
+
111
+ ### 🔐 Captcha & Security (6 tools)
112
+ | Tool | Description |
113
+ |------|-------------|
114
+ | `solve_captcha` | Universal CAPTCHA solver |
115
+ | `ocr_engine` | Read text from images (OCR) |
116
+ | `audio_captcha_solver` | Solve audio challenges |
117
+ | `puzzle_captcha_handler` | Solve puzzle/slider CAPTCHAs |
118
+ | `data_type_validator` | Validate extracted data |
119
+ | `attribute_harvester` | Collect element attributes |
120
+
121
+ ### 📸 Visual Tools (3 tools)
122
+ | Tool | Description |
123
+ |------|-------------|
124
+ | `element_screenshot` | Capture element screenshots |
125
+ | `video_recording` | Record browser session |
126
+ | `link_harvester` | Harvest all links from page |
68
127
 
69
128
  ---
70
129
 
71
130
  ## 🎨 IDE Configurations
72
131
 
73
132
  ### 1. Claude Desktop
74
- **File:** `%APPDATA%\Claude\claude_desktop_config.json` (Windows) or `~/Library/Application Support/Claude/claude_desktop_config.json` (Mac)
75
-
76
- ```json
77
- {
78
- "mcpServers": {
79
- "brave-real-browser": {
80
- "command": "npx",
81
- "args": ["-y", "brave-real-browser-mcp-server@latest"]
82
- }
83
- }
84
- }
85
- ```
86
-
87
- ### 2. Cursor AI
88
- **File:** `%APPDATA%\Cursor\User\globalStorage\saoudrizwan.claude-dev\settings\mcp_settings.json`
89
-
133
+ **File:** `%APPDATA%\Claude\claude_desktop_config.json` (Windows)
90
134
  ```json
91
135
  {
92
136
  "mcpServers": {
@@ -98,24 +142,8 @@ npm install -g brave-real-browser-mcp-server@latest
98
142
  }
99
143
  ```
100
144
 
101
- ### 3. Windsurf
102
- **File:** `%APPDATA%\Windsurf\mcp.json` (Windows) or `~/.windsurf/mcp.json` (Mac)
103
-
104
- ```json
105
- {
106
- "mcpServers": {
107
- "brave-real-browser": {
108
- "command": "npx",
109
- "args": ["-y", "brave-real-browser-mcp-server@latest"]
110
- }
111
- }
112
- }
113
- ```
114
-
115
- ### 4. Antigravity IDE
116
- **Auto-Detection:** Automatically detects installed MCP servers.
117
- **Manual Config:** Add to project config if needed:
118
-
145
+ ### 2. Cursor AI, Windsurf, & Others
146
+ Add this to your MCP settings:
119
147
  ```json
120
148
  {
121
149
  "mcpServers": {
@@ -127,281 +155,22 @@ npm install -g brave-real-browser-mcp-server@latest
127
155
  }
128
156
  ```
129
157
 
130
- ### 5. Warp AI
131
- **File:** `~/.warp/mcp_config.json`
132
-
133
- ```json
134
- {
135
- "mcpServers": {
136
- "brave-real-browser": {
137
- "command": "npx",
138
- "args": ["-y", "brave-real-browser-mcp-server@latest"]
139
- }
140
- }
141
- }
142
- ```
143
-
144
- ### 6. Zed AI
145
- **File:** `.zed/settings.json`
146
-
147
- ```json
148
- {
149
- "context_servers": {
150
- "brave-real-browser": {
151
- "command": "npx.cmd",
152
- "args": ["-y", "brave-real-browser-mcp-server@latest"],
153
- "env": {}
154
- }
155
- }
156
- }
157
- ```
158
-
159
- ### 7. Cline (VSCode Extension)
160
- **File:** `cline_mcp_settings.json`
161
-
162
- ```json
163
- {
164
- "mcpServers": {
165
- "brave-real-browser": {
166
- "command": "npx",
167
- "args": ["-y", "brave-real-browser-mcp-server@latest"]
168
- }
169
- }
170
- }
171
- ```
172
-
173
- ### 8. Qoder AI
174
- **File:** `%APPDATA%\Qoder\mcp_settings.json` (Windows) or `~/.config/Qoder/mcp_settings.json` (Linux)
175
- **Note:** Qoder AI uses STDIO.
176
-
177
- ```json
178
- {
179
- "mcpServers": {
180
- "brave-real-browser": {
181
- "command": "npx",
182
- "args": ["-y", "brave-real-browser-mcp-server@latest"],
183
- "env": {
184
- "BRAVE_PATH": "C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe"
185
- }
186
- }
187
- }
188
- }
189
- ```
190
-
191
158
  ---
192
159
 
193
- ## 🛠️ Available Tools (66)
194
-
195
- ### 🌐 Browser Management (2 tools)
196
-
197
- | Tool | Description |
198
- | --------------- | ----------------------------------------------- |
199
- | `browser_init` | Initialize browser with anti-detection features |
200
- | `browser_close` | Close browser instance |
201
-
202
- ### 🧭 Navigation (2 tools)
203
-
204
- | Tool | Description |
205
- | ---------- | ----------------------------------------- |
206
- | `navigate` | Navigate to URL with wait conditions |
207
- | `wait` | Wait for selector, navigation, or timeout |
208
-
209
- ### 🖱️ Interactions (4 tools)
210
-
211
- | Tool | Description |
212
- | --------------- | ---------------------------------------------------- |
213
- | `click` | Click on elements |
214
- | `type` | Type text into inputs |
215
- | `random_scroll` | Human-like scrolling |
216
- | `solve_captcha` | Solve CAPTCHA (reCAPTCHA, hCaptcha, Turnstile, etc.) |
217
-
218
- ### 📄 Content Extraction (9 tools)
219
-
220
- | Tool | Description |
221
- | -------------------------- | ----------------------------------------- |
222
- | `get_content` | Extract page content (HTML/Text/Markdown) |
223
- | `find_selector` | Find CSS selectors for elements |
224
- | `scrape_table` | Extract table data with headers |
225
- | `extract_json` | Extract JSON data from page |
226
- | `scrape_meta_tags` | Extract meta tags and SEO info |
227
- | `extract_schema` | Extract schema.org structured data |
228
- | `save_content_as_markdown` | Save page as markdown file |
229
- | `html_to_text` | Convert HTML to clean text |
230
- | `smart_text_cleaner` | Clean and normalize text |
231
-
232
- ### 🔍 Multi-Element Extraction (8 tools)
233
-
234
- | Tool | Description |
235
- | ------------------------- | --------------------------------- |
236
- | `batch_element_scraper` | Scrape multiple elements at once |
237
- | `nested_data_extraction` | Extract nested data structures |
238
- | `attribute_harvester` | Extract element attributes |
239
- | `image_scraper` | Extract all images with metadata |
240
- | `link_harvester` | Extract all links from page |
241
- | `media_extractor` | Extract media files (audio/video) |
242
- | `pdf_link_finder` | Find PDF download links |
243
- | `html_elements_extractor` | Extract specific HTML elements |
244
-
245
- ### 🎯 Advanced Extraction (10 tools)
246
-
247
- | Tool | Description |
248
- | ---------------------- | ---------------------------- |
249
- | `tags_finder` | Find elements by tag name |
250
- | `links_finder` | Advanced link extraction |
251
- | `xpath_links` | Extract links using XPath |
252
- | `ajax_extractor` | Extract AJAX/dynamic content |
253
- | `fetch_xhr` | Capture XHR/Fetch requests |
254
- | `network_recorder` | Record all network traffic |
255
- | `regex_pattern_finder` | Find patterns using regex |
256
- | `iframe_extractor` | Extract iframe content |
257
- | `embed_page_extractor` | Extract embedded pages |
258
- | `user_agent_extractor` | Extract user agent info |
259
-
260
- ### 🎬 Video & Media Tools (19 tools)
261
-
262
- | Tool | Description |
263
- | ------------------------------- | ---------------------------------------- |
264
- | `video_link_finder` | Find video URLs |
265
- | `video_download_button` | Find video download buttons |
266
- | `video_play_push_source` | Get video play sources |
267
- | `video_play_button_click` | Click video play button |
268
- | `advanced_video_extraction` | Advanced video extraction with ad-bypass |
269
- | `image_extractor_advanced` | Advanced image extraction |
270
- | `video_source_extractor` | Extract video source URLs |
271
- | `video_player_extractor` | Extract video player info |
272
- | `video_player_hoster_finder` | Find video hosting platform |
273
- | `original_video_hoster_finder` | Find original video source |
274
- | `stream_detector` | Detect HLS/DASH streams |
275
- | `redirect_tracer` | Trace URL redirects |
276
- | `video_download_link_finder` | Find direct download links |
277
-
278
- ### 🔐 CAPTCHA & Security (4 tools)
279
-
280
- | Tool | Description |
281
- | ------------------------ | ------------------------------------------------------------------- |
282
- | `solve_captcha` | Multi-CAPTCHA solver (reCAPTCHA, hCaptcha, Turnstile, Arkose, etc.) |
283
- | `ocr_engine` | OCR for text-based CAPTCHAs |
284
- | `audio_captcha_solver` | Solve audio CAPTCHAs |
285
- | `puzzle_captcha_handler` | Handle puzzle CAPTCHAs |
286
-
287
- ### 🔧 Data Processing (5 tools)
288
-
289
- | Tool | Description |
290
- | ------------------------- | ---------------------------------- |
291
- | `price_parser` | Extract and parse prices |
292
- | `date_normalizer` | Normalize dates to standard format |
293
- | `contact_extractor` | Extract contact information |
294
- | `schema_validator` | Validate data against schema |
295
- | `required_fields_checker` | Check for required fields |
296
-
297
- ### 📊 Data Quality (0 tools)
298
-
299
- *Advanced data quality tools removed for optimization.*
300
-
301
- ### 🤖 AI-Powered Tools (2 tools)
302
-
303
- | Tool | Description |
304
- | -------------------------- | --------------------------- |
305
- | `smart_selector_generator` | Auto-generate CSS selectors |
306
- | `content_classification` | Classify content type |
307
-
308
- ### 🔎 Search & Filter (5 tools)
309
-
310
- | Tool | Description |
311
- | ------------------------ | ----------------------------- |
312
- | `keyword_search` | Search for keywords in page |
313
- | `regex_pattern_matcher` | Match regex patterns |
314
- | `xpath_support` | XPath query support |
315
- | `advanced_css_selectors` | Advanced CSS selector queries |
316
- | `visual_element_finder` | Find elements visually |
317
-
318
- ### 📑 Pagination & Navigation (5 tools)
319
-
320
- | Tool | Description |
321
- | ---------------------- | --------------------------- |
322
- | `auto_pagination` | Auto-paginate through pages |
323
- | `infinite_scroll` | Handle infinite scroll |
324
- | `multi_page_scraper` | Scrape multiple pages |
325
- | `sitemap_parser` | Parse and navigate sitemaps |
326
- | `breadcrumb_navigator` | Navigate using breadcrumbs |
327
-
328
- ### 🔒 Session Management (6 tools)
329
-
330
- | Tool | Description |
331
- | ----------------------- | -------------------------- |
332
- | `session_persistence` | Persist sessions |
333
- | `form_auto_fill` | Auto-fill forms |
334
- | `ajax_content_waiter` | Wait for AJAX content |
335
- | `modal_popup_handler` | Handle modal popups |
336
- | `login_session_manager` | Manage login sessions |
337
- | `shadow_dom_extractor` | Extract Shadow DOM content |
338
-
339
- ### 📸 Visual Tools (4 tools)
340
-
341
- | Tool | Description |
342
- | ---------------------- | --------------------------- |
343
- | `element_screenshot` | Screenshot specific element |
344
- | `pdf_generation` | Generate PDF from page |
345
- | `video_recording` | Record page as video |
346
-
347
- ### 📈 Monitoring & Reporting (3 tools)
348
-
349
- | Tool | Description |
350
- | ----------------------- | ------------------------- |
351
- | `progress_tracker` | Track automation progress |
352
- | `success_rate_reporter` | Report success rates |
353
- | `performance_monitor` | Monitor performance |
354
-
355
- ### 🛡️ Advanced Extraction & Obfuscation (4 tools)
356
-
357
- | Tool | Description |
358
- | ---------------------------- | --------------------------- |
359
- | `deobfuscate_js` | Deobfuscate JavaScript |
360
- | `multi_layer_redirect_trace` | Trace multi-layer redirects |
361
- | `ad_protection_detector` | Detect ad protection |
362
-
363
- ## 🔧 Environment Variables
364
-
365
- You can configure the server using the local `.env` file directly.
366
-
367
- Edit `.env` to set your preferences:
160
+ ## 🔧 Environment Variables (.env)
368
161
 
369
162
  ```bash
370
- # Optional: Specify Brave browser path
371
- BRAVE_PATH="C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe"
372
-
373
163
  # Optional: Run in headless mode (default: false)
374
164
  HEADLESS=true
375
165
 
376
166
  # Optional: Disable content priority
377
167
  DISABLE_CONTENT_PRIORITY=true
378
168
 
379
- # Optional: Proxy URL
380
- PROXY_URL=http://localhost:8080
169
+ # Optional: Proxy Configuration
170
+ PROXY_URL=http://user:pass@host:port
381
171
  ```
382
172
 
383
- ## 📊 Supported Protocols
384
-
385
- | Protocol | Used By | Auto-Config | Status |
386
- | --------------- | --------------------------------------------- | ----------- | ---------- |
387
- | **MCP (STDIO)** | Claude Desktop, Cursor, Windsurf, Cline, Warp | ✅ | 🟢 Working |
388
-
389
- ## 📄 License
390
-
391
- MIT License - See LICENSE file for details.
392
-
393
173
  ---
394
174
 
395
- ## 🔗 Links
396
-
397
- - **GitHub:** https://github.com/codeiva4u/Brave-Real-Browser-Mcp-Server
398
- - **NPM:** https://www.npmjs.com/package/brave-real-browser-mcp-server
399
- - **Issues:** https://github.com/codeiva4u/Brave-Real-Browser-Mcp-Server/issues
400
-
401
- ---
402
-
403
- <div align="center">
404
-
405
- **🌟 78 Tools | 15+ AI IDEs | MCP Protocol | Universal Support 🌟**
406
-
407
- **Made with ❤️ for the AI Development Community**
175
+ ## 📄 License
176
+ MIT License
@@ -51,7 +51,10 @@ describe('Navigation Handlers', () => {
51
51
  let mockPageInstance;
52
52
  beforeEach(() => {
53
53
  vi.clearAllMocks();
54
- setTimeoutMock.mockClear(); // Clear setTimeout mock calls between tests
54
+ setTimeoutMock.mockClear();
55
+ // Explicitly restore default mock implementations
56
+ systemUtils.withTimeout.mockImplementation((op) => op());
57
+ systemUtils.withErrorHandling.mockImplementation((op) => op());
55
58
  // Setup mocks
56
59
  mockBrowserManager = browserManager;
57
60
  mockSystemUtils = systemUtils;
package/dist/index.js CHANGED
@@ -1,25 +1,14 @@
1
1
  #!/usr/bin/env node
2
- // Debug logging setup - Log process start
3
2
  import 'dotenv/config';
4
- console.error(`🔍 [DEBUG] Process starting - PID: ${process.pid}, Node: ${process.version}, Platform: ${process.platform}`);
5
- console.error(`🔍 [DEBUG] Working directory: ${process.cwd()}`);
6
- console.error(`🔍 [DEBUG] Command args: ${process.argv.join(" ")}`);
7
3
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
8
4
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
9
5
  import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ListPromptsRequestSchema, InitializeRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
10
- console.error("🔍 [DEBUG] MCP SDK imports completed successfully");
11
- // Import extracted modules
12
- console.error("🔍 [DEBUG] Loading tool definitions...");
13
6
  import { TOOLS, SERVER_INFO, CAPABILITIES, TOOL_NAMES, } from "./tool-definitions.js";
14
- console.error("🔍 [DEBUG] Loading system utils...");
15
7
  import { withErrorHandling } from "./system-utils.js";
16
8
  import { validateMCPResponse } from "./mcp-response-validator.js";
17
- console.error("🔍 [DEBUG] Loading browser manager...");
18
9
  import { closeBrowser, forceKillAllBraveProcesses } from "./browser-manager.js";
19
- console.error("🔍 [DEBUG] Loading core infrastructure...");
20
10
  import { setupProcessCleanup, } from "./core-infrastructure.js";
21
11
  // Import handlers
22
- console.error("🔍 [DEBUG] Loading handlers...");
23
12
  import { handleBrowserInit, handleBrowserClose, } from "./handlers/browser-handlers.js";
24
13
  import { handleNavigate, handleWait } from "./handlers/navigation-handlers.js";
25
14
  import { handleClick, handleType, handleSolveCaptcha, handleRandomScroll, handlePressKey, } from "./handlers/interaction-handlers.js";
@@ -42,7 +31,7 @@ import { handleOCREngine, handleAudioCaptchaSolver, handlePuzzleCaptchaHandler,
42
31
  // Import visual tools handlers
43
32
  import { handleElementScreenshot, handleVideoRecording, } from "./handlers/visual-tools-handlers.js";
44
33
  // Import smart data extractors
45
- import { handleFetchXHR, handleNetworkRecorder, handleImageExtractorAdvanced, handleVideoSourceExtractor, handleUrlRedirectTracer, handleApiFinder, } from "./handlers/smart-data-extractors.js";
34
+ import { handleHtmlElementsExtractor, handleFetchXHR, handleNetworkRecorder, handleImageExtractorAdvanced, handleVideoSourceExtractor, handleUrlRedirectTracer, handleApiFinder, } from "./handlers/smart-data-extractors.js";
46
35
  // Import dynamic session handlers
47
36
  import { handleAjaxContentWaiter, } from "./handlers/dynamic-session-handlers.js";
48
37
  // Import monitoring & reporting handlers
@@ -51,26 +40,17 @@ import { handleProgressTracker, } from "./handlers/monitoring-reporting-handlers
51
40
  import { handleVideoPlayerFinder, handleStreamDetector, handleVideoDownloadLinkFinder, } from "./handlers/advanced-video-media-handlers.js";
52
41
  // Import advanced extraction handlers (Ad-bypass & Obfuscation)
53
42
  import { handleAdvancedVideoExtraction, handleDeobfuscateJS, handleMultiLayerRedirectTrace, handleAdProtectionDetector, } from "./handlers/advanced-extraction-handlers.js";
54
- console.error("🔍 [DEBUG] All modules loaded successfully");
55
- console.error(`🔍 [DEBUG] Server info: ${JSON.stringify(SERVER_INFO)}`);
56
- console.error(`🔍 [DEBUG] Available tools: ${TOOLS.length} tools loaded`);
57
43
  // Initialize MCP server
58
- console.error("🔍 [DEBUG] Creating MCP server instance...");
59
44
  const server = new Server(SERVER_INFO, { capabilities: CAPABILITIES });
60
- console.error("🔍 [DEBUG] MCP server instance created successfully");
61
45
  // Register initialize handler (CRITICAL - missing handler can cause crash)
62
- console.error("🔍 [DEBUG] Registering initialize handler...");
63
46
  server.setRequestHandler(InitializeRequestSchema, async (request) => {
64
- console.error(`🔍 [DEBUG] Initialize request received: ${JSON.stringify(request)}`);
65
47
  // Use the client's protocol version to ensure compatibility
66
48
  const clientProtocolVersion = request.params.protocolVersion;
67
- console.error(`🔍 [DEBUG] Client protocol version: ${clientProtocolVersion}`);
68
49
  const response = {
69
50
  protocolVersion: clientProtocolVersion, // Match client version for compatibility
70
51
  capabilities: CAPABILITIES,
71
52
  serverInfo: SERVER_INFO,
72
53
  };
73
- console.error(`🔍 [DEBUG] Sending initialize response: ${JSON.stringify(response)}`);
74
54
  // Add a small delay to see if there are any immediate errors after response
75
55
  setTimeout(() => {
76
56
  console.error(`🔍 [DEBUG] 1 second after initialize response - server still alive`);
@@ -81,21 +61,15 @@ server.setRequestHandler(InitializeRequestSchema, async (request) => {
81
61
  return response;
82
62
  });
83
63
  // Register tool handlers
84
- console.error("🔍 [DEBUG] Registering tools handler...");
85
64
  server.setRequestHandler(ListToolsRequestSchema, async () => {
86
- console.error("🔍 [DEBUG] Tools list requested");
87
65
  return { tools: TOOLS };
88
66
  });
89
67
  // Register resource handlers (placeholder)
90
- console.error("🔍 [DEBUG] Registering resources handler...");
91
68
  server.setRequestHandler(ListResourcesRequestSchema, async () => {
92
- console.error("🔍 [DEBUG] Resources list requested");
93
69
  return { resources: [] };
94
70
  });
95
71
  // Register prompt handlers (placeholder)
96
- console.error("🔍 [DEBUG] Registering prompts handler...");
97
72
  server.setRequestHandler(ListPromptsRequestSchema, async () => {
98
- console.error("🔍 [DEBUG] Prompts list requested");
99
73
  return { prompts: [] };
100
74
  });
101
75
  // Tool execution function - exported for use in transports
@@ -140,6 +114,10 @@ export async function executeToolByName(name, args) {
140
114
  result = await handleSaveContentAsMarkdown(args);
141
115
  break;
142
116
  // Smart Data Extractors
117
+ // DOM & HTML Extraction
118
+ case TOOL_NAMES.HTML_ELEMENTS_EXTRACTOR:
119
+ result = await handleHtmlElementsExtractor(args || {});
120
+ break;
143
121
  case TOOL_NAMES.EXTRACT_JSON:
144
122
  result = await handleExtractJSON(args || {});
145
123
  break;
@@ -290,16 +268,13 @@ export async function executeToolByName(name, args) {
290
268
  }
291
269
  }
292
270
  // Main tool call handler
293
- console.error("🔍 [DEBUG] Registering tool call handler...");
294
271
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
295
272
  const { name, arguments: args } = request.params;
296
- console.error(`🔍 [DEBUG] Tool call received: ${name} with args: ${JSON.stringify(args)}`);
297
273
  return await executeToolByName(name, args);
298
274
  });
299
275
  // Main function - now using multi-protocol launcher
300
276
  // Main function
301
277
  async function main() {
302
- console.error("🔍 [DEBUG] Starting in STDIO mode...");
303
278
  setupProcessCleanup(async () => {
304
279
  await closeBrowser();
305
280
  await forceKillAllBraveProcesses();
@@ -307,42 +282,25 @@ async function main() {
307
282
  const transport = new StdioServerTransport();
308
283
  await withErrorHandling(async () => {
309
284
  await server.connect(transport);
310
- console.error("🚀 Brave Real Browser MCP Server started successfully");
311
- console.error("📋 Available tools:", TOOLS.map((t) => t.name).join(", "));
312
285
  }, "Failed to start MCP server");
313
286
  }
314
287
  // Enhanced error handling with debug info
315
- console.error("🔍 [DEBUG] Setting up error handlers...");
316
288
  process.on("uncaughtException", (error) => {
317
- console.error(`🔍 [DEBUG] Uncaught exception at ${new Date().toISOString()}`);
318
- console.error("❌ Uncaught exception:", error);
319
- console.error(`🔍 [DEBUG] Stack trace:`, error.stack);
320
289
  process.exit(1);
321
290
  });
322
291
  process.on("unhandledRejection", (reason, promise) => {
323
- console.error(`🔍 [DEBUG] Unhandled rejection at ${new Date().toISOString()}`);
324
- console.error("❌ Unhandled rejection:", reason);
325
- console.error(`🔍 [DEBUG] Promise:`, promise);
326
292
  process.exit(1);
327
293
  });
328
294
  // Process lifecycle debugging
329
295
  process.on("exit", (code) => {
330
- console.error(`🔍 [DEBUG] Process exiting with code: ${code} at ${new Date().toISOString()}`);
331
296
  });
332
297
  process.on("beforeExit", (code) => {
333
- console.error(`🔍 [DEBUG] Before exit event with code: ${code} at ${new Date().toISOString()}`);
334
298
  });
335
299
  process.on("SIGTERM", () => {
336
- console.error(`🔍 [DEBUG] SIGTERM received at ${new Date().toISOString()}`);
337
300
  });
338
301
  process.on("SIGINT", () => {
339
- console.error(`🔍 [DEBUG] SIGINT received at ${new Date().toISOString()}`);
340
302
  });
341
- console.error("🔍 [DEBUG] All error handlers registered");
342
303
  // Start the server
343
304
  main().catch((error) => {
344
- console.error(`🔍 [DEBUG] Main function failed at ${new Date().toISOString()}`);
345
- console.error("❌ Failed to start server:", error);
346
- console.error(`🔍 [DEBUG] Error stack:`, error.stack);
347
305
  process.exit(1);
348
306
  });
@@ -335,6 +335,19 @@ export const TOOLS = [
335
335
  },
336
336
  },
337
337
  // Smart Data Extractors
338
+ // DOM & HTML Extraction (Phase 1)
339
+ {
340
+ name: 'html_elements_extractor',
341
+ description: 'Extract detailed information about HTML elements matching a selector',
342
+ inputSchema: {
343
+ type: 'object',
344
+ properties: {
345
+ selector: { type: 'string', default: '*' },
346
+ maxElements: { type: 'number', default: 100 },
347
+ includeStyles: { type: 'boolean', default: false },
348
+ },
349
+ },
350
+ },
338
351
  {
339
352
  name: 'extract_json',
340
353
  description: 'Extract embedded JSON/API data from the page',
@@ -806,6 +819,7 @@ export const TOOL_NAMES = {
806
819
  LINK_HARVESTER: 'link_harvester',
807
820
  MEDIA_EXTRACTOR: 'media_extractor',
808
821
  // DOM & HTML Extraction (Phase 1)
822
+ HTML_ELEMENTS_EXTRACTOR: 'html_elements_extractor',
809
823
  // Network Tools (Phase 1)
810
824
  FETCH_XHR: 'fetch_xhr',
811
825
  NETWORK_RECORDER: 'network_recorder',
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "brave-real-browser-mcp-server",
3
- "version": "2.17.2",
3
+ "version": "2.17.4",
4
4
  "description": "Universal AI IDE MCP Server - Auto-detects and supports all AI IDEs (Claude Desktop, Cursor, Windsurf, Cline, Zed, VSCode, Qoder AI, etc.) with Brave browser automation",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "scripts": {
8
8
  "preinstall": "npm view brave-real-puppeteer-core version > .latest-version 2>&1 || echo 'Version check skipped'",
9
- "postinstall": "node scripts/patch-puppeteer-screen-recorder.cjs && node scripts/update-to-latest.cjs || echo 'Auto-update skipped'",
9
+ "postinstall": "node scripts/patch-puppeteer-screen-recorder.cjs",
10
10
  "clean": "rimraf dist",
11
11
  "clean:cache": "npm cache clean --force",
12
12
  "fix-cache-permissions": "echo 'Run: sudo chown -R $(whoami):$(id -gn) ~/.npm' && echo 'This fixes npm cache permission issues'",