mcpbrowser 0.2.9 → 0.2.10
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/package.json +1 -1
- package/src/mcp-browser.js +18 -5
package/package.json
CHANGED
package/src/mcp-browser.js
CHANGED
|
@@ -200,12 +200,25 @@ async function fetchPage({
|
|
|
200
200
|
// Try to reuse existing pages first (when Chrome opened with profile)
|
|
201
201
|
if (!page) {
|
|
202
202
|
const pages = await browser.pages();
|
|
203
|
-
//
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
203
|
+
// Filter out pages that might not be controllable
|
|
204
|
+
const controllablePages = [];
|
|
205
|
+
for (const p of pages) {
|
|
206
|
+
try {
|
|
207
|
+
const url = p.url();
|
|
208
|
+
// Skip chrome:// pages and other internal pages
|
|
209
|
+
if (!url.startsWith('chrome://') && !url.startsWith('chrome-extension://')) {
|
|
210
|
+
controllablePages.push(p);
|
|
211
|
+
}
|
|
212
|
+
} catch {
|
|
213
|
+
// Skip pages we can't access
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Use first controllable page or create new one
|
|
218
|
+
if (controllablePages.length > 0) {
|
|
219
|
+
page = controllablePages[0];
|
|
207
220
|
} else {
|
|
208
|
-
// Create new tab if no
|
|
221
|
+
// Create new tab if no controllable pages
|
|
209
222
|
page = await browser.newPage();
|
|
210
223
|
}
|
|
211
224
|
}
|