@mcp-b/chrome-devtools-mcp 1.5.5 → 1.5.6
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/build/src/McpContext.js +20 -4
- package/build/src/main.js +1 -1
- package/build/src/tools/pages.js +2 -1
- package/package.json +1 -1
package/build/src/McpContext.js
CHANGED
|
@@ -75,6 +75,12 @@ export class McpContext {
|
|
|
75
75
|
#pageToDevToolsPage = new Map();
|
|
76
76
|
/** Currently selected page for tool operations. */
|
|
77
77
|
#selectedPage;
|
|
78
|
+
/**
|
|
79
|
+
* Whether the selected page has been explicitly set for this session.
|
|
80
|
+
* When true, createPagesSnapshot() won't auto-switch to pages[0].
|
|
81
|
+
* This prevents MCP sessions from interfering with each other in shared browsers.
|
|
82
|
+
*/
|
|
83
|
+
#pageExplicitlySelected = false;
|
|
78
84
|
/** Most recent accessibility snapshot of the selected page. */
|
|
79
85
|
#textSnapshot = null;
|
|
80
86
|
#networkCollector;
|
|
@@ -357,7 +363,8 @@ export class McpContext {
|
|
|
357
363
|
async newPage() {
|
|
358
364
|
const page = await this.browser.newPage();
|
|
359
365
|
await this.createPagesSnapshot();
|
|
360
|
-
this
|
|
366
|
+
// Mark as explicitly selected so this session sticks to this page
|
|
367
|
+
this.selectPage(page, true);
|
|
361
368
|
this.#networkCollector.addPage(page);
|
|
362
369
|
this.#consoleCollector.addPage(page);
|
|
363
370
|
// Set up WebMCP auto-detection for the new page
|
|
@@ -384,7 +391,8 @@ export class McpContext {
|
|
|
384
391
|
throw new Error('Failed to get page from new window target');
|
|
385
392
|
}
|
|
386
393
|
await this.createPagesSnapshot();
|
|
387
|
-
this
|
|
394
|
+
// Mark as explicitly selected so this session sticks to this window
|
|
395
|
+
this.selectPage(page, true);
|
|
388
396
|
this.#networkCollector.addPage(page);
|
|
389
397
|
this.#consoleCollector.addPage(page);
|
|
390
398
|
// Set up WebMCP auto-detection for the new page
|
|
@@ -473,12 +481,16 @@ export class McpContext {
|
|
|
473
481
|
isPageSelected(page) {
|
|
474
482
|
return this.#selectedPage === page;
|
|
475
483
|
}
|
|
476
|
-
selectPage(newPage) {
|
|
484
|
+
selectPage(newPage, explicit = false) {
|
|
477
485
|
const oldPage = this.#selectedPage;
|
|
478
486
|
if (oldPage) {
|
|
479
487
|
oldPage.off('dialog', this.#dialogHandler);
|
|
480
488
|
}
|
|
481
489
|
this.#selectedPage = newPage;
|
|
490
|
+
if (explicit) {
|
|
491
|
+
// Mark page as explicitly selected to prevent auto-switching
|
|
492
|
+
this.#pageExplicitlySelected = true;
|
|
493
|
+
}
|
|
482
494
|
newPage.on('dialog', this.#dialogHandler);
|
|
483
495
|
this.#updateSelectedPageTimeouts();
|
|
484
496
|
}
|
|
@@ -532,7 +544,11 @@ export class McpContext {
|
|
|
532
544
|
return (this.#options.experimentalDevToolsDebugging ||
|
|
533
545
|
!page.url().startsWith('devtools://'));
|
|
534
546
|
});
|
|
535
|
-
|
|
547
|
+
// Only auto-select pages[0] if:
|
|
548
|
+
// 1. No page has been explicitly selected for this session AND
|
|
549
|
+
// 2. Either there's no selected page OR the selected page is no longer valid
|
|
550
|
+
if (!this.#pageExplicitlySelected &&
|
|
551
|
+
(!this.#selectedPage || this.#pages.indexOf(this.#selectedPage) === -1) &&
|
|
536
552
|
this.#pages[0]) {
|
|
537
553
|
this.selectPage(this.#pages[0]);
|
|
538
554
|
}
|
package/build/src/main.js
CHANGED
|
@@ -22,7 +22,7 @@ import { WebMCPToolHub } from './tools/WebMCPToolHub.js';
|
|
|
22
22
|
* @remarks If moved, update release-please config.
|
|
23
23
|
*/
|
|
24
24
|
// x-release-please-start-version
|
|
25
|
-
const VERSION = '1.5.
|
|
25
|
+
const VERSION = '1.5.6';
|
|
26
26
|
// x-release-please-end
|
|
27
27
|
process.on('unhandledRejection', (reason, promise) => {
|
|
28
28
|
logger('Unhandled promise rejection', promise, reason);
|
package/build/src/tools/pages.js
CHANGED
|
@@ -37,7 +37,8 @@ export const selectPage = defineTool({
|
|
|
37
37
|
},
|
|
38
38
|
handler: async (request, response, context) => {
|
|
39
39
|
const page = context.getPageByIdx(request.params.pageIdx);
|
|
40
|
-
|
|
40
|
+
// Mark as explicitly selected so this session stays on this page
|
|
41
|
+
context.selectPage(page, true);
|
|
41
42
|
if (request.params.bringToFront) {
|
|
42
43
|
await page.bringToFront();
|
|
43
44
|
}
|