chrome-devtools-mcp-for-extension 0.8.7 → 0.8.8

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.
@@ -448,7 +448,7 @@ export const toggleExtensionState = defineTool({
448
448
  });
449
449
  export const openExtensionPopup = defineTool({
450
450
  name: 'open_extension_popup',
451
- description: `Open a Chrome extension's popup in a testable context. The popup will be opened as a page that can be interacted with using standard tools like take_snapshot, click, and evaluate_script.`,
451
+ description: `Select an already-opened Chrome extension popup window for testing. The user should manually click the extension icon first to open the popup, then this tool will detect and select it. After selection, you can use take_snapshot, click, evaluate_script, etc. on the popup.`,
452
452
  annotations: {
453
453
  category: ToolCategories.EXTENSION_DEVELOPMENT,
454
454
  readOnlyHint: false,
@@ -494,54 +494,38 @@ export const openExtensionPopup = defineTool({
494
494
  }
495
495
  response.appendResponseLine(`🔍 Found extension: ${extensionInfo.name} (${extensionInfo.id})`);
496
496
  try {
497
- // Find service worker target
498
497
  const browser = page.browser();
499
498
  if (!browser) {
500
499
  response.appendResponseLine('❌ Failed to get browser instance.');
501
500
  return;
502
501
  }
503
- const targets = await browser.targets();
504
- const workerTarget = targets.find((target) => target.type() === 'service_worker' &&
505
- target.url().includes(extensionInfo.id));
506
- if (!workerTarget) {
507
- response.appendResponseLine('❌ Service worker not found. Extension may not have a service worker (MV2 extensions are not supported).');
508
- return;
509
- }
510
- const worker = await workerTarget.worker();
511
- if (!worker) {
512
- response.appendResponseLine('❌ Failed to get service worker context.');
513
- return;
514
- }
515
- response.appendResponseLine('🔧 Opening popup via service worker...');
516
- // Open popup
517
- await worker.evaluate('chrome.action.openPopup();');
518
- // Wait for popup target
519
- const popupTarget = await browser.waitForTarget((target) => target.type() === 'page' &&
520
- target.url().includes(extensionInfo.id) &&
521
- target.url().includes('popup'), { timeout: 5000 });
522
- if (!popupTarget) {
523
- response.appendResponseLine('❌ Popup did not open within timeout.');
524
- return;
502
+ response.appendResponseLine('🔧 Looking for open popup window...');
503
+ // Get all pages
504
+ const pages = await browser.pages();
505
+ // Find popup page by URL (contains extension ID)
506
+ let popupPage = null;
507
+ let popupIndex = -1;
508
+ for (let i = 0; i < pages.length; i++) {
509
+ const p = pages[i];
510
+ const url = p.url();
511
+ if (url && url.includes(extensionInfo.id)) {
512
+ popupPage = p;
513
+ popupIndex = i;
514
+ break;
515
+ }
525
516
  }
526
- const popupPage = await popupTarget.page();
527
517
  if (!popupPage) {
528
- response.appendResponseLine('❌ Failed to get popup page reference.');
518
+ response.appendResponseLine('❌ Popup window not found.');
519
+ response.appendResponseLine('💡 Please manually click the extension icon to open the popup first.');
529
520
  return;
530
521
  }
531
- // Add popup page to context and select it
532
- const pages = await browser.pages();
533
- const popupIndex = pages.indexOf(popupPage);
534
- if (popupIndex !== -1) {
535
- context.setSelectedPageIdx(popupIndex);
536
- response.appendResponseLine('');
537
- response.appendResponseLine(`✅ Popup opened: ${extensionInfo.name}`);
538
- response.appendResponseLine(`📄 Popup URL: ${popupPage.url()}`);
539
- response.appendResponseLine('');
540
- response.appendResponseLine('💡 You can now use take_snapshot, click, evaluate_script, etc. on the popup');
541
- }
542
- else {
543
- response.appendResponseLine('⚠️ Popup opened but could not be selected automatically.');
544
- }
522
+ // Select the popup page
523
+ context.setSelectedPageIdx(popupIndex);
524
+ response.appendResponseLine('');
525
+ response.appendResponseLine(`✅ Popup window selected: ${extensionInfo.name}`);
526
+ response.appendResponseLine(`📄 Popup URL: ${popupPage.url()}`);
527
+ response.appendResponseLine('');
528
+ response.appendResponseLine('💡 You can now use take_snapshot, click, evaluate_script, etc. on the popup');
545
529
  }
546
530
  catch (error) {
547
531
  response.appendResponseLine(`❌ Error: ${error instanceof Error ? error.message : String(error)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrome-devtools-mcp-for-extension",
3
- "version": "0.8.7",
3
+ "version": "0.8.8",
4
4
  "description": "MCP server for Chrome extension development with Web Store automation. Fork of chrome-devtools-mcp with extension-specific tools.",
5
5
  "type": "module",
6
6
  "bin": "./build/src/index.js",