brave-real-browser-mcp-server 2.14.0 → 2.14.1
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 +10 -91
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,34 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Debug logging setup - Log process start
|
|
3
|
-
console.error(`🔍 [DEBUG] Process starting - PID: ${process.pid}, Node: ${process.version}, Platform: ${process.platform}`);
|
|
4
|
-
console.error(`🔍 [DEBUG] Working directory: ${process.cwd()}`);
|
|
5
|
-
console.error(`🔍 [DEBUG] Command args: ${process.argv.join(" ")}`);
|
|
6
2
|
// Universal AI IDE Adapter - Auto-detect and support all AI IDEs
|
|
7
|
-
console.error("🔍 [DEBUG] Loading Universal IDE Adapter...");
|
|
8
3
|
import { UniversalIDEAdapter, } from "./universal-ide-adapter.js";
|
|
9
4
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
10
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
11
6
|
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ListPromptsRequestSchema, InitializeRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
12
|
-
console.error("🔍 [DEBUG] MCP SDK imports completed successfully");
|
|
13
7
|
// Import extracted modules
|
|
14
|
-
console.error("🔍 [DEBUG] Loading tool definitions...");
|
|
15
8
|
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
9
|
import { withErrorHandling } from "./system-utils.js";
|
|
19
10
|
import { validateMCPResponse } from "./mcp-response-validator.js";
|
|
20
|
-
console.error("🔍 [DEBUG] Loading browser manager...");
|
|
21
11
|
import { closeBrowser, forceKillAllBraveProcesses } from "./browser-manager.js";
|
|
22
|
-
console.error("🔍 [DEBUG] Loading core infrastructure...");
|
|
23
12
|
import { setupProcessCleanup, } from "./core-infrastructure.js";
|
|
24
13
|
// Initialize Universal IDE Adapter
|
|
25
14
|
const universalAdapter = new UniversalIDEAdapter({
|
|
26
15
|
enableAutoDetection: true,
|
|
27
16
|
fallbackToHttp: true,
|
|
28
|
-
logDetectionDetails:
|
|
17
|
+
logDetectionDetails: false,
|
|
29
18
|
});
|
|
30
19
|
// Import handlers
|
|
31
|
-
console.error("🔍 [DEBUG] Loading handlers...");
|
|
32
20
|
import { handleBrowserInit, handleBrowserClose, } from "./handlers/browser-handlers.js";
|
|
33
21
|
import { handleNavigate, handleWait } from "./handlers/navigation-handlers.js";
|
|
34
22
|
import { handleClick, handleType, handleSolveCaptcha, handleRandomScroll, } from "./handlers/interaction-handlers.js";
|
|
@@ -64,54 +52,30 @@ import { handleProgressTracker, handleErrorLogger, handleSuccessRateReporter, ha
|
|
|
64
52
|
import { handleVideoLinkFinder, handleVideoDownloadPage, handleVideoDownloadButton, handleVideoPlayPushSource, handleVideoPlayButtonClick, handleUrlRedirectTraceEndpoints, handleNetworkRecordingFinder, handleNetworkRecordingExtractors, handleVideoLinksFinders, handleVideosSelectors, handleLinkProcessExtracts, handleVideoLinkFindersExtracts, handleVideoDownloadButtonFinders, } from "./handlers/advanced-video-media-handlers.js";
|
|
65
53
|
// Import advanced extraction handlers (Ad-bypass & Obfuscation)
|
|
66
54
|
import { handleAdvancedVideoExtraction, handleDeobfuscateJS, handleMultiLayerRedirectTrace, handleAdProtectionDetector, } from "./handlers/advanced-extraction-handlers.js";
|
|
67
|
-
console.error("🔍 [DEBUG] All modules loaded successfully");
|
|
68
|
-
console.error(`🔍 [DEBUG] Server info: ${JSON.stringify(SERVER_INFO)}`);
|
|
69
|
-
console.error(`🔍 [DEBUG] Available tools: ${TOOLS.length} tools loaded`);
|
|
70
55
|
// Initialize MCP server
|
|
71
|
-
console.error("🔍 [DEBUG] Creating MCP server instance...");
|
|
72
56
|
const server = new Server(SERVER_INFO, { capabilities: CAPABILITIES });
|
|
73
|
-
|
|
74
|
-
// Register initialize handler (CRITICAL - missing handler can cause crash)
|
|
75
|
-
console.error("🔍 [DEBUG] Registering initialize handler...");
|
|
57
|
+
// Register initialize handler
|
|
76
58
|
server.setRequestHandler(InitializeRequestSchema, async (request) => {
|
|
77
|
-
console.error(`🔍 [DEBUG] Initialize request received: ${JSON.stringify(request)}`);
|
|
78
|
-
// Use the client's protocol version to ensure compatibility
|
|
79
59
|
const clientProtocolVersion = request.params.protocolVersion;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
protocolVersion: clientProtocolVersion, // Match client version for compatibility
|
|
60
|
+
return {
|
|
61
|
+
protocolVersion: clientProtocolVersion,
|
|
83
62
|
capabilities: CAPABILITIES,
|
|
84
63
|
serverInfo: SERVER_INFO,
|
|
85
64
|
};
|
|
86
|
-
console.error(`🔍 [DEBUG] Sending initialize response: ${JSON.stringify(response)}`);
|
|
87
|
-
// Add a small delay to see if there are any immediate errors after response
|
|
88
|
-
setTimeout(() => {
|
|
89
|
-
console.error(`🔍 [DEBUG] 1 second after initialize response - server still alive`);
|
|
90
|
-
}, 1000);
|
|
91
|
-
setTimeout(() => {
|
|
92
|
-
console.error(`🔍 [DEBUG] 5 seconds after initialize response - server still alive`);
|
|
93
|
-
}, 5000);
|
|
94
|
-
return response;
|
|
95
65
|
});
|
|
96
66
|
// Register tool handlers
|
|
97
|
-
console.error("🔍 [DEBUG] Registering tools handler...");
|
|
98
67
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
99
|
-
console.error("🔍 [DEBUG] Tools list requested");
|
|
100
68
|
return { tools: TOOLS };
|
|
101
69
|
});
|
|
102
|
-
// Register resource handlers
|
|
103
|
-
console.error("🔍 [DEBUG] Registering resources handler...");
|
|
70
|
+
// Register resource handlers
|
|
104
71
|
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
105
|
-
console.error("🔍 [DEBUG] Resources list requested");
|
|
106
72
|
return { resources: [] };
|
|
107
73
|
});
|
|
108
|
-
// Register prompt handlers
|
|
109
|
-
console.error("🔍 [DEBUG] Registering prompts handler...");
|
|
74
|
+
// Register prompt handlers
|
|
110
75
|
server.setRequestHandler(ListPromptsRequestSchema, async () => {
|
|
111
|
-
console.error("🔍 [DEBUG] Prompts list requested");
|
|
112
76
|
return { prompts: [] };
|
|
113
77
|
});
|
|
114
|
-
// Tool execution function
|
|
78
|
+
// Tool execution function
|
|
115
79
|
export async function executeToolByName(name, args) {
|
|
116
80
|
try {
|
|
117
81
|
let result;
|
|
@@ -466,19 +430,15 @@ export async function executeToolByName(name, args) {
|
|
|
466
430
|
default:
|
|
467
431
|
throw new Error(`Unknown tool: ${name}`);
|
|
468
432
|
}
|
|
469
|
-
// Validate MCP response format universally
|
|
470
433
|
return validateMCPResponse(result, name);
|
|
471
434
|
}
|
|
472
435
|
catch (error) {
|
|
473
436
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
474
|
-
console.error(`Tool ${name} failed:`, errorMessage);
|
|
475
|
-
// For workflow validation errors, throw them so MCP SDK handles them properly
|
|
476
437
|
if (errorMessage.includes("cannot be executed in current state") ||
|
|
477
438
|
errorMessage.includes("Cannot search for selectors") ||
|
|
478
439
|
errorMessage.includes("Next Steps:")) {
|
|
479
440
|
throw error;
|
|
480
441
|
}
|
|
481
|
-
// For other errors, return formatted response
|
|
482
442
|
return {
|
|
483
443
|
content: [
|
|
484
444
|
{
|
|
@@ -491,25 +451,18 @@ export async function executeToolByName(name, args) {
|
|
|
491
451
|
}
|
|
492
452
|
}
|
|
493
453
|
// Main tool call handler
|
|
494
|
-
console.error("🔍 [DEBUG] Registering tool call handler...");
|
|
495
454
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
496
455
|
const { name, arguments: args } = request.params;
|
|
497
|
-
console.error(`🔍 [DEBUG] Tool call received: ${name} with args: ${JSON.stringify(args)}`);
|
|
498
456
|
return await executeToolByName(name, args);
|
|
499
457
|
});
|
|
500
|
-
// Main function
|
|
458
|
+
// Main function
|
|
501
459
|
import { main as launcherMain } from "./launcher.js";
|
|
502
460
|
async function main() {
|
|
503
|
-
// Check if user wants multi-protocol mode
|
|
504
461
|
const hasProtocolArg = process.argv.some((arg) => arg === "--mode" || arg === "-m" || arg === "--http" || arg === "--lsp");
|
|
505
462
|
if (hasProtocolArg) {
|
|
506
|
-
// Use multi-protocol launcher
|
|
507
463
|
await launcherMain();
|
|
508
464
|
}
|
|
509
465
|
else {
|
|
510
|
-
// Default: MCP mode (backward compatibility)
|
|
511
|
-
console.error("🔍 [DEBUG] Starting in MCP mode (default)...");
|
|
512
|
-
console.error("💡 Tip: Use --mode http or --mode lsp for other protocols");
|
|
513
466
|
setupProcessCleanup(async () => {
|
|
514
467
|
await closeBrowser();
|
|
515
468
|
await forceKillAllBraveProcesses();
|
|
@@ -517,66 +470,32 @@ async function main() {
|
|
|
517
470
|
const transport = new StdioServerTransport();
|
|
518
471
|
await withErrorHandling(async () => {
|
|
519
472
|
await server.connect(transport);
|
|
520
|
-
console.error("🚀 Brave Real Browser MCP Server started successfully");
|
|
521
|
-
console.error("📋 Available tools:", TOOLS.map((t) => t.name).join(", "));
|
|
522
473
|
}, "Failed to start MCP server");
|
|
523
474
|
}
|
|
524
475
|
}
|
|
525
|
-
//
|
|
526
|
-
console.error("🔍 [DEBUG] Setting up error handlers...");
|
|
476
|
+
// Error handling
|
|
527
477
|
process.on("uncaughtException", (error) => {
|
|
528
|
-
console.error(`🔍 [DEBUG] Uncaught exception at ${new Date().toISOString()}`);
|
|
529
478
|
console.error("❌ Uncaught exception:", error);
|
|
530
|
-
console.error(`🔍 [DEBUG] Stack trace:`, error.stack);
|
|
531
479
|
process.exit(1);
|
|
532
480
|
});
|
|
533
|
-
process.on("unhandledRejection", (reason
|
|
534
|
-
console.error(`🔍 [DEBUG] Unhandled rejection at ${new Date().toISOString()}`);
|
|
481
|
+
process.on("unhandledRejection", (reason) => {
|
|
535
482
|
console.error("❌ Unhandled rejection:", reason);
|
|
536
|
-
console.error(`🔍 [DEBUG] Promise:`, promise);
|
|
537
483
|
process.exit(1);
|
|
538
484
|
});
|
|
539
|
-
// Process lifecycle debugging
|
|
540
|
-
process.on("exit", (code) => {
|
|
541
|
-
console.error(`🔍 [DEBUG] Process exiting with code: ${code} at ${new Date().toISOString()}`);
|
|
542
|
-
});
|
|
543
|
-
process.on("beforeExit", (code) => {
|
|
544
|
-
console.error(`🔍 [DEBUG] Before exit event with code: ${code} at ${new Date().toISOString()}`);
|
|
545
|
-
});
|
|
546
|
-
process.on("SIGTERM", () => {
|
|
547
|
-
console.error(`🔍 [DEBUG] SIGTERM received at ${new Date().toISOString()}`);
|
|
548
|
-
});
|
|
549
|
-
process.on("SIGINT", () => {
|
|
550
|
-
console.error(`🔍 [DEBUG] SIGINT received at ${new Date().toISOString()}`);
|
|
551
|
-
});
|
|
552
|
-
console.error("🔍 [DEBUG] All error handlers registered");
|
|
553
485
|
// Start the server
|
|
554
|
-
console.error("🔍 [DEBUG] Checking if module is main...");
|
|
555
|
-
console.error(`🔍 [DEBUG] import.meta.url: ${import.meta.url}`);
|
|
556
|
-
console.error(`🔍 [DEBUG] process.argv[1]: ${process.argv[1]}`);
|
|
557
|
-
console.error(`🔍 [DEBUG] process.argv[0]: ${process.argv[0]}`);
|
|
558
|
-
// Enhanced main module detection for npx compatibility
|
|
559
486
|
const isMain = import.meta.url === `file://${process.argv[1]}` ||
|
|
560
487
|
process.argv[1].includes("brave-real-browser-mcp-server") ||
|
|
561
488
|
process.argv[1].endsWith(".bin/brave-real-browser-mcp-server") ||
|
|
562
489
|
process.argv.some((arg) => arg.includes("brave-real-browser-mcp-server"));
|
|
563
|
-
console.error(`🔍 [DEBUG] Enhanced main detection result: ${isMain}`);
|
|
564
490
|
if (isMain) {
|
|
565
|
-
console.error("🔍 [DEBUG] Module is main - starting server...");
|
|
566
491
|
main().catch((error) => {
|
|
567
|
-
console.error(`🔍 [DEBUG] Main function failed at ${new Date().toISOString()}`);
|
|
568
492
|
console.error("❌ Failed to start server:", error);
|
|
569
|
-
console.error(`🔍 [DEBUG] Error stack:`, error.stack);
|
|
570
493
|
process.exit(1);
|
|
571
494
|
});
|
|
572
495
|
}
|
|
573
496
|
else {
|
|
574
|
-
console.error("🔍 [DEBUG] Module is not main - not starting server");
|
|
575
|
-
console.error("🔍 [DEBUG] FORCE STARTING - This is likely an npx execution");
|
|
576
497
|
main().catch((error) => {
|
|
577
|
-
console.error(`🔍 [DEBUG] Forced main function failed at ${new Date().toISOString()}`);
|
|
578
498
|
console.error("❌ Failed to start server:", error);
|
|
579
|
-
console.error(`🔍 [DEBUG] Error stack:`, error.stack);
|
|
580
499
|
process.exit(1);
|
|
581
500
|
});
|
|
582
501
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brave-real-browser-mcp-server",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.1",
|
|
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",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"test:brave:cleanup": "taskkill /F /IM brave.exe || pkill -f brave || true"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
42
|
+
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
43
43
|
"@types/turndown": "^5.0.6",
|
|
44
44
|
"ajv": "^8.12.0",
|
|
45
45
|
"axios": "^1.6.5",
|