brave-real-browser-mcp-server 2.11.7 → 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/README.md +461 -1240
- package/dist/index.js +134 -124
- package/dist/launcher.js +106 -34
- package/dist/universal-ide-adapter.js +855 -0
- package/package.json +26 -4
package/dist/launcher.js
CHANGED
|
@@ -1,41 +1,72 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { StdioServerTransport } from
|
|
3
|
-
import { HttpTransport } from
|
|
4
|
-
import { LspTransport } from
|
|
5
|
-
import { closeBrowser, forceKillAllBraveProcesses } from
|
|
6
|
-
import { setupProcessCleanup } from
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { HttpTransport } from "./transports/http-transport.js";
|
|
4
|
+
import { LspTransport } from "./transports/lsp-transport.js";
|
|
5
|
+
import { closeBrowser, forceKillAllBraveProcesses } from "./browser-manager.js";
|
|
6
|
+
import { setupProcessCleanup } from "./core-infrastructure.js";
|
|
7
|
+
import { UniversalIDEAdapter, ProtocolType, } from "./universal-ide-adapter.js";
|
|
7
8
|
export class MultiProtocolLauncher {
|
|
8
9
|
config;
|
|
9
10
|
httpTransport;
|
|
10
11
|
lspTransport;
|
|
11
12
|
mcpServer;
|
|
13
|
+
universalAdapter;
|
|
12
14
|
constructor(config = {}) {
|
|
13
15
|
this.config = {
|
|
14
|
-
mode: config.mode ||
|
|
16
|
+
mode: config.mode || "auto",
|
|
15
17
|
httpPort: config.httpPort || 3000,
|
|
16
|
-
httpHost: config.httpHost ||
|
|
18
|
+
httpHost: config.httpHost || "0.0.0.0",
|
|
17
19
|
enableWebSocket: config.enableWebSocket !== false,
|
|
18
20
|
enableCors: config.enableCors !== false,
|
|
21
|
+
enableAutoDetection: config.enableAutoDetection !== false,
|
|
19
22
|
};
|
|
20
23
|
}
|
|
21
24
|
async start() {
|
|
22
|
-
console.error(
|
|
25
|
+
console.error("🚀 Multi-Protocol Brave Browser Server Starting...");
|
|
23
26
|
console.error(`📡 Mode: ${this.config.mode.toUpperCase()}`);
|
|
27
|
+
// Initialize Universal IDE Adapter if auto-detection is enabled
|
|
28
|
+
if (this.config.enableAutoDetection && this.config.mode === "auto") {
|
|
29
|
+
console.error("🔍 Initializing Universal IDE Adapter...");
|
|
30
|
+
this.universalAdapter = new UniversalIDEAdapter({
|
|
31
|
+
enableAutoDetection: true,
|
|
32
|
+
fallbackToHttp: true,
|
|
33
|
+
httpPort: this.config.httpPort,
|
|
34
|
+
logDetectionDetails: true,
|
|
35
|
+
});
|
|
36
|
+
const detectionResult = await this.universalAdapter.initialize();
|
|
37
|
+
// Override mode based on detection
|
|
38
|
+
if (detectionResult.protocol === ProtocolType.MCP ||
|
|
39
|
+
detectionResult.protocol === ProtocolType.STDIO) {
|
|
40
|
+
this.config.mode = "mcp";
|
|
41
|
+
}
|
|
42
|
+
else if (detectionResult.protocol === ProtocolType.LSP) {
|
|
43
|
+
this.config.mode = "lsp";
|
|
44
|
+
}
|
|
45
|
+
else if (detectionResult.protocol === ProtocolType.HTTP ||
|
|
46
|
+
detectionResult.protocol === ProtocolType.WEBSOCKET) {
|
|
47
|
+
this.config.mode = "http";
|
|
48
|
+
}
|
|
49
|
+
console.error(`✅ Auto-detected mode: ${this.config.mode.toUpperCase()}`);
|
|
50
|
+
}
|
|
24
51
|
// Setup cleanup handlers
|
|
25
52
|
setupProcessCleanup(async () => {
|
|
26
53
|
await this.stop();
|
|
27
54
|
});
|
|
28
55
|
switch (this.config.mode) {
|
|
29
|
-
case
|
|
56
|
+
case "auto":
|
|
57
|
+
// Fallback to MCP if auto-detection didn't override
|
|
30
58
|
await this.startMcp();
|
|
31
59
|
break;
|
|
32
|
-
case
|
|
60
|
+
case "mcp":
|
|
61
|
+
await this.startMcp();
|
|
62
|
+
break;
|
|
63
|
+
case "http":
|
|
33
64
|
await this.startHttp();
|
|
34
65
|
break;
|
|
35
|
-
case
|
|
66
|
+
case "lsp":
|
|
36
67
|
await this.startLsp();
|
|
37
68
|
break;
|
|
38
|
-
case
|
|
69
|
+
case "all":
|
|
39
70
|
await this.startAll();
|
|
40
71
|
break;
|
|
41
72
|
default:
|
|
@@ -43,30 +74,45 @@ export class MultiProtocolLauncher {
|
|
|
43
74
|
}
|
|
44
75
|
}
|
|
45
76
|
async startMcp() {
|
|
46
|
-
console.error(
|
|
77
|
+
console.error("🔵 [MCP] Starting MCP server with STDIO transport...");
|
|
78
|
+
if (this.universalAdapter?.getDetectionResult()) {
|
|
79
|
+
const result = this.universalAdapter.getDetectionResult();
|
|
80
|
+
console.error(`🎯 [MCP] Optimized for: ${result.capabilities.name}`);
|
|
81
|
+
}
|
|
47
82
|
// Import MCP server setup from index.ts
|
|
48
|
-
const { createMcpServer } = await import(
|
|
83
|
+
const { createMcpServer } = await import("./mcp-server.js");
|
|
49
84
|
this.mcpServer = await createMcpServer();
|
|
50
85
|
const transport = new StdioServerTransport();
|
|
51
86
|
await this.mcpServer.connect(transport);
|
|
52
|
-
console.error(
|
|
87
|
+
console.error("✅ [MCP] Server started successfully");
|
|
88
|
+
console.error("💡 [MCP] Compatible with: Claude Desktop, Cursor, Windsurf, Cline, Warp, Roo Coder");
|
|
53
89
|
}
|
|
54
90
|
async startHttp() {
|
|
55
|
-
console.error(
|
|
91
|
+
console.error("🟢 [HTTP] Starting HTTP/WebSocket server...");
|
|
92
|
+
if (this.universalAdapter?.getDetectionResult()) {
|
|
93
|
+
const result = this.universalAdapter.getDetectionResult();
|
|
94
|
+
console.error(`🎯 [HTTP] Optimized for: ${result.capabilities.name}`);
|
|
95
|
+
}
|
|
56
96
|
this.httpTransport = new HttpTransport({
|
|
57
97
|
port: this.config.httpPort,
|
|
58
98
|
host: this.config.httpHost,
|
|
59
99
|
enableWebSocket: this.config.enableWebSocket,
|
|
60
100
|
});
|
|
61
101
|
await this.httpTransport.start();
|
|
102
|
+
console.error("💡 [HTTP] Universal mode - works with ALL AI IDEs");
|
|
62
103
|
}
|
|
63
104
|
async startLsp() {
|
|
64
|
-
console.error(
|
|
105
|
+
console.error("🟣 [LSP] Starting Language Server Protocol...");
|
|
106
|
+
if (this.universalAdapter?.getDetectionResult()) {
|
|
107
|
+
const result = this.universalAdapter.getDetectionResult();
|
|
108
|
+
console.error(`🎯 [LSP] Optimized for: ${result.capabilities.name}`);
|
|
109
|
+
}
|
|
65
110
|
this.lspTransport = new LspTransport();
|
|
66
111
|
await this.lspTransport.start();
|
|
112
|
+
console.error("💡 [LSP] Compatible with: Zed Editor, VSCode, Neovim, Emacs, Sublime Text");
|
|
67
113
|
}
|
|
68
114
|
async startAll() {
|
|
69
|
-
console.error(
|
|
115
|
+
console.error("🌈 Starting all protocols...");
|
|
70
116
|
// Start HTTP in background
|
|
71
117
|
if (!this.httpTransport) {
|
|
72
118
|
this.httpTransport = new HttpTransport({
|
|
@@ -79,10 +125,10 @@ export class MultiProtocolLauncher {
|
|
|
79
125
|
// Note: LSP and MCP use stdio/IPC, so they can't run simultaneously
|
|
80
126
|
// In 'all' mode, we prioritize HTTP/WebSocket for universal access
|
|
81
127
|
console.error('⚠️ [Note] MCP and LSP use stdio, so only HTTP/WebSocket is active in "all" mode');
|
|
82
|
-
console.error(
|
|
128
|
+
console.error("💡 Use separate instances for MCP or LSP: --mode=mcp or --mode=lsp");
|
|
83
129
|
}
|
|
84
130
|
async stop() {
|
|
85
|
-
console.error(
|
|
131
|
+
console.error("🛑 Stopping servers...");
|
|
86
132
|
await closeBrowser();
|
|
87
133
|
await forceKillAllBraveProcesses();
|
|
88
134
|
if (this.httpTransport) {
|
|
@@ -91,7 +137,7 @@ export class MultiProtocolLauncher {
|
|
|
91
137
|
if (this.lspTransport) {
|
|
92
138
|
await this.lspTransport.stop();
|
|
93
139
|
}
|
|
94
|
-
console.error(
|
|
140
|
+
console.error("✅ All servers stopped");
|
|
95
141
|
}
|
|
96
142
|
}
|
|
97
143
|
// Parse CLI arguments
|
|
@@ -100,50 +146,76 @@ export function parseArgs() {
|
|
|
100
146
|
const config = {};
|
|
101
147
|
for (let i = 0; i < args.length; i++) {
|
|
102
148
|
const arg = args[i];
|
|
103
|
-
if (arg ===
|
|
149
|
+
if (arg === "--mode" || arg === "-m") {
|
|
104
150
|
const mode = args[++i];
|
|
105
|
-
if ([
|
|
151
|
+
if (["auto", "mcp", "http", "lsp", "all"].includes(mode)) {
|
|
106
152
|
config.mode = mode;
|
|
107
153
|
}
|
|
108
154
|
else {
|
|
109
|
-
console.error(`❌ Invalid mode: ${mode}. Use: mcp, http, lsp, or all`);
|
|
155
|
+
console.error(`❌ Invalid mode: ${mode}. Use: auto, mcp, http, lsp, or all`);
|
|
110
156
|
process.exit(1);
|
|
111
157
|
}
|
|
112
158
|
}
|
|
113
|
-
else if (arg ===
|
|
159
|
+
else if (arg === "--port" || arg === "-p") {
|
|
114
160
|
config.httpPort = parseInt(args[++i]);
|
|
115
161
|
}
|
|
116
|
-
else if (arg ===
|
|
162
|
+
else if (arg === "--host" || arg === "-h") {
|
|
117
163
|
config.httpHost = args[++i];
|
|
118
164
|
}
|
|
119
|
-
else if (arg ===
|
|
165
|
+
else if (arg === "--no-websocket") {
|
|
120
166
|
config.enableWebSocket = false;
|
|
121
167
|
}
|
|
122
|
-
else if (arg ===
|
|
168
|
+
else if (arg === "--no-auto-detect") {
|
|
169
|
+
config.enableAutoDetection = false;
|
|
170
|
+
}
|
|
171
|
+
else if (arg === "--list-ides") {
|
|
172
|
+
UniversalIDEAdapter.printSupportedIDEs();
|
|
173
|
+
process.exit(0);
|
|
174
|
+
}
|
|
175
|
+
else if (arg === "--help") {
|
|
123
176
|
console.log(`
|
|
124
|
-
Brave Real Browser MCP Server -
|
|
177
|
+
Brave Real Browser MCP Server - Universal AI IDE Support
|
|
125
178
|
|
|
126
179
|
Usage: brave-real-browser-mcp-server [options]
|
|
127
180
|
|
|
128
181
|
Options:
|
|
129
|
-
--mode, -m <mode> Protocol mode: mcp, http, lsp, or all (default:
|
|
182
|
+
--mode, -m <mode> Protocol mode: auto, mcp, http, lsp, or all (default: auto)
|
|
130
183
|
--port, -p <port> HTTP server port (default: 3000)
|
|
131
184
|
--host, -h <host> HTTP server host (default: 0.0.0.0)
|
|
132
185
|
--no-websocket Disable WebSocket support in HTTP mode
|
|
186
|
+
--no-auto-detect Disable automatic IDE detection
|
|
187
|
+
--list-ides Show list of all supported AI IDEs
|
|
133
188
|
--help Show this help message
|
|
134
189
|
|
|
190
|
+
Supported AI IDEs (with auto-detection):
|
|
191
|
+
✓ Claude Desktop ✓ Cursor AI ✓ Windsurf
|
|
192
|
+
✓ Cline (VSCode) ✓ Roo Coder ✓ Zed Editor
|
|
193
|
+
✓ Continue.dev ✓ Qoder AI ✓ Warp Terminal
|
|
194
|
+
✓ GitHub Copilot ✓ Amazon CodeWhisperer ✓ Tabnine
|
|
195
|
+
✓ Cody (Sourcegraph) ✓ Aider ✓ Pieces for Developers
|
|
196
|
+
✓ VSCode (Generic) ✓ Any LSP-compatible editor
|
|
197
|
+
|
|
135
198
|
Examples:
|
|
136
|
-
#
|
|
199
|
+
# Auto mode (automatically detects your IDE and uses optimal protocol)
|
|
200
|
+
brave-real-browser-mcp-server --mode auto
|
|
201
|
+
|
|
202
|
+
# Or simply run without arguments (auto is default)
|
|
203
|
+
brave-real-browser-mcp-server
|
|
204
|
+
|
|
205
|
+
# MCP mode (for Claude Desktop, Cursor, Windsurf, Cline, Warp, Roo Coder)
|
|
137
206
|
brave-real-browser-mcp-server --mode mcp
|
|
138
207
|
|
|
139
|
-
# HTTP/WebSocket mode (
|
|
208
|
+
# HTTP/WebSocket mode (universal - works with ALL IDEs)
|
|
140
209
|
brave-real-browser-mcp-server --mode http --port 3000
|
|
141
210
|
|
|
142
|
-
# LSP mode (for Zed, VSCode,
|
|
211
|
+
# LSP mode (for Zed, VSCode, Neovim, Emacs, Sublime Text)
|
|
143
212
|
brave-real-browser-mcp-server --mode lsp
|
|
144
213
|
|
|
145
214
|
# All protocols (HTTP only, MCP/LSP need separate instances)
|
|
146
215
|
brave-real-browser-mcp-server --mode all
|
|
216
|
+
|
|
217
|
+
# Show all supported IDEs
|
|
218
|
+
brave-real-browser-mcp-server --list-ides
|
|
147
219
|
`);
|
|
148
220
|
process.exit(0);
|
|
149
221
|
}
|
|
@@ -158,7 +230,7 @@ export async function main() {
|
|
|
158
230
|
await launcher.start();
|
|
159
231
|
}
|
|
160
232
|
catch (error) {
|
|
161
|
-
console.error(
|
|
233
|
+
console.error("❌ Failed to start server:", error);
|
|
162
234
|
process.exit(1);
|
|
163
235
|
}
|
|
164
236
|
}
|