brave-real-browser-mcp-server 2.36.0 → 2.38.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 CHANGED
@@ -14,7 +14,8 @@ A production-ready MCP (Model Context Protocol) server that combines Puppeteer w
14
14
 
15
15
  | Feature | Description |
16
16
  |---------|-------------|
17
- | MCP Server | Model Context Protocol compatible server |
17
+ | **MCP Server** | Model Context Protocol compatible server with 28 tools |
18
+ | **LSP Server** | Language Server Protocol for IDE code intelligence |
18
19
  | Brave Browser | Uses Brave instead of Chromium for better privacy |
19
20
  | 50+ Stealth Features | Passes all major bot detectors |
20
21
  | Built-in Ad Blocker | uBlock Origin filters with auto-update |
@@ -25,6 +26,7 @@ A production-ready MCP (Model Context Protocol) server that combines Puppeteer w
25
26
  | Auto-Install | Brave auto-installs if missing |
26
27
  | TypeScript Support | Full type definitions included |
27
28
  | ESM + CJS | Dual module support |
29
+ | **Multi-language** | English & Hindi language support |
28
30
  | **Auto-Update** | Daily automatic dependency updates |
29
31
  | **Auto-Publish** | Automatic NPM publishing on updates |
30
32
  | **Monorepo** | npm workspaces with linked packages |
@@ -127,6 +129,113 @@ AI: [Calls file_downloader with url="..."] -> Downloaded to ./downloads/image.pn
127
129
 
128
130
  ---
129
131
 
132
+ ## LSP Server (Language Server Protocol)
133
+
134
+ This package also includes a full-featured **LSP Server** for IDE code intelligence when writing browser automation scripts.
135
+
136
+ ### Quick Start LSP Server
137
+
138
+ ```bash
139
+ # Start the LSP server
140
+ npm run lsp
141
+ ```
142
+
143
+ ### LSP Capabilities
144
+
145
+ | Feature | Description |
146
+ |---------|-------------|
147
+ | **Autocomplete** | Tool names, parameters, and enum values |
148
+ | **Hover** | Full documentation on hover |
149
+ | **Diagnostics** | Error & warning detection (missing browser_init, etc.) |
150
+ | **Snippets** | Code templates for common workflows |
151
+ | **Refactoring** | Quick fixes (add browser_init, try-catch, etc.) |
152
+ | **Simulation** | Workflow simulation in IDE |
153
+ | **Multi-language** | English & Hindi support |
154
+
155
+ ### VS Code Setup
156
+
157
+ Create `.vscode/settings.json` in your project:
158
+
159
+ ```json
160
+ {
161
+ "braveRealBrowser.language": "en",
162
+ "braveRealBrowser.maxDiagnostics": 100,
163
+ "braveRealBrowser.enableSnippets": true,
164
+ "braveRealBrowser.enableSimulation": true,
165
+ "braveRealBrowser.enableRefactoring": true
166
+ }
167
+ ```
168
+
169
+ ### Diagnostic Features
170
+
171
+ The LSP detects common issues:
172
+
173
+ - Missing `browser_init()` before page operations
174
+ - Missing `navigate()` before content extraction
175
+ - Invalid selectors and URLs
176
+ - Missing required parameters
177
+ - Unclosed browser sessions
178
+ - Security issues (eval usage, etc.)
179
+
180
+ ### Quick Fixes
181
+
182
+ When diagnostics are detected, quick fixes are offered:
183
+
184
+ - Add `browser_init()` at start
185
+ - Add `navigate()` before page tools
186
+ - Add `browser_close()` at end
187
+ - Wrap in try-catch
188
+ - Extract to function
189
+
190
+ ---
191
+
192
+ ## Unified Architecture
193
+
194
+ Both MCP and LSP servers share the same tool definitions:
195
+
196
+ ```
197
+ src/
198
+ ├── shared/
199
+ │ └── tools.js # Single source of truth (28 tools)
200
+ ├── mcp/
201
+ │ ├── server.js # MCP server for AI agents
202
+ │ └── handlers.js # Tool implementations
203
+ ├── lsp/
204
+ │ ├── server.js # LSP server for IDEs
205
+ │ └── capabilities/ # Autocomplete, hover, diagnostics, etc.
206
+ └── index.js # Unified entry point
207
+ ```
208
+
209
+ ### Unified CLI
210
+
211
+ ```bash
212
+ # List all tools
213
+ node src/index.js --list
214
+
215
+ # Start MCP server (default)
216
+ node src/index.js mcp
217
+
218
+ # Start LSP server
219
+ node src/index.js lsp
220
+
221
+ # Show help
222
+ node src/index.js --help
223
+ ```
224
+
225
+ ### Tool Categories
226
+
227
+ | Category | Tools | Description |
228
+ |----------|-------|-------------|
229
+ | **Browser** | 3 | Browser lifecycle (init, close, cookies) |
230
+ | **Navigation** | 1 | Page navigation |
231
+ | **Interaction** | 8 | User actions (click, type, scroll, etc.) |
232
+ | **Extraction** | 10 | Content scraping (HTML, JSON, links, etc.) |
233
+ | **Network** | 3 | Network operations (recorder, download, trace) |
234
+ | **Analysis** | 1 | Page analysis (SEO, performance, etc.) |
235
+ | **Utility** | 2 | Helpers (wait, progress tracker) |
236
+
237
+ ---
238
+
130
239
  ## Monorepo Ecosystem
131
240
 
132
241
  ```
@@ -398,9 +507,12 @@ console.log(blocker === sameBlocker); // true
398
507
 
399
508
  | Command | Description |
400
509
  |---------|-------------|
510
+ | `npm start` | Start unified server (MCP by default) |
401
511
  | `npm run dev` | Start MCP server |
402
512
  | `npm run mcp` | Start MCP server (alias) |
403
513
  | `npm run mcp:verbose` | Start MCP server with tool details |
514
+ | `npm run lsp` | Start LSP server for IDE intelligence |
515
+ | `npm run list` | List all 28 tools with categories |
404
516
  | `npm install` | Install all dependencies with workspace linking |
405
517
  | `npm test` | Run all tests (CJS + ESM) |
406
518
  | `npm run cjs_test` | Run CommonJS tests only |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brave-real-browser-mcp-server",
3
- "version": "2.36.0",
3
+ "version": "2.38.0",
4
4
  "description": "MCP Server for Brave Real Browser - Puppeteer with Brave Browser, Stealth Mode, Ad Blocker, and Turnstile Auto-Solver for undetectable web automation.",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/esm/index.mjs",
@@ -28,10 +28,11 @@
28
28
  },
29
29
  "scripts": {
30
30
  "start": "node src/index.js",
31
- "dev": "node src/index.js mcp",
31
+ "dev": "node src/index.js",
32
32
  "mcp": "node src/index.js mcp",
33
33
  "mcp:verbose": "node src/index.js mcp --verbose",
34
34
  "lsp": "node src/index.js lsp",
35
+ "lsp:tcp": "node src/lsp/server.js --tcp",
35
36
  "list": "node src/index.js --list",
36
37
  "build": "echo 'Root package uses pre-built lib/ - no build needed'",
37
38
  "build:self": "echo 'Root package uses pre-built lib/ - no build needed'",
@@ -70,7 +71,7 @@
70
71
  "license": "ISC",
71
72
  "dependencies": {
72
73
  "@modelcontextprotocol/sdk": "^1.25.3",
73
- "brave-real-puppeteer-core": "^24.51.0",
74
+ "brave-real-puppeteer-core": "^24.53.0",
74
75
  "ghost-cursor": "^1.4.2",
75
76
  "puppeteer-extra": "^3.3.6",
76
77
  "puppeteer-extra-plugin-stealth": "^2.11.2",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brave-real-blocker",
3
- "version": "1.12.0",
3
+ "version": "1.14.0",
4
4
  "description": "Advanced uBlock Origin management and stealth features for Brave Real Browser",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -63,7 +63,7 @@
63
63
  "@types/adm-zip": "^0.5.5",
64
64
  "@types/fs-extra": "^11.0.4",
65
65
  "@types/node": "^20.0.0",
66
- "brave-real-puppeteer-core": "^24.51.0",
66
+ "brave-real-puppeteer-core": "^24.53.0",
67
67
  "mocha": "^10.4.0",
68
68
  "puppeteer-core": "^24.35.0",
69
69
  "sinon": "^17.0.1",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brave-real-launcher",
3
- "version": "1.18.0",
3
+ "version": "1.20.0",
4
4
  "description": "Launch Brave Browser with ease from node. Based on chrome-launcher with Brave-specific support.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -54,7 +54,7 @@
54
54
  "typescript": "^5.0.0"
55
55
  },
56
56
  "dependencies": {
57
- "brave-real-blocker": "^1.12.0",
57
+ "brave-real-blocker": "^1.14.0",
58
58
  "escape-string-regexp": "^4.0.0",
59
59
  "is-wsl": "^2.2.0",
60
60
  "which": "^4.0.0"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brave-real-puppeteer-core",
3
- "version": "24.51.0",
3
+ "version": "24.53.0",
4
4
  "description": "🦁 Brave Real-World Optimized Puppeteer & Playwright Core with 1-5ms ultra-fast timing, 50+ professional stealth features, intelligent browser auto-detection, and 100% bot detection bypass. Features cross-platform Brave browser integration, comprehensive anti-detection, and breakthrough performance improvements.",
5
5
  "keywords": [
6
6
  "automation",
@@ -132,7 +132,7 @@
132
132
  "test-version": "node ./scripts/test-version-management.js"
133
133
  },
134
134
  "dependencies": {
135
- "brave-real-launcher": "^1.18.0",
135
+ "brave-real-launcher": "^1.20.0",
136
136
  "get-east-asian-width": "^1.4.0",
137
137
  "yargs": "^18.0.0"
138
138
  },
@@ -0,0 +1,274 @@
1
+ /**
2
+ * AI Action Parser - Parse natural language commands into actions
3
+ *
4
+ * Converts commands like:
5
+ * - "click the login button" -> { type: 'click', target: 'login button' }
6
+ * - "type hello in the search box" -> { type: 'type', target: 'search box', text: 'hello' }
7
+ * - "scroll down" -> { type: 'scroll', direction: 'down' }
8
+ */
9
+
10
+ class ActionParser {
11
+ constructor() {
12
+ // Action patterns
13
+ this.actionPatterns = [
14
+ // Click patterns
15
+ {
16
+ pattern: /^(click|tap|press|hit|select)\s+(?:on\s+)?(?:the\s+)?(.+)/i,
17
+ type: 'click',
18
+ extract: (match) => ({ target: match[2].trim() })
19
+ },
20
+ // Type patterns
21
+ {
22
+ pattern: /^(type|enter|write|input)\s+["']?([^"']+)["']?\s+(?:in|into|in the|into the)\s+(.+)/i,
23
+ type: 'type',
24
+ extract: (match) => ({ text: match[2].trim(), target: match[3].trim() })
25
+ },
26
+ {
27
+ pattern: /^(type|enter|write|input)\s+(.+)\s+(?:in|into)\s+["']?([^"']+)["']?/i,
28
+ type: 'type',
29
+ extract: (match) => ({ target: match[2].trim(), text: match[3].trim() })
30
+ },
31
+ {
32
+ pattern: /^(fill|fill in|complete)\s+(?:the\s+)?(.+)\s+(?:with|as)\s+["']?([^"']+)["']?/i,
33
+ type: 'type',
34
+ extract: (match) => ({ target: match[2].trim(), text: match[3].trim() })
35
+ },
36
+ // Navigate patterns
37
+ {
38
+ pattern: /^(go to|navigate to|open|visit)\s+(.+)/i,
39
+ type: 'navigate',
40
+ extract: (match) => {
41
+ let url = match[2].trim();
42
+ if (!url.startsWith('http')) {
43
+ url = 'https://' + url;
44
+ }
45
+ return { url };
46
+ }
47
+ },
48
+ // Scroll patterns
49
+ {
50
+ pattern: /^scroll\s+(up|down|left|right)(?:\s+(\d+)\s*(?:px|pixels)?)?/i,
51
+ type: 'scroll',
52
+ extract: (match) => ({
53
+ direction: match[1].toLowerCase(),
54
+ amount: parseInt(match[2]) || 300
55
+ })
56
+ },
57
+ {
58
+ pattern: /^scroll\s+to\s+(?:the\s+)?(top|bottom|footer|header)/i,
59
+ type: 'scroll',
60
+ extract: (match) => {
61
+ const target = match[1].toLowerCase();
62
+ return {
63
+ direction: target === 'top' || target === 'header' ? 'up' : 'down',
64
+ amount: 10000,
65
+ scrollTo: target
66
+ };
67
+ }
68
+ },
69
+ // Wait patterns
70
+ {
71
+ pattern: /^wait\s+(?:for\s+)?(\d+)\s*(?:ms|milliseconds?|s|seconds?)?/i,
72
+ type: 'wait',
73
+ extract: (match) => {
74
+ let duration = parseInt(match[1]);
75
+ const unit = match[0].toLowerCase();
76
+ if (unit.includes('s') && !unit.includes('ms')) {
77
+ duration *= 1000;
78
+ }
79
+ return { duration };
80
+ }
81
+ },
82
+ {
83
+ pattern: /^wait\s+(?:for\s+)?(?:the\s+)?(.+?)(?:\s+to\s+(?:appear|load|show))?$/i,
84
+ type: 'waitFor',
85
+ extract: (match) => ({ target: match[1].trim() })
86
+ },
87
+ // Find/Search patterns
88
+ {
89
+ pattern: /^(find|search|look for|locate)\s+(?:the\s+)?(.+)/i,
90
+ type: 'find',
91
+ extract: (match) => ({ query: match[2].trim() })
92
+ },
93
+ // Hover patterns
94
+ {
95
+ pattern: /^(hover|mouse over|move to)\s+(?:the\s+)?(.+)/i,
96
+ type: 'hover',
97
+ extract: (match) => ({ target: match[2].trim() })
98
+ },
99
+ // Clear patterns
100
+ {
101
+ pattern: /^(clear|empty|delete)\s+(?:the\s+)?(.+)/i,
102
+ type: 'clear',
103
+ extract: (match) => ({ target: match[2].trim() })
104
+ },
105
+ // Submit patterns
106
+ {
107
+ pattern: /^submit\s+(?:the\s+)?(?:form)?(.*)$/i,
108
+ type: 'submit',
109
+ extract: (match) => ({ target: match[1].trim() || 'form' })
110
+ },
111
+ // Screenshot patterns
112
+ {
113
+ pattern: /^(take|capture)\s+(?:a\s+)?screenshot/i,
114
+ type: 'screenshot',
115
+ extract: () => ({})
116
+ },
117
+ // Go back/forward patterns
118
+ {
119
+ pattern: /^go\s+(back|forward)/i,
120
+ type: 'navigation',
121
+ extract: (match) => ({ direction: match[1].toLowerCase() })
122
+ },
123
+ // Refresh patterns
124
+ {
125
+ pattern: /^(refresh|reload)\s*(?:the\s+)?(?:page)?/i,
126
+ type: 'refresh',
127
+ extract: () => ({})
128
+ }
129
+ ];
130
+
131
+ // Context variable patterns (for substitution)
132
+ this.variablePattern = /\{(\w+)\}/g;
133
+ }
134
+
135
+ /**
136
+ * Parse a natural language command
137
+ */
138
+ async parse(command, context = {}) {
139
+ // Substitute context variables
140
+ let processedCommand = command.replace(this.variablePattern, (match, varName) => {
141
+ return context[varName] !== undefined ? context[varName] : match;
142
+ });
143
+
144
+ // Trim and normalize
145
+ processedCommand = processedCommand.trim();
146
+
147
+ // Try each pattern
148
+ for (const pattern of this.actionPatterns) {
149
+ const match = processedCommand.match(pattern.pattern);
150
+ if (match) {
151
+ const extracted = pattern.extract(match);
152
+ return {
153
+ type: pattern.type,
154
+ ...extracted,
155
+ originalCommand: command,
156
+ confidence: 0.9
157
+ };
158
+ }
159
+ }
160
+
161
+ // Fallback: Try to guess action from keywords
162
+ const fallback = this.guessFallback(processedCommand);
163
+ if (fallback) {
164
+ return {
165
+ ...fallback,
166
+ originalCommand: command,
167
+ confidence: 0.5
168
+ };
169
+ }
170
+
171
+ // Could not parse
172
+ return {
173
+ type: 'unknown',
174
+ originalCommand: command,
175
+ confidence: 0,
176
+ error: 'Could not understand command'
177
+ };
178
+ }
179
+
180
+ /**
181
+ * Try to guess action from keywords
182
+ */
183
+ guessFallback(command) {
184
+ const lower = command.toLowerCase();
185
+
186
+ // Check for action keywords
187
+ if (lower.includes('button') || lower.includes('link') || lower.includes('click')) {
188
+ return { type: 'click', target: command };
189
+ }
190
+
191
+ if (lower.includes('type') || lower.includes('enter') || lower.includes('input')) {
192
+ return { type: 'find', query: command, suggestedAction: 'type' };
193
+ }
194
+
195
+ if (lower.includes('search') || lower.includes('find') || lower.includes('look')) {
196
+ return { type: 'find', query: command };
197
+ }
198
+
199
+ if (lower.includes('scroll')) {
200
+ return { type: 'scroll', direction: 'down', amount: 300 };
201
+ }
202
+
203
+ // Default to find
204
+ return { type: 'find', query: command };
205
+ }
206
+
207
+ /**
208
+ * Parse multiple commands (separated by 'then', 'and', or newlines)
209
+ */
210
+ async parseMultiple(commands, context = {}) {
211
+ // Split by separators
212
+ const parts = commands.split(/\s+(?:then|and)\s+|\n|;/i).filter(p => p.trim());
213
+
214
+ const results = [];
215
+ for (const part of parts) {
216
+ const parsed = await this.parse(part.trim(), context);
217
+ results.push(parsed);
218
+ }
219
+
220
+ return results;
221
+ }
222
+
223
+ /**
224
+ * Get suggestions for incomplete commands
225
+ */
226
+ getSuggestions(partialCommand) {
227
+ const lower = partialCommand.toLowerCase();
228
+ const suggestions = [];
229
+
230
+ if (lower.startsWith('click')) {
231
+ suggestions.push(
232
+ 'click the login button',
233
+ 'click the submit button',
234
+ 'click the link',
235
+ 'click the menu'
236
+ );
237
+ } else if (lower.startsWith('type')) {
238
+ suggestions.push(
239
+ 'type "text" in the search box',
240
+ 'type "username" in the login field',
241
+ 'type "hello" in the input'
242
+ );
243
+ } else if (lower.startsWith('go')) {
244
+ suggestions.push(
245
+ 'go to google.com',
246
+ 'go back',
247
+ 'go forward'
248
+ );
249
+ } else if (lower.startsWith('scroll')) {
250
+ suggestions.push(
251
+ 'scroll down',
252
+ 'scroll up',
253
+ 'scroll to the bottom',
254
+ 'scroll to the top'
255
+ );
256
+ } else if (lower.startsWith('wait')) {
257
+ suggestions.push(
258
+ 'wait 2 seconds',
259
+ 'wait for the button to appear',
260
+ 'wait 500ms'
261
+ );
262
+ } else if (lower.startsWith('find')) {
263
+ suggestions.push(
264
+ 'find the login button',
265
+ 'find the search input',
266
+ 'find all links'
267
+ );
268
+ }
269
+
270
+ return suggestions;
271
+ }
272
+ }
273
+
274
+ module.exports = ActionParser;