mcpbrowser 0.2.9 → 0.2.11
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/extension/package.json +1 -1
- package/package.json +1 -1
- package/src/mcp-browser.js +30 -12
package/extension/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "mcpbrowser",
|
|
3
3
|
"displayName": "MCP Browser",
|
|
4
4
|
"description": "Extends Copilot's web access to protected pages - handles login, SSO, and anti-crawler restrictions",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.11",
|
|
6
6
|
"publisher": "cherchyk",
|
|
7
7
|
"icon": "icon.png",
|
|
8
8
|
"engines": {
|
package/package.json
CHANGED
package/src/mcp-browser.js
CHANGED
|
@@ -20,12 +20,13 @@ function getDefaultUserDataDir() {
|
|
|
20
20
|
const platform = os.platform();
|
|
21
21
|
const home = os.homedir();
|
|
22
22
|
|
|
23
|
+
// Use a dedicated debugging profile directory
|
|
23
24
|
if (platform === "win32") {
|
|
24
|
-
return path.join(home, "AppData/Local/
|
|
25
|
+
return path.join(home, "AppData/Local/MCPBrowser/ChromeDebug");
|
|
25
26
|
} else if (platform === "darwin") {
|
|
26
|
-
return path.join(home, "Library/Application Support/
|
|
27
|
+
return path.join(home, "Library/Application Support/MCPBrowser/ChromeDebug");
|
|
27
28
|
} else {
|
|
28
|
-
return path.join(home, ".config/
|
|
29
|
+
return path.join(home, ".config/MCPBrowser/ChromeDebug");
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -104,7 +105,10 @@ async function launchChromeIfNeeded() {
|
|
|
104
105
|
const args = [
|
|
105
106
|
`--remote-debugging-port=${chromePort}`,
|
|
106
107
|
`--user-data-dir=${userDataDir}`,
|
|
107
|
-
'
|
|
108
|
+
'--no-first-run', // Skip first run experience
|
|
109
|
+
'--no-default-browser-check', // Skip default browser check
|
|
110
|
+
'--disable-sync', // Disable Chrome sync prompts
|
|
111
|
+
'about:blank' // Open with a blank page
|
|
108
112
|
];
|
|
109
113
|
const child = spawn(chromePath, args, { detached: true, stdio: "ignore" });
|
|
110
114
|
child.unref();
|
|
@@ -197,23 +201,37 @@ async function fetchPage({
|
|
|
197
201
|
}
|
|
198
202
|
}
|
|
199
203
|
|
|
200
|
-
//
|
|
204
|
+
// Create new tab if no reuse
|
|
201
205
|
if (!page) {
|
|
202
|
-
|
|
203
|
-
// Find an existing page that's not being used
|
|
204
|
-
if (pages.length > 0) {
|
|
205
|
-
// Use the first available page (usually the blank tab Chrome opens with)
|
|
206
|
-
page = pages[0];
|
|
207
|
-
} else {
|
|
208
|
-
// Create new tab if no existing pages
|
|
206
|
+
try {
|
|
209
207
|
page = await browser.newPage();
|
|
208
|
+
} catch (error) {
|
|
209
|
+
// If newPage() fails (can happen with some profiles), try to reuse existing page
|
|
210
|
+
const pages = await browser.pages();
|
|
211
|
+
for (const p of pages) {
|
|
212
|
+
try {
|
|
213
|
+
const pageUrl = p.url();
|
|
214
|
+
// Skip chrome:// pages and other internal pages
|
|
215
|
+
if (!pageUrl.startsWith('chrome://') && !pageUrl.startsWith('chrome-extension://')) {
|
|
216
|
+
page = p;
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
} catch {
|
|
220
|
+
// Skip pages we can't access
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (!page) {
|
|
224
|
+
throw new Error('Unable to create or find a controllable page');
|
|
225
|
+
}
|
|
210
226
|
}
|
|
211
227
|
}
|
|
212
228
|
|
|
213
229
|
let shouldKeepOpen = keepPageOpen || page === lastKeptPage;
|
|
214
230
|
let wasSuccess = false;
|
|
215
231
|
try {
|
|
232
|
+
console.error(`[MCPBrowser] Navigating to: ${url}`);
|
|
216
233
|
await page.goto(url, { waitUntil, timeout: timeoutMs });
|
|
234
|
+
console.error(`[MCPBrowser] Navigation completed: ${page.url()}`);
|
|
217
235
|
|
|
218
236
|
// Extract content
|
|
219
237
|
const text = await page.evaluate(() => document.body?.innerText || "");
|