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

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: `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.`,
451
+ description: `Select an already-opened Chrome extension popup window for testing. If no extension name is provided, it will automatically detect and select the currently active popup window. If an extension name is provided, it will search for that specific extension's popup. 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,
@@ -456,12 +456,46 @@ export const openExtensionPopup = defineTool({
456
456
  schema: {
457
457
  extensionName: z
458
458
  .string()
459
- .describe('The name or partial name of the extension'),
459
+ .optional()
460
+ .describe('(Optional) The name or partial name of the extension. If omitted, will use the currently active popup.'),
460
461
  },
461
462
  handler: async (request, response, context) => {
462
463
  const page = context.getSelectedPage();
463
464
  const { extensionName } = request.params;
464
465
  await context.waitForEventsAfterAction(async () => {
466
+ const browser = page.browser();
467
+ if (!browser) {
468
+ response.appendResponseLine('❌ Failed to get browser instance.');
469
+ return;
470
+ }
471
+ // If no extension name provided, check if current page is already a popup
472
+ if (!extensionName) {
473
+ const currentUrl = page.url();
474
+ if (currentUrl.startsWith('chrome-extension://')) {
475
+ response.appendResponseLine('✅ Already on an extension popup window');
476
+ response.appendResponseLine(`📄 Popup URL: ${currentUrl}`);
477
+ response.appendResponseLine('');
478
+ response.appendResponseLine('💡 You can now use take_snapshot, click, evaluate_script, etc. on the popup');
479
+ return;
480
+ }
481
+ // If not on popup, try to find any open popup
482
+ const pages = await browser.pages();
483
+ for (let i = 0; i < pages.length; i++) {
484
+ const p = pages[i];
485
+ const url = p.url();
486
+ if (url.startsWith('chrome-extension://')) {
487
+ context.setSelectedPageIdx(i);
488
+ response.appendResponseLine('✅ Found and selected open popup window');
489
+ response.appendResponseLine(`📄 Popup URL: ${url}`);
490
+ response.appendResponseLine('');
491
+ response.appendResponseLine('💡 You can now use take_snapshot, click, evaluate_script, etc. on the popup');
492
+ return;
493
+ }
494
+ }
495
+ response.appendResponseLine('❌ No extension popup window found.');
496
+ response.appendResponseLine('💡 Please manually click the extension icon to open the popup first.');
497
+ return;
498
+ }
465
499
  // First, get extension ID
466
500
  await page.goto('chrome://extensions/', { waitUntil: 'networkidle0' });
467
501
  const extensionInfo = await page.evaluate((searchName) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrome-devtools-mcp-for-extension",
3
- "version": "0.8.8",
3
+ "version": "0.8.9",
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",