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 CHANGED
@@ -1,63 +1,91 @@
1
- # MCP Browser (MCP fetch for protected web resources)
1
+ # MCPBrowser (MCP Browser)
2
2
 
3
3
  [![VS Code Marketplace](https://img.shields.io/visual-studio-marketplace/v/cherchyk.mcpbrowser.svg)](https://marketplace.visualstudio.com/items?itemName=cherchyk.mcpbrowser)
4
4
  [![npm version](https://img.shields.io/npm/v/mcpbrowser.svg)](https://www.npmjs.com/package/mcpbrowser)
5
5
  [![Claude Desktop](https://img.shields.io/badge/Claude-Desktop-5865F2?logo=anthropic)](https://modelcontextprotocol.io/quickstart/user)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
 
8
- **Enables Claude Code, GitHub Copilot, and Claude Desktop to fetch protected web pages** - handles login-protected web pages, corporate SSO, and anti-crawler restrictions that normal fetching can't handle. Uses your Chrome/Edge browser session via DevTools Protocol.
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
- ## ๐Ÿš€ Installation Options
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
- ### Option 1: VS Code Extension (Easiest - One Click)
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
- Or search "MCPBrowser" in VS Code Extensions view.
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
- **From GitHub Release:**
21
- Download from [GitHub Releases](https://github.com/cherchyk/MCPBrowser/releases):
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-0.3.1.vsix
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
- ๐Ÿ“ฆ [View on Marketplace](https://marketplace.visualstudio.com/items?itemName=cherchyk.mcpbrowser)
64
+ ### Option 2: Claude Code
32
65
 
33
- ### Option 2: npm Package (Recommended for Manual Setup)
34
- Published on npm as [mcpbrowser](https://www.npmjs.com/package/mcpbrowser) v0.3.1.
66
+ ```bash
67
+ claude mcp add mcpbrowser --scope user -- npx -y mcpbrowser@latest
68
+ ```
35
69
 
36
- Add to your `mcp.json`:
37
- ```jsonc
38
- "MCPBrowser": {
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
- **mcp.json Location:**
47
- - Windows: `%APPDATA%\Code\User\mcp.json`
48
- - Mac/Linux: `~/.config/Code/User/mcp.json`
75
+ You should see:
76
+ ```
77
+ mcpbrowser: npx -y mcpbrowser@latest - โœ“ Connected
78
+ ```
49
79
 
50
- ### Option 3: MCP Registry
51
- Available in the [MCP Registry](https://registry.modelcontextprotocol.io/) as `io.github.cherchyk/browser` v0.3.1.
80
+ That's it! Ask Claude to fetch any protected page:
81
+ > "Fetch https://portal.azure.com using mcpbrowser"
52
82
 
53
- Search for "browser" in the registry to find configuration instructions.
83
+ ### Option 3: Claude Desktop
54
84
 
55
- ### Option 4: Claude Desktop
56
- Add to your Claude Desktop config file:
85
+ Add to your config file:
57
86
 
58
- **Config Location:**
59
- - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
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 configuration.
101
+ Restart Claude Desktop after saving.
74
102
 
75
- ### Option 5: Clone from GitHub (Development)
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
- ## Prereqs
83
- - Chrome or Edge installed.
84
- - Node 18+.
105
+ For VS Code (GitHub Copilot) manual setup, add to your `mcp.json`:
85
106
 
86
- ## Run (automatic via AI assistants)
87
- - Add the MCP server entry to your AI assistant's config (see installation options above). The AI assistant will start the server automatically when it needs the toolโ€”no manual launch required.
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
- ## Manual start (optional)
92
- Only if you want to run it yourself (AI assistants already start it when configured):
93
- ```bash
94
- npm run mcp
95
- ```
96
- Or manually:
97
- ```powershell
98
- & "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="$env:LOCALAPPDATA\ChromeAuthProfile"
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
- ## (Optional) Local runner
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
- ## Configure in VS Code (Claude Code & GitHub Copilot)
124
+ ### `fetch_webpage`
106
125
 
107
- ### Step 1: Locate your mcp.json file
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
- ### Step 2: Add MCPBrowser server configuration
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
- Add this entry to your `mcp.json` file under the `"servers"` section:
133
+ **Examples:**
134
+ ```javascript
135
+ // Basic fetch
136
+ { url: "https://example.com" }
114
137
 
115
- ```jsonc
116
- "MCPBrowser": {
117
- "type": "stdio",
118
- "command": "node",
119
- "args": ["<PATH_TO_MCPBROWSER>/src/mcp-browser.js"],
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
- Replace `<PATH_TO_MCPBROWSER>` with the full path to the MCP server directory in the cloned repository, for example:
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
- ### Step 3: Reload VS Code
129
- Restart VS Code or reload the window for the changes to take effect.
147
+ ### `click_element`
130
148
 
131
- ### Step 4: Verify
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
- ## How it works
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
- ## ๐ŸŽฏ Interactive Features (NEW!)
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
- MCPBrowser now supports **human-like interaction** with web pages! You can click buttons, fill forms, and interact with dynamic content just like a human would.
167
+ // Click by CSS selector
168
+ { url: "https://example.com", selector: "#login-button" }
147
169
 
148
- ### Available Tools
170
+ // Click without waiting for HTML (fast checkbox toggle)
171
+ { url: "https://example.com", selector: "#agree-checkbox", returnHtml: false }
149
172
 
150
- #### 1. `click_element` - Click on page elements
151
- Click on any element - buttons, links, divs with onclick handlers, or any clickable element.
173
+ // Click with custom wait time
174
+ { url: "https://example.com", text: "Load More", postClickWait: 2000 }
175
+ ```
152
176
 
153
- **Parameters:**
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
- **Example:**
160
- ```javascript
161
- // Click by selector
162
- { url: "https://example.com", selector: "#login-button" }
179
+ ### `type_text`
163
180
 
164
- // Click by text content
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
- #### 2. `type_text` - Type text into input fields
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): URL of the page
173
- - `selector` (required): CSS selector for the input element
174
- - `text` (required): Text to type
175
- - `clear` (optional): Clear existing text first (default: true)
176
- - `delay` (optional): Delay between keystrokes in ms (default: 50)
177
- - `timeout` (optional): Maximum wait time in milliseconds (default: 30000)
178
-
179
- **Example:**
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
- url: "https://example.com",
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
- #### 3. `get_interactive_elements` - List all interactive elements
189
- Discover all clickable and interactive elements on the page - links, buttons, inputs, elements with onclick handlers.
201
+ // Append text without clearing
202
+ { url: "https://example.com", selector: "#search", text: " advanced", clear: false }
190
203
 
191
- **Parameters:**
192
- - `url` (required): URL of the page
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
- **Example:**
198
- ```javascript
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
- #### 4. `wait_for_element` - Wait for element to appear
203
- Wait for an element to appear on the page (useful after clicking something that triggers dynamic content).
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): URL of the page
207
- - `selector` (optional): CSS selector to wait for
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
- **Example:**
223
+ **Examples:**
212
224
  ```javascript
213
- { url: "https://example.com", selector: ".success-message" }
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
- #### 5. `get_current_html` - Get updated HTML without reloading (NEW! ๐Ÿš€)
217
- **Efficiently** get the current HTML state from an already-loaded page **without navigation or reloading**. Use this after interactions (`click_element`, `type_text`, `wait_for_element`) to get the updated DOM state.
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
- **Why use this instead of `fetch_webpage`?**
220
- - โšก **Much faster** - no page reload, just extracts current DOM
221
- - ๐ŸŽฏ **More accurate** - captures exact state after interaction
222
- - ๐Ÿ’พ **Preserves state** - doesn't lose dynamic JavaScript state
223
- - ๐Ÿ”„ **Efficient** - perfect for interactive workflows
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): URL of the page (must be already loaded via `fetch_webpage`)
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
- **Example:**
247
+ **Examples:**
230
248
  ```javascript
231
- { url: "https://example.com", removeUnnecessaryHTML: true }
232
- ```
249
+ // Close tab for a domain
250
+ { url: "https://example.com" }
233
251
 
234
- **Performance comparison:**
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
- ### Usage Workflow
241
-
242
- **Efficient interactive workflow (NEW!):**
243
-
244
- 1. **First, fetch the page:**
245
- ```javascript
246
- fetch_webpage({ url: "https://example.com/login" })
247
- ```
248
-
249
- 2. **Discover interactive elements:**
250
- ```javascript
251
- get_interactive_elements({ url: "https://example.com/login" })
252
- ```
253
-
254
- 3. **Fill in the form:**
255
- ```javascript
256
- type_text({ url: "https://example.com/login", selector: "#username", text: "user@example.com" })
257
- type_text({ url: "https://example.com/login", selector: "#password", text: "mypassword" })
258
- ```
259
-
260
- 4. **Click the submit button:**
261
- ```javascript
262
- click_element({ url: "https://example.com/login", selector: "#submit" })
263
- // or by text: click_element({ url: "https://example.com/login", text: "Sign In" })
264
- ```
265
-
266
- 5. **Wait for content to load:**
267
- ```javascript
268
- wait_for_element({ url: "https://example.com/dashboard", selector: ".dashboard-content" })
269
- ```
270
-
271
- 6. **Get updated HTML efficiently (no reload!):**
272
- ```javascript
273
- get_current_html({ url: "https://example.com/dashboard" })
274
- // โœ… Fast! Just extracts current DOM without reloading the page
275
- ```
276
-
277
- **When to use `get_current_html` vs `fetch_webpage`:**
278
- - Use `fetch_webpage`: Initial page load, navigation to new URLs, auth flows
279
- - Use `get_current_html`: After clicks, form fills, waits - when page is already loaded โœ…
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.1",
3
+ "version": "0.3.3",
4
4
  "mcpName": "io.github.cherchyk/mcpbrowser",
5
5
  "type": "module",
6
- "description": "MCP server for in-browser web page fetching using Chrome DevTools Protocol",
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
- "github-copilot"
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",
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * MCP Browser Server - Main Entry Point
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
  */
@@ -1,5 +1,5 @@
1
1
  import assert from 'assert';
2
- import { prepareHtml, cleanHtml, enrichHtml } from '../../src/mcp-browser.js';
2
+ import { prepareHtml, cleanHtml, enrichHtml } from '../../src/core/html.js';
3
3
 
4
4
  console.log('๐Ÿงช Testing HTML processing functions\n');
5
5
 
@@ -1,5 +1,6 @@
1
1
  import assert from 'assert';
2
- import { getBaseDomain, isLikelyAuthUrl, detectRedirectType } from '../../src/mcp-browser.js';
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
- }