brave-real-browser-mcp-server 2.14.2 → 2.14.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/dist/index.js +91 -10
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,22 +1,34 @@
|
|
|
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(" ")}`);
|
|
2
6
|
// Universal AI IDE Adapter - Auto-detect and support all AI IDEs
|
|
7
|
+
console.error("🔍 [DEBUG] Loading Universal IDE Adapter...");
|
|
3
8
|
import { UniversalIDEAdapter, } from "./universal-ide-adapter.js";
|
|
4
9
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
10
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
11
|
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ListPromptsRequestSchema, InitializeRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
12
|
+
console.error("🔍 [DEBUG] MCP SDK imports completed successfully");
|
|
7
13
|
// Import extracted modules
|
|
14
|
+
console.error("🔍 [DEBUG] Loading tool definitions...");
|
|
8
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...");
|
|
9
18
|
import { withErrorHandling } from "./system-utils.js";
|
|
10
19
|
import { validateMCPResponse } from "./mcp-response-validator.js";
|
|
20
|
+
console.error("🔍 [DEBUG] Loading browser manager...");
|
|
11
21
|
import { closeBrowser, forceKillAllBraveProcesses } from "./browser-manager.js";
|
|
22
|
+
console.error("🔍 [DEBUG] Loading core infrastructure...");
|
|
12
23
|
import { setupProcessCleanup, } from "./core-infrastructure.js";
|
|
13
24
|
// Initialize Universal IDE Adapter
|
|
14
25
|
const universalAdapter = new UniversalIDEAdapter({
|
|
15
26
|
enableAutoDetection: true,
|
|
16
27
|
fallbackToHttp: true,
|
|
17
|
-
logDetectionDetails:
|
|
28
|
+
logDetectionDetails: true,
|
|
18
29
|
});
|
|
19
30
|
// Import handlers
|
|
31
|
+
console.error("🔍 [DEBUG] Loading handlers...");
|
|
20
32
|
import { handleBrowserInit, handleBrowserClose, } from "./handlers/browser-handlers.js";
|
|
21
33
|
import { handleNavigate, handleWait } from "./handlers/navigation-handlers.js";
|
|
22
34
|
import { handleClick, handleType, handleSolveCaptcha, handleRandomScroll, } from "./handlers/interaction-handlers.js";
|
|
@@ -52,30 +64,54 @@ import { handleProgressTracker, handleErrorLogger, handleSuccessRateReporter, ha
|
|
|
52
64
|
import { handleVideoLinkFinder, handleVideoDownloadPage, handleVideoDownloadButton, handleVideoPlayPushSource, handleVideoPlayButtonClick, handleUrlRedirectTraceEndpoints, handleNetworkRecordingFinder, handleNetworkRecordingExtractors, handleVideoLinksFinders, handleVideosSelectors, handleLinkProcessExtracts, handleVideoLinkFindersExtracts, handleVideoDownloadButtonFinders, } from "./handlers/advanced-video-media-handlers.js";
|
|
53
65
|
// Import advanced extraction handlers (Ad-bypass & Obfuscation)
|
|
54
66
|
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`);
|
|
55
70
|
// Initialize MCP server
|
|
71
|
+
console.error("🔍 [DEBUG] Creating MCP server instance...");
|
|
56
72
|
const server = new Server(SERVER_INFO, { capabilities: CAPABILITIES });
|
|
57
|
-
|
|
73
|
+
console.error("🔍 [DEBUG] MCP server instance created successfully");
|
|
74
|
+
// Register initialize handler (CRITICAL - missing handler can cause crash)
|
|
75
|
+
console.error("🔍 [DEBUG] Registering initialize handler...");
|
|
58
76
|
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
|
|
59
79
|
const clientProtocolVersion = request.params.protocolVersion;
|
|
60
|
-
|
|
61
|
-
|
|
80
|
+
console.error(`🔍 [DEBUG] Client protocol version: ${clientProtocolVersion}`);
|
|
81
|
+
const response = {
|
|
82
|
+
protocolVersion: clientProtocolVersion, // Match client version for compatibility
|
|
62
83
|
capabilities: CAPABILITIES,
|
|
63
84
|
serverInfo: SERVER_INFO,
|
|
64
85
|
};
|
|
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;
|
|
65
95
|
});
|
|
66
96
|
// Register tool handlers
|
|
97
|
+
console.error("🔍 [DEBUG] Registering tools handler...");
|
|
67
98
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
99
|
+
console.error("🔍 [DEBUG] Tools list requested");
|
|
68
100
|
return { tools: TOOLS };
|
|
69
101
|
});
|
|
70
|
-
// Register resource handlers
|
|
102
|
+
// Register resource handlers (placeholder)
|
|
103
|
+
console.error("🔍 [DEBUG] Registering resources handler...");
|
|
71
104
|
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
105
|
+
console.error("🔍 [DEBUG] Resources list requested");
|
|
72
106
|
return { resources: [] };
|
|
73
107
|
});
|
|
74
|
-
// Register prompt handlers
|
|
108
|
+
// Register prompt handlers (placeholder)
|
|
109
|
+
console.error("🔍 [DEBUG] Registering prompts handler...");
|
|
75
110
|
server.setRequestHandler(ListPromptsRequestSchema, async () => {
|
|
111
|
+
console.error("🔍 [DEBUG] Prompts list requested");
|
|
76
112
|
return { prompts: [] };
|
|
77
113
|
});
|
|
78
|
-
// Tool execution function
|
|
114
|
+
// Tool execution function - exported for use in transports
|
|
79
115
|
export async function executeToolByName(name, args) {
|
|
80
116
|
try {
|
|
81
117
|
let result;
|
|
@@ -430,15 +466,19 @@ export async function executeToolByName(name, args) {
|
|
|
430
466
|
default:
|
|
431
467
|
throw new Error(`Unknown tool: ${name}`);
|
|
432
468
|
}
|
|
469
|
+
// Validate MCP response format universally
|
|
433
470
|
return validateMCPResponse(result, name);
|
|
434
471
|
}
|
|
435
472
|
catch (error) {
|
|
436
473
|
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
|
|
437
476
|
if (errorMessage.includes("cannot be executed in current state") ||
|
|
438
477
|
errorMessage.includes("Cannot search for selectors") ||
|
|
439
478
|
errorMessage.includes("Next Steps:")) {
|
|
440
479
|
throw error;
|
|
441
480
|
}
|
|
481
|
+
// For other errors, return formatted response
|
|
442
482
|
return {
|
|
443
483
|
content: [
|
|
444
484
|
{
|
|
@@ -451,18 +491,25 @@ export async function executeToolByName(name, args) {
|
|
|
451
491
|
}
|
|
452
492
|
}
|
|
453
493
|
// Main tool call handler
|
|
494
|
+
console.error("🔍 [DEBUG] Registering tool call handler...");
|
|
454
495
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
455
496
|
const { name, arguments: args } = request.params;
|
|
497
|
+
console.error(`🔍 [DEBUG] Tool call received: ${name} with args: ${JSON.stringify(args)}`);
|
|
456
498
|
return await executeToolByName(name, args);
|
|
457
499
|
});
|
|
458
|
-
// Main function
|
|
500
|
+
// Main function - now using multi-protocol launcher
|
|
459
501
|
import { main as launcherMain } from "./launcher.js";
|
|
460
502
|
async function main() {
|
|
503
|
+
// Check if user wants multi-protocol mode
|
|
461
504
|
const hasProtocolArg = process.argv.some((arg) => arg === "--mode" || arg === "-m" || arg === "--http" || arg === "--lsp");
|
|
462
505
|
if (hasProtocolArg) {
|
|
506
|
+
// Use multi-protocol launcher
|
|
463
507
|
await launcherMain();
|
|
464
508
|
}
|
|
465
509
|
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");
|
|
466
513
|
setupProcessCleanup(async () => {
|
|
467
514
|
await closeBrowser();
|
|
468
515
|
await forceKillAllBraveProcesses();
|
|
@@ -470,32 +517,66 @@ async function main() {
|
|
|
470
517
|
const transport = new StdioServerTransport();
|
|
471
518
|
await withErrorHandling(async () => {
|
|
472
519
|
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(", "));
|
|
473
522
|
}, "Failed to start MCP server");
|
|
474
523
|
}
|
|
475
524
|
}
|
|
476
|
-
//
|
|
525
|
+
// Enhanced error handling with debug info
|
|
526
|
+
console.error("🔍 [DEBUG] Setting up error handlers...");
|
|
477
527
|
process.on("uncaughtException", (error) => {
|
|
528
|
+
console.error(`🔍 [DEBUG] Uncaught exception at ${new Date().toISOString()}`);
|
|
478
529
|
console.error("❌ Uncaught exception:", error);
|
|
530
|
+
console.error(`🔍 [DEBUG] Stack trace:`, error.stack);
|
|
479
531
|
process.exit(1);
|
|
480
532
|
});
|
|
481
|
-
process.on("unhandledRejection", (reason) => {
|
|
533
|
+
process.on("unhandledRejection", (reason, promise) => {
|
|
534
|
+
console.error(`🔍 [DEBUG] Unhandled rejection at ${new Date().toISOString()}`);
|
|
482
535
|
console.error("❌ Unhandled rejection:", reason);
|
|
536
|
+
console.error(`🔍 [DEBUG] Promise:`, promise);
|
|
483
537
|
process.exit(1);
|
|
484
538
|
});
|
|
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");
|
|
485
553
|
// 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
|
|
486
559
|
const isMain = import.meta.url === `file://${process.argv[1]}` ||
|
|
487
560
|
process.argv[1].includes("brave-real-browser-mcp-server") ||
|
|
488
561
|
process.argv[1].endsWith(".bin/brave-real-browser-mcp-server") ||
|
|
489
562
|
process.argv.some((arg) => arg.includes("brave-real-browser-mcp-server"));
|
|
563
|
+
console.error(`🔍 [DEBUG] Enhanced main detection result: ${isMain}`);
|
|
490
564
|
if (isMain) {
|
|
565
|
+
console.error("🔍 [DEBUG] Module is main - starting server...");
|
|
491
566
|
main().catch((error) => {
|
|
567
|
+
console.error(`🔍 [DEBUG] Main function failed at ${new Date().toISOString()}`);
|
|
492
568
|
console.error("❌ Failed to start server:", error);
|
|
569
|
+
console.error(`🔍 [DEBUG] Error stack:`, error.stack);
|
|
493
570
|
process.exit(1);
|
|
494
571
|
});
|
|
495
572
|
}
|
|
496
573
|
else {
|
|
574
|
+
console.error("🔍 [DEBUG] Module is not main - not starting server");
|
|
575
|
+
console.error("🔍 [DEBUG] FORCE STARTING - This is likely an npx execution");
|
|
497
576
|
main().catch((error) => {
|
|
577
|
+
console.error(`🔍 [DEBUG] Forced main function failed at ${new Date().toISOString()}`);
|
|
498
578
|
console.error("❌ Failed to start server:", error);
|
|
579
|
+
console.error(`🔍 [DEBUG] Error stack:`, error.stack);
|
|
499
580
|
process.exit(1);
|
|
500
581
|
});
|
|
501
582
|
}
|
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.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",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"ajv": "^8.12.0",
|
|
45
45
|
"axios": "^1.6.5",
|
|
46
46
|
"brave-real-browser": "^1.5.105",
|
|
47
|
-
"brave-real-launcher": "^1.2.
|
|
48
|
-
"brave-real-puppeteer-core": "^24.
|
|
47
|
+
"brave-real-launcher": "^1.2.19",
|
|
48
|
+
"brave-real-puppeteer-core": "^24.26.1",
|
|
49
49
|
"cheerio": "^1.0.0-rc.12",
|
|
50
50
|
"chrono-node": "^2.7.0",
|
|
51
51
|
"compromise": "^14.13.0",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@types/xml2js": "^0.4.14",
|
|
74
74
|
"@vitest/coverage-v8": "^3.2.4",
|
|
75
75
|
"@vitest/ui": "^3.2.4",
|
|
76
|
-
"rimraf": "^6.1
|
|
76
|
+
"rimraf": "^6.0.1",
|
|
77
77
|
"tsx": "latest",
|
|
78
78
|
"typescript": "^5.5.3",
|
|
79
79
|
"vitest": "^3.2.4"
|