Launch Chromium with the extension loaded: const browser = await puppeteer.launch({ headless: false, args: ['--load-extension=/path/to/extension', '--disable-extensions-except=/path/to/extension'] })
List all targets: const targets = await browser.targets()
Find the service worker target: const swTarget = targets.find(t => t.type() === 'service_worker' && t.url().includes('chrome-extension://'))
Attach a CDP session: const swClient = await swTarget.createCDPSession()
Evaluate logic in the service worker: await swClient.send('Runtime.evaluate', { expression: 'self.registration.scope', returnByValue: true })
Listen for messages from the extension: swClient.on('Runtime.consoleAPICalled', (event) => console.log(event.args))
Known gotchas
Headless mode in Chromium blocks extension loading; you must use headless: false or the new --headless=new flag with certain Chromium versions that allow extension testing
Service worker targets only appear after the extension has been activated; add a small delay or poll browser.targets() until the service_worker target is present
Extension IDs are derived from the extension key or directory hash and are stable across runs only when the extension has a fixed key in its manifest
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp