mcpbrowser 0.3.1 โ 0.3.3
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 +215 -234
- package/package.json +18 -3
- package/src/mcp-browser.js +1 -1
- package/tests/core/html.test.js +1 -1
- package/tests/core/page.test.js +2 -1
- package/server.json +0 -20
package/README.md
CHANGED
|
@@ -1,63 +1,91 @@
|
|
|
1
|
-
#
|
|
1
|
+
# MCPBrowser (MCP Browser)
|
|
2
2
|
|
|
3
3
|
[](https://marketplace.visualstudio.com/items?itemName=cherchyk.mcpbrowser)
|
|
4
4
|
[](https://www.npmjs.com/package/mcpbrowser)
|
|
5
5
|
[](https://modelcontextprotocol.io/quickstart/user)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
|
-
**
|
|
8
|
+
**MCPBrowser is an MCP browser server that gives AI assistants the ability to browse web pages using a real Chrome or Edge browser.** This browser-based MCP server fetches any web page โ especially those protected by authentication, CAPTCHAs, anti-bot protection, or requiring JavaScript rendering. Uses your real Chrome/Edge browser for web automation so you can log in normally, then automatically extracts content. Works with corporate SSO, login forms, Cloudflare, and JavaScript-heavy sites (SPAs, dashboards).
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
This is an [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) server using [stdio transport](https://modelcontextprotocol.io/docs/concepts/transports#stdio). Your AI assistant uses this web browser MCP server when standard HTTP requests fail โ pages requiring authentication, CAPTCHA protection, or heavy JavaScript (SPAs). Once connected, the browser MCP server can navigate through websites, interact with elements, and send HTML back to the AI assistant. This gives your AI the ability to browse the web just like you do.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Example workflow for AI assistant to use MCPBrowser
|
|
13
13
|
|
|
14
|
-
**From VS Code Marketplace:**
|
|
15
|
-
```bash
|
|
16
|
-
code --install-extension cherchyk.mcpbrowser
|
|
17
14
|
```
|
|
18
|
-
|
|
15
|
+
1. fetch_webpage โ Load the login page
|
|
16
|
+
2. type_text โ Enter username
|
|
17
|
+
3. type_text โ Enter password
|
|
18
|
+
4. click_element โ Click "Sign In"
|
|
19
|
+
5. get_current_html โ Extract the content after login
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Contents
|
|
24
|
+
|
|
25
|
+
- [Requirements](#requirements)
|
|
26
|
+
- [Installation](#installation)
|
|
27
|
+
- [VS Code Extension](#option-1-vs-code-extension)
|
|
28
|
+
- [Claude Code](#option-2-claude-code)
|
|
29
|
+
- [Claude Desktop](#option-3-claude-desktop)
|
|
30
|
+
- [npm Package](#option-4-npm-package)
|
|
31
|
+
- [MCP Tools](#mcp-tools)
|
|
32
|
+
- [fetch_webpage](#fetch_webpage)
|
|
33
|
+
- [click_element](#click_element)
|
|
34
|
+
- [type_text](#type_text)
|
|
35
|
+
- [get_current_html](#get_current_html)
|
|
36
|
+
- [close_tab](#close_tab)
|
|
37
|
+
- [Configuration](#configuration-optional)
|
|
38
|
+
- [Troubleshooting](#troubleshooting)
|
|
39
|
+
- [Links](#links)
|
|
40
|
+
|
|
41
|
+
## Requirements
|
|
42
|
+
|
|
43
|
+
- Chrome or Edge browser
|
|
44
|
+
- Node.js 18+
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
| # | Platform | Difficulty |
|
|
49
|
+
|---|----------|------------|
|
|
50
|
+
| 1 | [VS Code Extension](#option-1-vs-code-extension) | One Click |
|
|
51
|
+
| 2 | [Claude Code](#option-2-claude-code) | One Command |
|
|
52
|
+
| 3 | [Claude Desktop](#option-3-claude-desktop) | Manual |
|
|
53
|
+
| 4 | [npm Package](#option-4-npm-package) | Manual |
|
|
19
54
|
|
|
20
|
-
|
|
21
|
-
|
|
55
|
+
### Option 1: VS Code Extension
|
|
56
|
+
|
|
57
|
+
Install from [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=cherchyk.mcpbrowser) or run:
|
|
22
58
|
```bash
|
|
23
|
-
code --install-extension mcpbrowser
|
|
59
|
+
code --install-extension cherchyk.mcpbrowser
|
|
24
60
|
```
|
|
25
61
|
|
|
26
|
-
The extension automatically
|
|
27
|
-
- Installs the MCPBrowser npm package globally
|
|
28
|
-
- Configures mcp.json for Claude Code & GitHub Copilot
|
|
29
|
-
- Complete one-click setup - no manual steps needed
|
|
62
|
+
The extension automatically installs and configures everything for GitHub Copilot.
|
|
30
63
|
|
|
31
|
-
|
|
64
|
+
### Option 2: Claude Code
|
|
32
65
|
|
|
33
|
-
|
|
34
|
-
|
|
66
|
+
```bash
|
|
67
|
+
claude mcp add mcpbrowser --scope user -- npx -y mcpbrowser@latest
|
|
68
|
+
```
|
|
35
69
|
|
|
36
|
-
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
"type": "stdio",
|
|
40
|
-
"command": "npx",
|
|
41
|
-
"args": ["-y", "mcpbrowser@latest"],
|
|
42
|
-
"description": "Web page fetching via browser for sites requiring authentication, anti-bot protection, or JavaScript rendering. Use when standard HTTP requests fail for: (1) auth-required pages (401/403, SSO, corporate intranets), (2) anti-bot verification (CAPTCHA, Cloudflare), (3) JavaScript-heavy sites (SPAs, dynamic content). Opens a browser where the user can authenticate, then automatically extracts content."
|
|
43
|
-
}
|
|
70
|
+
Verify it's working:
|
|
71
|
+
```bash
|
|
72
|
+
claude mcp list
|
|
44
73
|
```
|
|
45
74
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
-
|
|
75
|
+
You should see:
|
|
76
|
+
```
|
|
77
|
+
mcpbrowser: npx -y mcpbrowser@latest - โ Connected
|
|
78
|
+
```
|
|
49
79
|
|
|
50
|
-
|
|
51
|
-
|
|
80
|
+
That's it! Ask Claude to fetch any protected page:
|
|
81
|
+
> "Fetch https://portal.azure.com using mcpbrowser"
|
|
52
82
|
|
|
53
|
-
|
|
83
|
+
### Option 3: Claude Desktop
|
|
54
84
|
|
|
55
|
-
|
|
56
|
-
Add to your Claude Desktop config file:
|
|
85
|
+
Add to your config file:
|
|
57
86
|
|
|
58
|
-
**
|
|
59
|
-
|
|
60
|
-
- Mac: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
87
|
+
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
88
|
+
**Mac:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
61
89
|
|
|
62
90
|
```json
|
|
63
91
|
{
|
|
@@ -70,246 +98,199 @@ Add to your Claude Desktop config file:
|
|
|
70
98
|
}
|
|
71
99
|
```
|
|
72
100
|
|
|
73
|
-
Restart Claude Desktop after
|
|
101
|
+
Restart Claude Desktop after saving.
|
|
74
102
|
|
|
75
|
-
### Option
|
|
76
|
-
```bash
|
|
77
|
-
git clone https://github.com/cherchyk/MCPBrowser.git
|
|
78
|
-
cd MCPBrowser/MCPBrowser # Navigate to MCP server directory
|
|
79
|
-
npm install
|
|
80
|
-
```
|
|
103
|
+
### Option 4: npm Package
|
|
81
104
|
|
|
82
|
-
|
|
83
|
-
- Chrome or Edge installed.
|
|
84
|
-
- Node 18+.
|
|
105
|
+
For VS Code (GitHub Copilot) manual setup, add to your `mcp.json`:
|
|
85
106
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
- On first use, the server auto-launches Chrome/Edge with remote debugging if it cannot find an existing DevTools endpoint. Defaults: port `9222`, user data dir `%LOCALAPPDATA%/ChromeAuthProfile`. Override with `CHROME_PATH`, `CHROME_USER_DATA_DIR`, or `CHROME_REMOTE_DEBUG_PORT`.
|
|
89
|
-
- Chrome startup is handled inside the MCP server.
|
|
107
|
+
**Windows:** `%APPDATA%\Code\User\mcp.json`
|
|
108
|
+
**Mac/Linux:** `~/.config/Code/User/mcp.json`
|
|
90
109
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"servers": {
|
|
113
|
+
"MCPBrowser": {
|
|
114
|
+
"type": "stdio",
|
|
115
|
+
"command": "npx",
|
|
116
|
+
"args": ["-y", "mcpbrowser@latest"]
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
99
120
|
```
|
|
100
|
-
Set `CHROME_PATH` if auto-detect fails; override profile with `CHROME_USER_DATA_DIR`, port with `CHROME_REMOTE_DEBUG_PORT`.
|
|
101
121
|
|
|
102
|
-
##
|
|
103
|
-
There is no local LLM runner now; AI assistants (Claude Code, GitHub Copilot, Claude Desktop) provide the LLM and call this MCP tool. If you need a standalone agent later, we can add one that reuses the fetch logic.
|
|
122
|
+
## MCP Tools
|
|
104
123
|
|
|
105
|
-
|
|
124
|
+
### `fetch_webpage`
|
|
106
125
|
|
|
107
|
-
|
|
108
|
-
- **Windows**: `%APPDATA%\Code\User\mcp.json`
|
|
109
|
-
- **Linux/Mac**: `~/.config/Code/User/mcp.json`
|
|
126
|
+
Fetches web pages using your Chrome/Edge browser. Handles authentication, CAPTCHA, SSO, anti-bot protection, and JavaScript-heavy sites. Opens the URL in a browser tab (reuses existing tab for same domain) and waits for the page to fully load before returning content.
|
|
110
127
|
|
|
111
|
-
|
|
128
|
+
**Parameters:**
|
|
129
|
+
- `url` (string, required) - The URL to fetch
|
|
130
|
+
- `removeUnnecessaryHTML` (boolean, optional, default: `true`) - Remove unnecessary HTML for size reduction by ~90%
|
|
131
|
+
- `postLoadWait` (number, optional, default: `1000`) - Milliseconds to wait after page load for SPAs to render dynamic content
|
|
112
132
|
|
|
113
|
-
|
|
133
|
+
**Examples:**
|
|
134
|
+
```javascript
|
|
135
|
+
// Basic fetch
|
|
136
|
+
{ url: "https://example.com" }
|
|
114
137
|
|
|
115
|
-
|
|
116
|
-
"
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"description": "Web page fetching via browser for sites requiring authentication, anti-bot protection, or JavaScript rendering. Use when standard HTTP requests fail for: (1) auth-required pages (401/403, SSO, corporate intranets), (2) anti-bot verification (CAPTCHA, Cloudflare), (3) JavaScript-heavy sites (SPAs, dynamic content). Opens a browser where the user can authenticate, then automatically extracts content."
|
|
121
|
-
}
|
|
138
|
+
// Fetch with custom wait time for slow SPAs
|
|
139
|
+
{ url: "https://dashboard.example.com", postLoadWait: 2000 }
|
|
140
|
+
|
|
141
|
+
// Keep full HTML without cleanup
|
|
142
|
+
{ url: "https://example.com", removeUnnecessaryHTML: false }
|
|
122
143
|
```
|
|
123
144
|
|
|
124
|
-
|
|
125
|
-
- Windows: `"D:/dev/MCPBrowser/MCPBrowser/src/mcp-browser.js"`
|
|
126
|
-
- Linux/Mac: `"/home/user/MCPBrowser/MCPBrowser/src/mcp-browser.js"`
|
|
145
|
+
---
|
|
127
146
|
|
|
128
|
-
###
|
|
129
|
-
Restart VS Code or reload the window for the changes to take effect.
|
|
147
|
+
### `click_element`
|
|
130
148
|
|
|
131
|
-
|
|
132
|
-
In Claude Code or Copilot Chat, you should see the `MCPBrowser` server listed. Ask it to fetch an authenticated URL and it will drive your signed-in Chrome session.
|
|
149
|
+
Clicks on any clickable element (buttons, links, divs with onclick handlers, etc.). Can target by CSS selector or visible text content. Automatically scrolls element into view and waits for page stability after clicking.
|
|
133
150
|
|
|
134
|
-
|
|
135
|
-
- Tool `fetch_webpage` (inside the MCP server) drives your live Chrome/Edge (DevTools Protocol) so it inherits your auth cookies, returning `html` (truncated up to 2M chars) for analysis.
|
|
136
|
-
- **Smart confirmation**: AI assistant asks for confirmation ONLY on first request to a new domain - explains browser will open for authentication. Subsequent requests to same domain work automatically (session preserved).
|
|
137
|
-
- **Domain-aware tab reuse**: Automatically reuses the same tab for URLs on the same domain, preserving authentication session. Different domains open new tabs.
|
|
138
|
-
- **Automatic page loading**: Waits for network idle (`networkidle0`) by default, ensuring JavaScript-heavy pages (SPAs, dashboards) fully load before returning content.
|
|
139
|
-
- **Automatic auth detection**: Detects ANY authentication redirect (domain changes, login/auth/sso/oauth URLs) and waits for you to complete sign-in, then returns to target page.
|
|
140
|
-
- **Universal compatibility**: Works with ANY authenticated site - corporate intranets, SSO, OAuth, SAML, login pages, etc.
|
|
141
|
-
- **Smart timeouts**: 60s default for page fetch, 10 min for auth redirects. Tabs stay open indefinitely for reuse (no auto-close).
|
|
142
|
-
- The AI assistant's LLM invokes this tool via MCP; this repo itself does not run an LLM.
|
|
151
|
+
**โ ๏ธ Note:** Page must be already loaded via `fetch_webpage` first.
|
|
143
152
|
|
|
144
|
-
|
|
153
|
+
**Parameters:**
|
|
154
|
+
- `url` (string, required) - The URL of the page (must match a previously fetched page)
|
|
155
|
+
- `selector` (string, optional) - CSS selector for the element (e.g., `#submit-btn`, `.login-button`)
|
|
156
|
+
- `text` (string, optional) - Text content to search for if selector not provided (e.g., "Sign In", "Submit")
|
|
157
|
+
- `returnHtml` (boolean, optional, default: `true`) - Whether to wait for stability and return HTML after clicking. Set to `false` for fast form interactions (checkboxes, radio buttons)
|
|
158
|
+
- `removeUnnecessaryHTML` (boolean, optional, default: `true`) - Remove unnecessary HTML for size reduction. Only used when `returnHtml` is `true`
|
|
159
|
+
- `postClickWait` (number, optional, default: `1000`) - Milliseconds to wait after click for SPAs to render dynamic content
|
|
160
|
+
- `waitForElementTimeout` (number, optional, default: `1000`) - Maximum time to wait for element in milliseconds
|
|
161
|
+
|
|
162
|
+
**Examples:**
|
|
163
|
+
```javascript
|
|
164
|
+
// Click by text content
|
|
165
|
+
{ url: "https://example.com", text: "Sign In" }
|
|
145
166
|
|
|
146
|
-
|
|
167
|
+
// Click by CSS selector
|
|
168
|
+
{ url: "https://example.com", selector: "#login-button" }
|
|
147
169
|
|
|
148
|
-
|
|
170
|
+
// Click without waiting for HTML (fast checkbox toggle)
|
|
171
|
+
{ url: "https://example.com", selector: "#agree-checkbox", returnHtml: false }
|
|
149
172
|
|
|
150
|
-
|
|
151
|
-
|
|
173
|
+
// Click with custom wait time
|
|
174
|
+
{ url: "https://example.com", text: "Load More", postClickWait: 2000 }
|
|
175
|
+
```
|
|
152
176
|
|
|
153
|
-
|
|
154
|
-
- `url` (required): URL of the page (must be already loaded via `fetch_webpage`)
|
|
155
|
-
- `selector` (optional): CSS selector for the element (e.g., `#submit-btn`, `.login-button`)
|
|
156
|
-
- `text` (optional): Text content to search for if selector not provided (e.g., "Sign In", "Submit")
|
|
157
|
-
- `timeout` (optional): Maximum wait time in milliseconds (default: 30000)
|
|
177
|
+
---
|
|
158
178
|
|
|
159
|
-
|
|
160
|
-
```javascript
|
|
161
|
-
// Click by selector
|
|
162
|
-
{ url: "https://example.com", selector: "#login-button" }
|
|
179
|
+
### `type_text`
|
|
163
180
|
|
|
164
|
-
|
|
165
|
-
{ url: "https://example.com", text: "Sign In" }
|
|
166
|
-
```
|
|
181
|
+
Types text into an input field, textarea, or other editable element. Simulates human-like typing with configurable delay between keystrokes. Automatically clears existing text by default.
|
|
167
182
|
|
|
168
|
-
|
|
169
|
-
Type text into input fields, textareas, or any editable element with human-like typing simulation.
|
|
183
|
+
**โ ๏ธ Note:** Page must be already loaded via `fetch_webpage` first.
|
|
170
184
|
|
|
171
185
|
**Parameters:**
|
|
172
|
-
- `url` (required)
|
|
173
|
-
- `selector` (required)
|
|
174
|
-
- `text` (required)
|
|
175
|
-
- `clear` (optional
|
|
176
|
-
- `
|
|
177
|
-
- `
|
|
178
|
-
|
|
179
|
-
|
|
186
|
+
- `url` (string, required) - The URL of the page (must match a previously fetched page)
|
|
187
|
+
- `selector` (string, required) - CSS selector for the input element (e.g., `#username`, `input[name="email"]`)
|
|
188
|
+
- `text` (string, required) - Text to type into the field
|
|
189
|
+
- `clear` (boolean, optional, default: `true`) - Whether to clear existing text first
|
|
190
|
+
- `typeDelay` (number, optional, default: `50`) - Delay between keystrokes in milliseconds (simulates human typing)
|
|
191
|
+
- `returnHtml` (boolean, optional, default: `true`) - Whether to wait for stability and return HTML after typing
|
|
192
|
+
- `removeUnnecessaryHTML` (boolean, optional, default: `true`) - Remove unnecessary HTML for size reduction. Only used when `returnHtml` is `true`
|
|
193
|
+
- `postTypeWait` (number, optional, default: `1000`) - Milliseconds to wait after typing for SPAs to render dynamic content
|
|
194
|
+
- `waitForElementTimeout` (number, optional, default: `5000`) - Maximum time to wait for element in milliseconds
|
|
195
|
+
|
|
196
|
+
**Examples:**
|
|
180
197
|
```javascript
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
selector: "#username",
|
|
184
|
-
text: "myuser@example.com"
|
|
185
|
-
}
|
|
186
|
-
```
|
|
198
|
+
// Basic text input
|
|
199
|
+
{ url: "https://example.com", selector: "#email", text: "user@example.com" }
|
|
187
200
|
|
|
188
|
-
|
|
189
|
-
|
|
201
|
+
// Append text without clearing
|
|
202
|
+
{ url: "https://example.com", selector: "#search", text: " advanced", clear: false }
|
|
190
203
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
- `limit` (optional): Maximum number of elements to return (default: 50)
|
|
194
|
-
|
|
195
|
-
**Returns:** Array of elements with details (tag, text, selector, href, type, id, hasOnClick, role)
|
|
204
|
+
// Fast typing without human simulation
|
|
205
|
+
{ url: "https://example.com", selector: "#username", text: "john", typeDelay: 0 }
|
|
196
206
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
{ url: "https://example.com", limit: 20 }
|
|
207
|
+
// Type without waiting for HTML return (faster)
|
|
208
|
+
{ url: "https://example.com", selector: "#field", text: "value", returnHtml: false }
|
|
200
209
|
```
|
|
201
210
|
|
|
202
|
-
|
|
203
|
-
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
### `get_current_html`
|
|
214
|
+
|
|
215
|
+
Gets the current HTML from an already-loaded page **WITHOUT** navigating or reloading. Much faster than `fetch_webpage` since it only extracts the current DOM state. Use this after interactions (click, type) to get the updated page content efficiently.
|
|
216
|
+
|
|
217
|
+
**โ ๏ธ Note:** Page must be already loaded via `fetch_webpage` first.
|
|
204
218
|
|
|
205
219
|
**Parameters:**
|
|
206
|
-
- `url` (required)
|
|
207
|
-
- `
|
|
208
|
-
- `text` (optional): Text content to wait for if selector not provided
|
|
209
|
-
- `timeout` (optional): Maximum wait time in milliseconds (default: 30000)
|
|
220
|
+
- `url` (string, required) - The URL of the page (must match a previously fetched page)
|
|
221
|
+
- `removeUnnecessaryHTML` (boolean, optional, default: `true`) - Remove unnecessary HTML for size reduction by ~90%
|
|
210
222
|
|
|
211
|
-
**
|
|
223
|
+
**Examples:**
|
|
212
224
|
```javascript
|
|
213
|
-
|
|
225
|
+
// Get current HTML after interactions
|
|
226
|
+
{ url: "https://example.com" }
|
|
227
|
+
|
|
228
|
+
// Get full HTML without cleanup
|
|
229
|
+
{ url: "https://example.com", removeUnnecessaryHTML: false }
|
|
214
230
|
```
|
|
215
231
|
|
|
216
|
-
|
|
217
|
-
|
|
232
|
+
**Performance comparison:**
|
|
233
|
+
- `fetch_webpage`: 2-5 seconds (full page reload)
|
|
234
|
+
- `get_current_html`: 0.1-0.3 seconds (just extracts HTML) โ
|
|
235
|
+
|
|
236
|
+
---
|
|
218
237
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
238
|
+
### `close_tab`
|
|
239
|
+
|
|
240
|
+
Closes the browser tab for the given URL's hostname. Removes the page from the tab pool and forces a fresh session on the next visit to that hostname. Useful for clearing authentication state, managing memory, or starting fresh with a domain.
|
|
241
|
+
|
|
242
|
+
**โ ๏ธ Note:** Uses exact hostname match (`www.example.com` and `example.com` are treated as different tabs).
|
|
224
243
|
|
|
225
244
|
**Parameters:**
|
|
226
|
-
- `url` (required)
|
|
227
|
-
- `removeUnnecessaryHTML` (optional): Clean HTML for size reduction (default: true, ~90% smaller)
|
|
245
|
+
- `url` (string, required) - The URL whose hostname tab should be closed
|
|
228
246
|
|
|
229
|
-
**
|
|
247
|
+
**Examples:**
|
|
230
248
|
```javascript
|
|
231
|
-
|
|
232
|
-
|
|
249
|
+
// Close tab for a domain
|
|
250
|
+
{ url: "https://example.com" }
|
|
233
251
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
fetch_webpage after interaction: 2-5 seconds (reloads page)
|
|
237
|
-
get_current_html after interaction: 0.1-0.3 seconds (just extracts HTML) โ
|
|
252
|
+
// This will close the tab for portal.azure.com
|
|
253
|
+
{ url: "https://portal.azure.com/dashboard" }
|
|
238
254
|
```
|
|
239
255
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
### Key Features
|
|
282
|
-
- โ
Works with **any clickable element** - not just `<a>` tags (buttons, divs with onclick, etc.)
|
|
283
|
-
- โ
**Text-based selection** - click elements by their visible text
|
|
284
|
-
- โ
**Human-like typing** - simulates natural keystroke delays
|
|
285
|
-
- โ
**Automatic scrolling** - scrolls elements into view before interaction
|
|
286
|
-
- โ
**Smart element detection** - finds the most specific match when searching by text
|
|
287
|
-
- โ
**Session preservation** - all interactions happen in the same browser tab
|
|
288
|
-
|
|
289
|
-
## Auth-assisted fetch flow
|
|
290
|
-
- AI assistant can call with just the URL, or with no params if you set an env default (`DEFAULT_FETCH_URL` or `MCP_DEFAULT_FETCH_URL`). By default tabs stay open indefinitely for reuse (domain-aware).
|
|
291
|
-
- First call opens the tab and leaves it open so you can sign in. No extra params needed.
|
|
292
|
-
- After you sign in, call the same URL again; tab stays open for reuse. Set `keepPageOpen: false` to close immediately on success.
|
|
293
|
-
- Optional fields (`authWaitSelector`, `waitForSelector`, `waitForUrlPattern`, etc.) are available but not required.
|
|
294
|
-
|
|
295
|
-
## Configuration
|
|
296
|
-
Optional environment variables for advanced configuration:
|
|
297
|
-
- `CHROME_PATH`: Custom path to Chrome/Edge executable
|
|
298
|
-
- `CHROME_USER_DATA_DIR`: Custom browser profile directory
|
|
299
|
-
- `CHROME_REMOTE_DEBUG_HOST`: DevTools host (default: `127.0.0.1`)
|
|
300
|
-
- `CHROME_REMOTE_DEBUG_PORT`: DevTools port (default: `9222`)
|
|
301
|
-
- `CHROME_WS_ENDPOINT`: Explicit WebSocket endpoint URL
|
|
302
|
-
- `DEFAULT_FETCH_URL` or `MCP_DEFAULT_FETCH_URL`: Default URL when called without params
|
|
303
|
-
|
|
304
|
-
Set these in your shell or system environment before running the MCP server.
|
|
305
|
-
|
|
306
|
-
## Tips
|
|
307
|
-
- **Universal auth**: Works with ANY authenticated site - corporate intranets, SSO, OAuth, SAML, login pages, CAPTCHA, human verification, etc.
|
|
308
|
-
- **No re-authentication needed**: Automatically reuses the same tab for URLs on the same domain, keeping your auth session alive across multiple page fetches
|
|
309
|
-
- **Automatic page loading**: Tool waits for pages to fully load (default 60s timeout, waits for network idle). AI assistant should trust the tool and not retry manually.
|
|
310
|
-
- **Auth redirect handling**: Auto-detects auth redirects by monitoring domain changes and common login URL patterns (`/login`, `/auth`, `/signin`, `/sso`, `/oauth`, `/saml`)
|
|
311
|
-
- **Tabs stay open**: By default tabs remain open indefinitely for reuse. Set `keepPageOpen: false` to close immediately after successful fetch.
|
|
312
|
-
- **Smart domain switching**: When switching domains, automatically closes the old tab and opens a new one to prevent tab accumulation
|
|
313
|
-
- If you hit login pages, verify Chrome/Edge instance is signed in and the site opens there.
|
|
314
|
-
- Use a dedicated profile directory to avoid interfering with your daily browser.
|
|
315
|
-
- For heavy pages, add `waitForSelector` to ensure post-login content appears before extraction.
|
|
256
|
+
**Use cases:**
|
|
257
|
+
- Clear authentication/session state
|
|
258
|
+
- Free up browser memory
|
|
259
|
+
- Reset to fresh state before new login
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
## Configuration (Optional)
|
|
264
|
+
|
|
265
|
+
Environment variables for advanced setup:
|
|
266
|
+
|
|
267
|
+
| Variable | Description | Default |
|
|
268
|
+
|----------|-------------|---------|
|
|
269
|
+
| `CHROME_PATH` | Path to Chrome/Edge | Auto-detect |
|
|
270
|
+
| `CHROME_USER_DATA_DIR` | Browser profile directory | `%LOCALAPPDATA%/ChromeAuthProfile` |
|
|
271
|
+
| `CHROME_REMOTE_DEBUG_PORT` | DevTools port | `9222` |
|
|
272
|
+
|
|
273
|
+
## Troubleshooting
|
|
274
|
+
|
|
275
|
+
**Browser doesn't open?**
|
|
276
|
+
- Make sure Chrome or Edge is installed
|
|
277
|
+
- Try setting `CHROME_PATH` explicitly
|
|
278
|
+
|
|
279
|
+
**Can't connect to browser?**
|
|
280
|
+
- Close all Chrome instances and try again
|
|
281
|
+
- Check if port 9222 is in use
|
|
282
|
+
|
|
283
|
+
**Authentication not preserved?**
|
|
284
|
+
- Keep the browser tab open (default behavior)
|
|
285
|
+
- Use the same domain for related requests
|
|
286
|
+
|
|
287
|
+
## Links
|
|
288
|
+
|
|
289
|
+
- [GitHub](https://github.com/cherchyk/MCPBrowser)
|
|
290
|
+
- [npm](https://www.npmjs.com/package/mcpbrowser)
|
|
291
|
+
- [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=cherchyk.mcpbrowser)
|
|
292
|
+
- [Issues](https://github.com/cherchyk/MCPBrowser/issues)
|
|
293
|
+
|
|
294
|
+
## License
|
|
295
|
+
|
|
296
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcpbrowser",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"mcpName": "io.github.cherchyk/mcpbrowser",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"description": "MCP server
|
|
6
|
+
"description": "MCP browser server - fetch web pages using real Chrome/Edge browser. Handles authentication, SSO, CAPTCHAs, and anti-bot protection. Browser automation for AI assistants.",
|
|
7
7
|
"main": "src/mcp-browser.js",
|
|
8
8
|
"bin": {
|
|
9
9
|
"mcpbrowser": "src/mcp-browser.js"
|
|
@@ -18,11 +18,26 @@
|
|
|
18
18
|
"mcp",
|
|
19
19
|
"mcp-server",
|
|
20
20
|
"model-context-protocol",
|
|
21
|
+
"browser",
|
|
22
|
+
"web-browser",
|
|
21
23
|
"chrome",
|
|
22
24
|
"puppeteer",
|
|
25
|
+
"playwright",
|
|
23
26
|
"authentication",
|
|
24
27
|
"web-scraping",
|
|
25
|
-
"
|
|
28
|
+
"scraper",
|
|
29
|
+
"web-automation",
|
|
30
|
+
"automation",
|
|
31
|
+
"cloudflare",
|
|
32
|
+
"sso",
|
|
33
|
+
"captcha",
|
|
34
|
+
"spa",
|
|
35
|
+
"javascript-rendering",
|
|
36
|
+
"github-copilot",
|
|
37
|
+
"claude",
|
|
38
|
+
"ai-assistant",
|
|
39
|
+
"cdp",
|
|
40
|
+
"devtools"
|
|
26
41
|
],
|
|
27
42
|
"author": "cherchyk",
|
|
28
43
|
"license": "MIT",
|
package/src/mcp-browser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* MCPBrowser Server - Main Entry Point
|
|
4
4
|
* A Model Context Protocol server that provides browser automation capabilities
|
|
5
5
|
* with support for authentication flows, tab reuse, and interactive actions.
|
|
6
6
|
*/
|
package/tests/core/html.test.js
CHANGED
package/tests/core/page.test.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import assert from 'assert';
|
|
2
|
-
import { getBaseDomain, isLikelyAuthUrl
|
|
2
|
+
import { getBaseDomain, isLikelyAuthUrl } from '../../src/utils.js';
|
|
3
|
+
import { detectRedirectType } from '../../src/core/auth.js';
|
|
3
4
|
|
|
4
5
|
console.log('๐งช Testing redirect detection functions\n');
|
|
5
6
|
|
package/server.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
-
"name": "io.github.cherchyk/mcpbrowser",
|
|
4
|
-
"description": "In-browser web page fetching using Chrome DevTools Protocol. Handles auth-required pages, anti-bot/crawler blocks, and JavaScript-heavy sites",
|
|
5
|
-
"repository": {
|
|
6
|
-
"url": "https://github.com/cherchyk/MCPBrowser",
|
|
7
|
-
"source": "github"
|
|
8
|
-
},
|
|
9
|
-
"version": "0.3.1",
|
|
10
|
-
"packages": [
|
|
11
|
-
{
|
|
12
|
-
"registryType": "npm",
|
|
13
|
-
"identifier": "mcpbrowser",
|
|
14
|
-
"version": "0.2.32",
|
|
15
|
-
"transport": {
|
|
16
|
-
"type": "stdio"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
}
|