brave-real-browser-mcp-server 2.11.8 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,67 +2,77 @@
2
2
  // Debug logging setup - Log process start
3
3
  console.error(`🔍 [DEBUG] Process starting - PID: ${process.pid}, Node: ${process.version}, Platform: ${process.platform}`);
4
4
  console.error(`🔍 [DEBUG] Working directory: ${process.cwd()}`);
5
- console.error(`🔍 [DEBUG] Command args: ${process.argv.join(' ')}`);
6
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
7
- import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
8
- import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ListPromptsRequestSchema, InitializeRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
9
- console.error('🔍 [DEBUG] MCP SDK imports completed successfully');
5
+ console.error(`🔍 [DEBUG] Command args: ${process.argv.join(" ")}`);
6
+ // Universal AI IDE Adapter - Auto-detect and support all AI IDEs
7
+ console.error("🔍 [DEBUG] Loading Universal IDE Adapter...");
8
+ import { UniversalIDEAdapter, } from "./universal-ide-adapter.js";
9
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
10
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
11
+ import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ListPromptsRequestSchema, InitializeRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
12
+ console.error("🔍 [DEBUG] MCP SDK imports completed successfully");
10
13
  // Import extracted modules
11
- console.error('🔍 [DEBUG] Loading tool definitions...');
12
- import { TOOLS, SERVER_INFO, CAPABILITIES, TOOL_NAMES } from './tool-definitions.js';
13
- console.error('🔍 [DEBUG] Loading system utils...');
14
- import { withErrorHandling } from './system-utils.js';
15
- import { validateMCPResponse } from './mcp-response-validator.js';
16
- console.error('🔍 [DEBUG] Loading browser manager...');
17
- import { closeBrowser, forceKillAllBraveProcesses } from './browser-manager.js';
18
- console.error('🔍 [DEBUG] Loading core infrastructure...');
19
- import { setupProcessCleanup } from './core-infrastructure.js';
14
+ console.error("🔍 [DEBUG] Loading tool definitions...");
15
+ import { TOOLS, SERVER_INFO, CAPABILITIES, TOOL_NAMES, } from "./tool-definitions.js";
16
+ console.error("🔍 [DEBUG] Universal IDE Adapter loaded successfully");
17
+ console.error("🔍 [DEBUG] Loading system utils...");
18
+ import { withErrorHandling } from "./system-utils.js";
19
+ import { validateMCPResponse } from "./mcp-response-validator.js";
20
+ console.error("🔍 [DEBUG] Loading browser manager...");
21
+ import { closeBrowser, forceKillAllBraveProcesses } from "./browser-manager.js";
22
+ console.error("🔍 [DEBUG] Loading core infrastructure...");
23
+ import { setupProcessCleanup, } from "./core-infrastructure.js";
24
+ // Initialize Universal IDE Adapter
25
+ const universalAdapter = new UniversalIDEAdapter({
26
+ enableAutoDetection: true,
27
+ fallbackToHttp: true,
28
+ logDetectionDetails: true,
29
+ });
20
30
  // Import handlers
21
- console.error('🔍 [DEBUG] Loading handlers...');
22
- import { handleBrowserInit, handleBrowserClose } from './handlers/browser-handlers.js';
23
- import { handleNavigate, handleWait } from './handlers/navigation-handlers.js';
24
- import { handleClick, handleType, handleSolveCaptcha, handleRandomScroll } from './handlers/interaction-handlers.js';
25
- import { handleGetContent, handleFindSelector } from './handlers/content-handlers.js';
26
- import { handleSaveContentAsMarkdown } from './handlers/file-handlers.js';
31
+ console.error("🔍 [DEBUG] Loading handlers...");
32
+ import { handleBrowserInit, handleBrowserClose, } from "./handlers/browser-handlers.js";
33
+ import { handleNavigate, handleWait } from "./handlers/navigation-handlers.js";
34
+ import { handleClick, handleType, handleSolveCaptcha, handleRandomScroll, } from "./handlers/interaction-handlers.js";
35
+ import { handleGetContent, handleFindSelector, } from "./handlers/content-handlers.js";
36
+ import { handleSaveContentAsMarkdown } from "./handlers/file-handlers.js";
27
37
  // Import new data extraction handlers
28
- import { handleScrapeTable, handleExtractList, handleExtractJSON, handleScrapeMetaTags, handleExtractSchema } from './handlers/data-extraction-handlers.js';
38
+ import { handleScrapeTable, handleExtractList, handleExtractJSON, handleScrapeMetaTags, handleExtractSchema, } from "./handlers/data-extraction-handlers.js";
29
39
  // Import multi-element handlers
30
- import { handleBatchElementScraper, handleNestedDataExtraction, handleAttributeHarvester, handleImageScraper, handleLinkHarvester, handleMediaExtractor, handlePDFLinkFinder } from './handlers/multi-element-handlers.js';
40
+ import { handleBatchElementScraper, handleNestedDataExtraction, handleAttributeHarvester, handleImageScraper, handleLinkHarvester, handleMediaExtractor, handlePDFLinkFinder, } from "./handlers/multi-element-handlers.js";
31
41
  // Import pagination handlers
32
- import { handleAutoPagination, handleInfiniteScroll, handleMultiPageScraper, handleSitemapParser, handleBreadcrumbNavigator } from './handlers/pagination-handlers.js';
42
+ import { handleAutoPagination, handleInfiniteScroll, handleMultiPageScraper, handleSitemapParser, handleBreadcrumbNavigator, } from "./handlers/pagination-handlers.js";
33
43
  // Import data processing handlers
34
- import { handleSmartTextCleaner, handleHTMLToText, handlePriceParser, handleDateNormalizer, handleContactExtractor, handleSchemaValidator, handleRequiredFieldsChecker, handleDuplicateRemover } from './handlers/data-processing-handlers.js';
44
+ import { handleSmartTextCleaner, handleHTMLToText, handlePriceParser, handleDateNormalizer, handleContactExtractor, handleSchemaValidator, handleRequiredFieldsChecker, handleDuplicateRemover, } from "./handlers/data-processing-handlers.js";
35
45
  // Import AI-powered handlers
36
- import { handleSmartSelectorGenerator, handleContentClassification, handleSentimentAnalysis, handleSummaryGenerator, handleTranslationSupport } from './handlers/ai-powered-handlers.js';
46
+ import { handleSmartSelectorGenerator, handleContentClassification, handleSentimentAnalysis, handleSummaryGenerator, handleTranslationSupport, } from "./handlers/ai-powered-handlers.js";
37
47
  // Import search & filter handlers
38
- import { handleKeywordSearch, handleRegexPatternMatcher, handleXPathSupport, handleAdvancedCSSSelectors, handleVisualElementFinder } from './handlers/search-filter-handlers.js';
48
+ import { handleKeywordSearch, handleRegexPatternMatcher, handleXPathSupport, handleAdvancedCSSSelectors, handleVisualElementFinder, } from "./handlers/search-filter-handlers.js";
39
49
  // Import data quality handlers
40
- import { handleDataDeduplication, handleMissingDataHandler, handleDataTypeValidator, handleOutlierDetection, handleConsistencyChecker } from './handlers/data-quality-handlers.js';
50
+ import { handleDataDeduplication, handleMissingDataHandler, handleDataTypeValidator, handleOutlierDetection, handleConsistencyChecker, } from "./handlers/data-quality-handlers.js";
41
51
  // Import captcha handlers
42
- import { handleOCREngine, handleAudioCaptchaSolver, handlePuzzleCaptchaHandler } from './handlers/captcha-handlers.js';
52
+ import { handleOCREngine, handleAudioCaptchaSolver, handlePuzzleCaptchaHandler, } from "./handlers/captcha-handlers.js";
43
53
  // Import visual tools handlers
44
- import { handleFullPageScreenshot, handleElementScreenshot, handlePDFGeneration, handleVideoRecording, handleVisualComparison } from './handlers/visual-tools-handlers.js';
54
+ import { handleFullPageScreenshot, handleElementScreenshot, handlePDFGeneration, handleVideoRecording, handleVisualComparison, } from "./handlers/visual-tools-handlers.js";
45
55
  // Import API integration handlers
46
- import { handleRESTAPIEndpointFinder, handleWebhookSupport, handleAllWebsiteAPIFinder } from './handlers/api-integration-handlers.js';
56
+ import { handleRESTAPIEndpointFinder, handleWebhookSupport, handleAllWebsiteAPIFinder, } from "./handlers/api-integration-handlers.js";
47
57
  // Import smart data extractors
48
- import { handleHtmlElementsExtractor, handleTagsFinder, handleLinksFinder, handleXpathLinks, handleAjaxExtractor, handleFetchXHR, handleNetworkRecorder, handleApiFinder, handleRegexPatternFinder, handleIframeExtractor, handleEmbedPageExtractor, handleImageExtractorAdvanced, handleVideoSourceExtractor, handleVideoPlayerExtractor, handleVideoPlayerHosterFinder, handleOriginalVideoHosterFinder, handleUrlRedirectTracer, handleUserAgentExtractor } from './handlers/smart-data-extractors.js';
58
+ import { handleHtmlElementsExtractor, handleTagsFinder, handleLinksFinder, handleXpathLinks, handleAjaxExtractor, handleFetchXHR, handleNetworkRecorder, handleApiFinder, handleRegexPatternFinder, handleIframeExtractor, handleEmbedPageExtractor, handleImageExtractorAdvanced, handleVideoSourceExtractor, handleVideoPlayerExtractor, handleVideoPlayerHosterFinder, handleOriginalVideoHosterFinder, handleUrlRedirectTracer, handleUserAgentExtractor, } from "./handlers/smart-data-extractors.js";
49
59
  // Import dynamic session handlers
50
- import { handleShadowDOMExtractor, handleCookieManager, handleSessionPersistence, handleFormAutoFill, handleAjaxContentWaiter, handleModalPopupHandler, handleLoginSessionManager } from './handlers/dynamic-session-handlers.js';
60
+ import { handleShadowDOMExtractor, handleCookieManager, handleSessionPersistence, handleFormAutoFill, handleAjaxContentWaiter, handleModalPopupHandler, handleLoginSessionManager, } from "./handlers/dynamic-session-handlers.js";
51
61
  // Import monitoring & reporting handlers
52
- import { handleProgressTracker, handleErrorLogger, handleSuccessRateReporter, handleDataQualityMetrics, handlePerformanceMonitor, handleGetMonitoringSummary } from './handlers/monitoring-reporting-handlers.js';
62
+ import { handleProgressTracker, handleErrorLogger, handleSuccessRateReporter, handleDataQualityMetrics, handlePerformanceMonitor, handleGetMonitoringSummary, } from "./handlers/monitoring-reporting-handlers.js";
53
63
  // Import advanced video & media handlers
54
- import { handleVideoLinkFinder, handleVideoDownloadPage, handleVideoDownloadButton, handleVideoPlayPushSource, handleVideoPlayButtonClick, handleUrlRedirectTraceEndpoints, handleNetworkRecordingFinder, handleNetworkRecordingExtractors, handleVideoLinksFinders, handleVideosSelectors, handleLinkProcessExtracts, handleVideoLinkFindersExtracts, handleVideoDownloadButtonFinders } from './handlers/advanced-video-media-handlers.js';
64
+ import { handleVideoLinkFinder, handleVideoDownloadPage, handleVideoDownloadButton, handleVideoPlayPushSource, handleVideoPlayButtonClick, handleUrlRedirectTraceEndpoints, handleNetworkRecordingFinder, handleNetworkRecordingExtractors, handleVideoLinksFinders, handleVideosSelectors, handleLinkProcessExtracts, handleVideoLinkFindersExtracts, handleVideoDownloadButtonFinders, } from "./handlers/advanced-video-media-handlers.js";
55
65
  // Import advanced extraction handlers (Ad-bypass & Obfuscation)
56
- import { handleAdvancedVideoExtraction, handleDeobfuscateJS, handleMultiLayerRedirectTrace, handleAdProtectionDetector } from './handlers/advanced-extraction-handlers.js';
57
- console.error('🔍 [DEBUG] All modules loaded successfully');
66
+ import { handleAdvancedVideoExtraction, handleDeobfuscateJS, handleMultiLayerRedirectTrace, handleAdProtectionDetector, } from "./handlers/advanced-extraction-handlers.js";
67
+ console.error("🔍 [DEBUG] All modules loaded successfully");
58
68
  console.error(`🔍 [DEBUG] Server info: ${JSON.stringify(SERVER_INFO)}`);
59
69
  console.error(`🔍 [DEBUG] Available tools: ${TOOLS.length} tools loaded`);
60
70
  // Initialize MCP server
61
- console.error('🔍 [DEBUG] Creating MCP server instance...');
71
+ console.error("🔍 [DEBUG] Creating MCP server instance...");
62
72
  const server = new Server(SERVER_INFO, { capabilities: CAPABILITIES });
63
- console.error('🔍 [DEBUG] MCP server instance created successfully');
73
+ console.error("🔍 [DEBUG] MCP server instance created successfully");
64
74
  // Register initialize handler (CRITICAL - missing handler can cause crash)
65
- console.error('🔍 [DEBUG] Registering initialize handler...');
75
+ console.error("🔍 [DEBUG] Registering initialize handler...");
66
76
  server.setRequestHandler(InitializeRequestSchema, async (request) => {
67
77
  console.error(`🔍 [DEBUG] Initialize request received: ${JSON.stringify(request)}`);
68
78
  // Use the client's protocol version to ensure compatibility
@@ -84,25 +94,25 @@ server.setRequestHandler(InitializeRequestSchema, async (request) => {
84
94
  return response;
85
95
  });
86
96
  // Register tool handlers
87
- console.error('🔍 [DEBUG] Registering tools handler...');
97
+ console.error("🔍 [DEBUG] Registering tools handler...");
88
98
  server.setRequestHandler(ListToolsRequestSchema, async () => {
89
- console.error('🔍 [DEBUG] Tools list requested');
99
+ console.error("🔍 [DEBUG] Tools list requested");
90
100
  return { tools: TOOLS };
91
101
  });
92
102
  // Register resource handlers (placeholder)
93
- console.error('🔍 [DEBUG] Registering resources handler...');
103
+ console.error("🔍 [DEBUG] Registering resources handler...");
94
104
  server.setRequestHandler(ListResourcesRequestSchema, async () => {
95
- console.error('🔍 [DEBUG] Resources list requested');
105
+ console.error("🔍 [DEBUG] Resources list requested");
96
106
  return { resources: [] };
97
107
  });
98
108
  // Register prompt handlers (placeholder)
99
- console.error('🔍 [DEBUG] Registering prompts handler...');
109
+ console.error("🔍 [DEBUG] Registering prompts handler...");
100
110
  server.setRequestHandler(ListPromptsRequestSchema, async () => {
101
- console.error('🔍 [DEBUG] Prompts list requested');
111
+ console.error("🔍 [DEBUG] Prompts list requested");
102
112
  return { prompts: [] };
103
113
  });
104
114
  // Main tool call handler
105
- console.error('🔍 [DEBUG] Registering tool call handler...');
115
+ console.error("🔍 [DEBUG] Registering tool call handler...");
106
116
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
107
117
  const { name, arguments: args } = request.params;
108
118
  console.error(`🔍 [DEBUG] Tool call received: ${name} with args: ${JSON.stringify(args)}`);
@@ -308,152 +318,152 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
308
318
  result = await handleAllWebsiteAPIFinder(args);
309
319
  break;
310
320
  // Smart Data Extractors (Advanced)
311
- case 'html_elements_extractor':
321
+ case "html_elements_extractor":
312
322
  result = await handleHtmlElementsExtractor(args || {});
313
323
  break;
314
- case 'tags_finder':
324
+ case "tags_finder":
315
325
  result = await handleTagsFinder(args || {});
316
326
  break;
317
- case 'links_finder':
327
+ case "links_finder":
318
328
  result = await handleLinksFinder(args || {});
319
329
  break;
320
- case 'xpath_links':
330
+ case "xpath_links":
321
331
  result = await handleXpathLinks(args || {});
322
332
  break;
323
- case 'ajax_extractor':
333
+ case "ajax_extractor":
324
334
  result = await handleAjaxExtractor(args || {});
325
335
  break;
326
- case 'fetch_xhr':
336
+ case "fetch_xhr":
327
337
  result = await handleFetchXHR(args || {});
328
338
  break;
329
- case 'network_recorder':
339
+ case "network_recorder":
330
340
  result = await handleNetworkRecorder(args || {});
331
341
  break;
332
- case 'api_finder':
342
+ case "api_finder":
333
343
  result = await handleApiFinder(args || {});
334
344
  break;
335
- case 'regex_pattern_finder':
345
+ case "regex_pattern_finder":
336
346
  result = await handleRegexPatternFinder(args);
337
347
  break;
338
- case 'iframe_extractor':
348
+ case "iframe_extractor":
339
349
  result = await handleIframeExtractor(args || {});
340
350
  break;
341
- case 'embed_page_extractor':
351
+ case "embed_page_extractor":
342
352
  result = await handleEmbedPageExtractor(args || {});
343
353
  break;
344
- case 'image_extractor_advanced':
354
+ case "image_extractor_advanced":
345
355
  result = await handleImageExtractorAdvanced(args || {});
346
356
  break;
347
- case 'video_source_extractor':
357
+ case "video_source_extractor":
348
358
  result = await handleVideoSourceExtractor(args || {});
349
359
  break;
350
- case 'video_player_extractor':
360
+ case "video_player_extractor":
351
361
  result = await handleVideoPlayerExtractor(args || {});
352
362
  break;
353
- case 'video_player_hoster_finder':
363
+ case "video_player_hoster_finder":
354
364
  result = await handleVideoPlayerHosterFinder(args || {});
355
365
  break;
356
- case 'original_video_hoster_finder':
366
+ case "original_video_hoster_finder":
357
367
  result = await handleOriginalVideoHosterFinder(args || {});
358
368
  break;
359
- case 'url_redirect_tracer':
369
+ case "url_redirect_tracer":
360
370
  result = await handleUrlRedirectTracer(args);
361
371
  break;
362
- case 'user_agent_extractor':
372
+ case "user_agent_extractor":
363
373
  result = await handleUserAgentExtractor(args || {});
364
374
  break;
365
375
  // Dynamic Content & Session Handling
366
- case 'shadow_dom_extractor':
376
+ case "shadow_dom_extractor":
367
377
  result = await handleShadowDOMExtractor(args || {});
368
378
  break;
369
- case 'cookie_manager':
379
+ case "cookie_manager":
370
380
  result = await handleCookieManager(args);
371
381
  break;
372
- case 'session_persistence':
382
+ case "session_persistence":
373
383
  result = await handleSessionPersistence(args);
374
384
  break;
375
- case 'form_auto_fill':
385
+ case "form_auto_fill":
376
386
  result = await handleFormAutoFill(args);
377
387
  break;
378
- case 'ajax_content_waiter':
388
+ case "ajax_content_waiter":
379
389
  result = await handleAjaxContentWaiter(args);
380
390
  break;
381
- case 'modal_popup_handler':
391
+ case "modal_popup_handler":
382
392
  result = await handleModalPopupHandler(args);
383
393
  break;
384
- case 'login_session_manager':
394
+ case "login_session_manager":
385
395
  result = await handleLoginSessionManager(args);
386
396
  break;
387
397
  // Monitoring & Reporting
388
- case 'progress_tracker':
398
+ case "progress_tracker":
389
399
  result = await handleProgressTracker(args || {});
390
400
  break;
391
- case 'error_logger':
401
+ case "error_logger":
392
402
  result = await handleErrorLogger(args || {});
393
403
  break;
394
- case 'success_rate_reporter':
404
+ case "success_rate_reporter":
395
405
  result = await handleSuccessRateReporter(args || {});
396
406
  break;
397
- case 'data_quality_metrics':
407
+ case "data_quality_metrics":
398
408
  result = await handleDataQualityMetrics(args || {});
399
409
  break;
400
- case 'performance_monitor':
410
+ case "performance_monitor":
401
411
  result = await handlePerformanceMonitor(args || {});
402
412
  break;
403
- case 'monitoring_summary':
413
+ case "monitoring_summary":
404
414
  result = await handleGetMonitoringSummary(args || {});
405
415
  break;
406
416
  // Advanced Video & Media Download Tools
407
- case 'video_link_finder':
417
+ case "video_link_finder":
408
418
  result = await handleVideoLinkFinder(args || {});
409
419
  break;
410
- case 'video_download_page':
420
+ case "video_download_page":
411
421
  result = await handleVideoDownloadPage(args || {});
412
422
  break;
413
- case 'video_download_button':
423
+ case "video_download_button":
414
424
  result = await handleVideoDownloadButton(args);
415
425
  break;
416
- case 'video_play_push_source':
426
+ case "video_play_push_source":
417
427
  result = await handleVideoPlayPushSource(args || {});
418
428
  break;
419
- case 'video_play_button_click':
429
+ case "video_play_button_click":
420
430
  result = await handleVideoPlayButtonClick(args || {});
421
431
  break;
422
- case 'url_redirect_trace_endpoints':
432
+ case "url_redirect_trace_endpoints":
423
433
  result = await handleUrlRedirectTraceEndpoints(args);
424
434
  break;
425
- case 'network_recording_finder':
435
+ case "network_recording_finder":
426
436
  result = await handleNetworkRecordingFinder(args || {});
427
437
  break;
428
- case 'network_recording_extractors':
438
+ case "network_recording_extractors":
429
439
  result = await handleNetworkRecordingExtractors(args || {});
430
440
  break;
431
- case 'video_links_finders':
441
+ case "video_links_finders":
432
442
  result = await handleVideoLinksFinders(args || {});
433
443
  break;
434
- case 'videos_selectors':
444
+ case "videos_selectors":
435
445
  result = await handleVideosSelectors(args || {});
436
446
  break;
437
- case 'link_process_extracts':
447
+ case "link_process_extracts":
438
448
  result = await handleLinkProcessExtracts(args || {});
439
449
  break;
440
- case 'video_link_finders_extracts':
450
+ case "video_link_finders_extracts":
441
451
  result = await handleVideoLinkFindersExtracts(args || {});
442
452
  break;
443
- case 'video_download_button_finders':
453
+ case "video_download_button_finders":
444
454
  result = await handleVideoDownloadButtonFinders(args || {});
445
455
  break;
446
456
  // Advanced Extraction Tools (Ad-Bypass & Obfuscation)
447
- case 'advanced_video_extraction':
457
+ case "advanced_video_extraction":
448
458
  result = await handleAdvancedVideoExtraction(args || {});
449
459
  break;
450
- case 'deobfuscate_js':
460
+ case "deobfuscate_js":
451
461
  result = await handleDeobfuscateJS(args || {});
452
462
  break;
453
- case 'multi_layer_redirect_trace':
463
+ case "multi_layer_redirect_trace":
454
464
  result = await handleMultiLayerRedirectTrace(args);
455
465
  break;
456
- case 'ad_protection_detector':
466
+ case "ad_protection_detector":
457
467
  result = await handleAdProtectionDetector(args || {});
458
468
  break;
459
469
  default:
@@ -466,16 +476,16 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
466
476
  const errorMessage = error instanceof Error ? error.message : String(error);
467
477
  console.error(`Tool ${name} failed:`, errorMessage);
468
478
  // For workflow validation errors, throw them so MCP SDK handles them properly
469
- if (errorMessage.includes('cannot be executed in current state') ||
470
- errorMessage.includes('Cannot search for selectors') ||
471
- errorMessage.includes('Next Steps:')) {
479
+ if (errorMessage.includes("cannot be executed in current state") ||
480
+ errorMessage.includes("Cannot search for selectors") ||
481
+ errorMessage.includes("Next Steps:")) {
472
482
  throw error;
473
483
  }
474
484
  // For other errors, return formatted response
475
485
  return {
476
486
  content: [
477
487
  {
478
- type: 'text',
488
+ type: "text",
479
489
  text: `❌ Tool execution failed: ${errorMessage}`,
480
490
  },
481
491
  ],
@@ -484,18 +494,18 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
484
494
  }
485
495
  });
486
496
  // Main function - now using multi-protocol launcher
487
- import { main as launcherMain } from './launcher.js';
497
+ import { main as launcherMain } from "./launcher.js";
488
498
  async function main() {
489
499
  // Check if user wants multi-protocol mode
490
- const hasProtocolArg = process.argv.some(arg => arg === '--mode' || arg === '-m' || arg === '--http' || arg === '--lsp');
500
+ const hasProtocolArg = process.argv.some((arg) => arg === "--mode" || arg === "-m" || arg === "--http" || arg === "--lsp");
491
501
  if (hasProtocolArg) {
492
502
  // Use multi-protocol launcher
493
503
  await launcherMain();
494
504
  }
495
505
  else {
496
506
  // Default: MCP mode (backward compatibility)
497
- console.error('🔍 [DEBUG] Starting in MCP mode (default)...');
498
- console.error('💡 Tip: Use --mode http or --mode lsp for other protocols');
507
+ console.error("🔍 [DEBUG] Starting in MCP mode (default)...");
508
+ console.error("💡 Tip: Use --mode http or --mode lsp for other protocols");
499
509
  setupProcessCleanup(async () => {
500
510
  await closeBrowser();
501
511
  await forceKillAllBraveProcesses();
@@ -503,65 +513,65 @@ async function main() {
503
513
  const transport = new StdioServerTransport();
504
514
  await withErrorHandling(async () => {
505
515
  await server.connect(transport);
506
- console.error('🚀 Brave Real Browser MCP Server started successfully');
507
- console.error('📋 Available tools:', TOOLS.map(t => t.name).join(', '));
508
- }, 'Failed to start MCP server');
516
+ console.error("🚀 Brave Real Browser MCP Server started successfully");
517
+ console.error("📋 Available tools:", TOOLS.map((t) => t.name).join(", "));
518
+ }, "Failed to start MCP server");
509
519
  }
510
520
  }
511
521
  // Enhanced error handling with debug info
512
- console.error('🔍 [DEBUG] Setting up error handlers...');
513
- process.on('uncaughtException', (error) => {
522
+ console.error("🔍 [DEBUG] Setting up error handlers...");
523
+ process.on("uncaughtException", (error) => {
514
524
  console.error(`🔍 [DEBUG] Uncaught exception at ${new Date().toISOString()}`);
515
- console.error('❌ Uncaught exception:', error);
525
+ console.error("❌ Uncaught exception:", error);
516
526
  console.error(`🔍 [DEBUG] Stack trace:`, error.stack);
517
527
  process.exit(1);
518
528
  });
519
- process.on('unhandledRejection', (reason, promise) => {
529
+ process.on("unhandledRejection", (reason, promise) => {
520
530
  console.error(`🔍 [DEBUG] Unhandled rejection at ${new Date().toISOString()}`);
521
- console.error('❌ Unhandled rejection:', reason);
531
+ console.error("❌ Unhandled rejection:", reason);
522
532
  console.error(`🔍 [DEBUG] Promise:`, promise);
523
533
  process.exit(1);
524
534
  });
525
535
  // Process lifecycle debugging
526
- process.on('exit', (code) => {
536
+ process.on("exit", (code) => {
527
537
  console.error(`🔍 [DEBUG] Process exiting with code: ${code} at ${new Date().toISOString()}`);
528
538
  });
529
- process.on('beforeExit', (code) => {
539
+ process.on("beforeExit", (code) => {
530
540
  console.error(`🔍 [DEBUG] Before exit event with code: ${code} at ${new Date().toISOString()}`);
531
541
  });
532
- process.on('SIGTERM', () => {
542
+ process.on("SIGTERM", () => {
533
543
  console.error(`🔍 [DEBUG] SIGTERM received at ${new Date().toISOString()}`);
534
544
  });
535
- process.on('SIGINT', () => {
545
+ process.on("SIGINT", () => {
536
546
  console.error(`🔍 [DEBUG] SIGINT received at ${new Date().toISOString()}`);
537
547
  });
538
- console.error('🔍 [DEBUG] All error handlers registered');
548
+ console.error("🔍 [DEBUG] All error handlers registered");
539
549
  // Start the server
540
- console.error('🔍 [DEBUG] Checking if module is main...');
550
+ console.error("🔍 [DEBUG] Checking if module is main...");
541
551
  console.error(`🔍 [DEBUG] import.meta.url: ${import.meta.url}`);
542
552
  console.error(`🔍 [DEBUG] process.argv[1]: ${process.argv[1]}`);
543
553
  console.error(`🔍 [DEBUG] process.argv[0]: ${process.argv[0]}`);
544
554
  // Enhanced main module detection for npx compatibility
545
555
  const isMain = import.meta.url === `file://${process.argv[1]}` ||
546
- process.argv[1].includes('brave-real-browser-mcp-server') ||
547
- process.argv[1].endsWith('.bin/brave-real-browser-mcp-server') ||
548
- process.argv.some(arg => arg.includes('brave-real-browser-mcp-server'));
556
+ process.argv[1].includes("brave-real-browser-mcp-server") ||
557
+ process.argv[1].endsWith(".bin/brave-real-browser-mcp-server") ||
558
+ process.argv.some((arg) => arg.includes("brave-real-browser-mcp-server"));
549
559
  console.error(`🔍 [DEBUG] Enhanced main detection result: ${isMain}`);
550
560
  if (isMain) {
551
- console.error('🔍 [DEBUG] Module is main - starting server...');
561
+ console.error("🔍 [DEBUG] Module is main - starting server...");
552
562
  main().catch((error) => {
553
563
  console.error(`🔍 [DEBUG] Main function failed at ${new Date().toISOString()}`);
554
- console.error('❌ Failed to start server:', error);
564
+ console.error("❌ Failed to start server:", error);
555
565
  console.error(`🔍 [DEBUG] Error stack:`, error.stack);
556
566
  process.exit(1);
557
567
  });
558
568
  }
559
569
  else {
560
- console.error('🔍 [DEBUG] Module is not main - not starting server');
561
- console.error('🔍 [DEBUG] FORCE STARTING - This is likely an npx execution');
570
+ console.error("🔍 [DEBUG] Module is not main - not starting server");
571
+ console.error("🔍 [DEBUG] FORCE STARTING - This is likely an npx execution");
562
572
  main().catch((error) => {
563
573
  console.error(`🔍 [DEBUG] Forced main function failed at ${new Date().toISOString()}`);
564
- console.error('❌ Failed to start server:', error);
574
+ console.error("❌ Failed to start server:", error);
565
575
  console.error(`🔍 [DEBUG] Error stack:`, error.stack);
566
576
  process.exit(1);
567
577
  });