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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/mcp-browser.js +18 -5
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  { "name": "mcpbrowser",
2
- "version": "0.2.9",
2
+ "version": "0.2.10",
3
3
  "mcpName": "io.github.cherchyk/browser",
4
4
  "type": "module",
5
5
  "description": "MCP server that loads authenticated web pages using Chrome DevTools Protocol",
@@ -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
- // 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];
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 existing pages
221
+ // Create new tab if no controllable pages
209
222
  page = await browser.newPage();
210
223
  }
211
224
  }