chrome-devtools-mcp 0.19.0 → 0.20.0
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/README.md +2 -2
- package/build/src/McpContext.js +27 -0
- package/build/src/McpResponse.js +51 -19
- package/build/src/bin/chrome-devtools-cli-options.js +651 -0
- package/build/src/{cli.js → bin/chrome-devtools-mcp-cli-options.js} +1 -1
- package/build/src/{main.js → bin/chrome-devtools-mcp-main.js} +7 -7
- package/build/src/bin/chrome-devtools-mcp.js +21 -0
- package/build/src/bin/chrome-devtools.js +4 -3
- package/build/src/bin/cliDefinitions.js +0 -36
- package/build/src/browser.js +8 -9
- package/build/src/daemon/client.js +1 -0
- package/build/src/daemon/daemon.js +7 -2
- package/build/src/daemon/utils.js +1 -1
- package/build/src/index.js +204 -16
- package/build/src/third_party/THIRD_PARTY_NOTICES +1 -1
- package/build/src/third_party/bundled-packages.json +2 -2
- package/build/src/third_party/devtools-formatter-worker.js +0 -1
- package/build/src/third_party/index.js +152 -80
- package/build/src/third_party/issue-descriptions/selectivePermissionsIntervention.md +7 -0
- package/build/src/version.js +1 -1
- package/package.json +8 -5
- package/build/src/server.js +0 -209
package/README.md
CHANGED
|
@@ -122,7 +122,7 @@ To use the Chrome DevTools MCP server follow the instructions from <a href="http
|
|
|
122
122
|
|
|
123
123
|
This will make the Chrome DevTools MCP server automatically connect to the browser that Antigravity is using. If you are not using port 9222, make sure to adjust accordingly.
|
|
124
124
|
|
|
125
|
-
Chrome DevTools MCP will not start the browser instance automatically using this approach
|
|
125
|
+
Chrome DevTools MCP will not start the browser instance automatically using this approach because the Chrome DevTools MCP server connects to Antigravity's built-in browser. If the browser is not already running, you have to start it first by clicking the Chrome icon at the top right corner.
|
|
126
126
|
|
|
127
127
|
</details>
|
|
128
128
|
|
|
@@ -358,7 +358,7 @@ Alternatively, follow the <a href="https://docs.qoder.com/user-guide/chat/model-
|
|
|
358
358
|
<details>
|
|
359
359
|
<summary>Qoder CLI</summary>
|
|
360
360
|
|
|
361
|
-
Install the Chrome DevTools MCP server using the Qoder CLI (<a href="https://docs.qoder.com/cli/using-cli#mcp-
|
|
361
|
+
Install the Chrome DevTools MCP server using the Qoder CLI (<a href="https://docs.qoder.com/cli/using-cli#mcp-servers">guide</a>):
|
|
362
362
|
|
|
363
363
|
**Project wide:**
|
|
364
364
|
|
package/build/src/McpContext.js
CHANGED
|
@@ -49,6 +49,7 @@ export class McpContext {
|
|
|
49
49
|
#isRunningTrace = false;
|
|
50
50
|
#screenRecorderData = null;
|
|
51
51
|
#nextPageId = 1;
|
|
52
|
+
#extensionPages = new WeakMap();
|
|
52
53
|
#extensionServiceWorkerMap = new WeakMap();
|
|
53
54
|
#nextExtensionServiceWorkerId = 1;
|
|
54
55
|
#nextSnapshotId = 1;
|
|
@@ -411,6 +412,32 @@ export class McpContext {
|
|
|
411
412
|
async #getAllPages() {
|
|
412
413
|
const defaultCtx = this.browser.defaultBrowserContext();
|
|
413
414
|
const allPages = await this.browser.pages(this.#options.experimentalIncludeAllPages);
|
|
415
|
+
const allTargets = this.browser.targets();
|
|
416
|
+
const extensionTargets = allTargets.filter(target => {
|
|
417
|
+
return (target.url().startsWith('chrome-extension://') &&
|
|
418
|
+
target.type() === 'page');
|
|
419
|
+
});
|
|
420
|
+
for (const target of extensionTargets) {
|
|
421
|
+
// Right now target.page() returns null for popup and side panel pages.
|
|
422
|
+
let page = await target.page();
|
|
423
|
+
if (!page) {
|
|
424
|
+
// We need to cache pages instances for targets because target.asPage()
|
|
425
|
+
// returns a new page instance every time.
|
|
426
|
+
page = this.#extensionPages.get(target) ?? null;
|
|
427
|
+
if (!page) {
|
|
428
|
+
try {
|
|
429
|
+
page = await target.asPage();
|
|
430
|
+
this.#extensionPages.set(target, page);
|
|
431
|
+
}
|
|
432
|
+
catch (e) {
|
|
433
|
+
this.logger('Failed to get page for extension target', e);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
if (page && !allPages.includes(page)) {
|
|
438
|
+
allPages.push(page);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
414
441
|
// Build a reverse lookup from BrowserContext instance → name.
|
|
415
442
|
const contextToName = new Map();
|
|
416
443
|
for (const [name, ctx] of this.#isolatedContexts) {
|
package/build/src/McpResponse.js
CHANGED
|
@@ -15,6 +15,7 @@ import { paginate } from './utils/pagination.js';
|
|
|
15
15
|
export class McpResponse {
|
|
16
16
|
#includePages = false;
|
|
17
17
|
#includeExtensionServiceWorkers = false;
|
|
18
|
+
#includeExtensionPages = false;
|
|
18
19
|
#snapshotParams;
|
|
19
20
|
#attachedNetworkRequestId;
|
|
20
21
|
#attachedNetworkRequestOptions;
|
|
@@ -47,6 +48,7 @@ export class McpResponse {
|
|
|
47
48
|
this.#includePages = value;
|
|
48
49
|
if (this.#args.categoryExtensions) {
|
|
49
50
|
this.#includeExtensionServiceWorkers = value;
|
|
51
|
+
this.#includeExtensionPages = value;
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
includeSnapshot(params) {
|
|
@@ -358,27 +360,45 @@ Call ${handleDialog.name} to handle it before continuing.`);
|
|
|
358
360
|
};
|
|
359
361
|
}
|
|
360
362
|
if (this.#includePages) {
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
363
|
+
const allPages = context.getPages();
|
|
364
|
+
const { regularPages, extensionPages } = allPages.reduce((acc, page) => {
|
|
365
|
+
if (page.url().startsWith('chrome-extension://')) {
|
|
366
|
+
acc.extensionPages.push(page);
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
acc.regularPages.push(page);
|
|
370
|
+
}
|
|
371
|
+
return acc;
|
|
372
|
+
}, { regularPages: [], extensionPages: [] });
|
|
373
|
+
if (regularPages.length) {
|
|
374
|
+
const parts = [`## Pages`];
|
|
375
|
+
const structuredPages = [];
|
|
376
|
+
for (const page of regularPages) {
|
|
377
|
+
const isolatedContextName = context.getIsolatedContextName(page);
|
|
378
|
+
const contextLabel = isolatedContextName
|
|
379
|
+
? ` isolatedContext=${isolatedContextName}`
|
|
380
|
+
: '';
|
|
381
|
+
parts.push(`${context.getPageId(page)}: ${page.url()}${context.isPageSelected(page) ? ' [selected]' : ''}${contextLabel}`);
|
|
382
|
+
structuredPages.push(createStructuredPage(page, context));
|
|
383
|
+
}
|
|
384
|
+
response.push(...parts);
|
|
385
|
+
structuredContent.pages = structuredPages;
|
|
368
386
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
387
|
+
if (this.#includeExtensionPages) {
|
|
388
|
+
if (extensionPages.length) {
|
|
389
|
+
response.push(`## Extension Pages`);
|
|
390
|
+
const structuredExtensionPages = [];
|
|
391
|
+
for (const page of extensionPages) {
|
|
392
|
+
const isolatedContextName = context.getIsolatedContextName(page);
|
|
393
|
+
const contextLabel = isolatedContextName
|
|
394
|
+
? ` isolatedContext=${isolatedContextName}`
|
|
395
|
+
: '';
|
|
396
|
+
response.push(`${context.getPageId(page)}: ${page.url()}${context.isPageSelected(page) ? ' [selected]' : ''}${contextLabel}`);
|
|
397
|
+
structuredExtensionPages.push(createStructuredPage(page, context));
|
|
398
|
+
}
|
|
399
|
+
structuredContent.extensionPages = structuredExtensionPages;
|
|
379
400
|
}
|
|
380
|
-
|
|
381
|
-
});
|
|
401
|
+
}
|
|
382
402
|
}
|
|
383
403
|
if (this.#includeExtensionServiceWorkers) {
|
|
384
404
|
if (context.getExtensionServiceWorkers().length) {
|
|
@@ -560,3 +580,15 @@ Call ${handleDialog.name} to handle it before continuing.`);
|
|
|
560
580
|
this.#textResponseLines = [];
|
|
561
581
|
}
|
|
562
582
|
}
|
|
583
|
+
function createStructuredPage(page, context) {
|
|
584
|
+
const isolatedContextName = context.getIsolatedContextName(page);
|
|
585
|
+
const entry = {
|
|
586
|
+
id: context.getPageId(page),
|
|
587
|
+
url: page.url(),
|
|
588
|
+
selected: context.isPageSelected(page),
|
|
589
|
+
};
|
|
590
|
+
if (isolatedContextName) {
|
|
591
|
+
entry.isolatedContext = isolatedContextName;
|
|
592
|
+
}
|
|
593
|
+
return entry;
|
|
594
|
+
}
|