@@ -42,6 +42,7 @@ interface TraceInsightData {
4242export class McpResponse implements Response {
4343 #includePages = false ;
4444 #includeExtensionServiceWorkers = false ;
45+ #includeExtensionPages = false ;
4546 #snapshotParams?: SnapshotParams ;
4647 #attachedNetworkRequestId?: number ;
4748 #attachedNetworkRequestOptions?: {
@@ -94,6 +95,7 @@ export class McpResponse implements Response {
9495
9596 if ( this . #args. categoryExtensions ) {
9697 this . #includeExtensionServiceWorkers = value ;
98+ this . #includeExtensionPages = value ;
9799 }
98100 }
99101
@@ -501,6 +503,7 @@ export class McpResponse implements Response {
501503 pages ?: object [ ] ;
502504 pagination ?: object ;
503505 extensionServiceWorkers ?: object [ ] ;
506+ extensionPages ?: object [ ] ;
504507 } = { } ;
505508
506509 const response = [ `# ${ toolName } response` ] ;
@@ -564,38 +567,66 @@ Call ${handleDialog.name} to handle it before continuing.`);
564567 }
565568
566569 if ( this . #includePages) {
567- const parts = [ `## Pages` ] ;
568- for ( const page of context . getPages ( ) ) {
569- const isolatedContextName = context . getIsolatedContextName ( page ) ;
570- const contextLabel = isolatedContextName
571- ? ` isolatedContext=${ isolatedContextName } `
572- : '' ;
573- parts . push (
574- `${ context . getPageId ( page ) } : ${ page . url ( ) } ${ context . isPageSelected ( page ) ? ' [selected]' : '' } ${ contextLabel } ` ,
575- ) ;
570+ const allPages = context . getPages ( ) ;
571+ const regularPages = this . #includeExtensionPages
572+ ? allPages . filter ( p => ! p . url ( ) . startsWith ( 'chrome-extension://' ) )
573+ : allPages ;
574+
575+ if ( regularPages . length ) {
576+ const parts = [ `## Pages` ] ;
577+ for ( const page of regularPages ) {
578+ const isolatedContextName = context . getIsolatedContextName ( page ) ;
579+ const contextLabel = isolatedContextName
580+ ? ` isolatedContext=${ isolatedContextName } `
581+ : '' ;
582+ parts . push (
583+ `${ context . getPageId ( page ) } : ${ page . url ( ) } ${ context . isPageSelected ( page ) ? ' [selected]' : '' } ${ contextLabel } ` ,
584+ ) ;
585+ }
586+ response . push ( ...parts ) ;
587+ structuredContent . pages = regularPages . map ( page => {
588+ const isolatedContextName = context . getIsolatedContextName ( page ) ;
589+ const entry : {
590+ id : number | undefined ;
591+ url : string ;
592+ selected : boolean ;
593+ isolatedContext ?: string ;
594+ } = {
595+ id : context . getPageId ( page ) ,
596+ url : page . url ( ) ,
597+ selected : context . isPageSelected ( page ) ,
598+ } ;
599+ if ( isolatedContextName ) {
600+ entry . isolatedContext = isolatedContextName ;
601+ }
602+ return entry ;
603+ } ) ;
576604 }
577- response . push ( ...parts ) ;
578- structuredContent . pages = context . getPages ( ) . map ( page => {
579- const isolatedContextName = context . getIsolatedContextName ( page ) ;
580- const entry : {
581- id : number | undefined ;
582- url : string ;
583- selected : boolean ;
584- isolatedContext ?: string ;
585- } = {
586- id : context . getPageId ( page ) ,
587- url : page . url ( ) ,
588- selected : context . isPageSelected ( page ) ,
589- } ;
590- if ( isolatedContextName ) {
591- entry . isolatedContext = isolatedContextName ;
605+
606+ if ( this . #includeExtensionPages) {
607+ const extensionPages = allPages . filter ( p =>
608+ p . url ( ) . startsWith ( 'chrome-extension://' ) ,
609+ ) ;
610+ if ( extensionPages . length ) {
611+ response . push ( `## Extension Pages` ) ;
612+ for ( const page of extensionPages ) {
613+ response . push (
614+ `${ context . getPageId ( page ) } : ${ page . url ( ) } ${ context . isPageSelected ( page ) ? ' [selected]' : '' } ` ,
615+ ) ;
616+ }
617+ structuredContent . extensionPages = extensionPages . map ( page => {
618+ return {
619+ id : context . getPageId ( page ) ,
620+ url : page . url ( ) ,
621+ selected : context . isPageSelected ( page ) ,
622+ } ;
623+ } ) ;
592624 }
593- return entry ;
594- } ) ;
625+ }
595626 }
596627
597628 if ( this . #includeExtensionServiceWorkers) {
598- if ( ! context . getExtensionServiceWorkers ( ) . length ) {
629+ if ( context . getExtensionServiceWorkers ( ) . length ) {
599630 response . push ( `## Extension Service Workers` ) ;
600631 }
601632
0 commit comments