File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,11 +57,16 @@ export class McpResponse implements Response {
5757 includePreservedMessages ?: boolean ;
5858 } ;
5959 #devToolsData?: DevToolsData ;
60+ #tabId?: string ;
6061
6162 attachDevToolsData ( data : DevToolsData ) : void {
6263 this . #devToolsData = data ;
6364 }
6465
66+ setTabId ( tabId : string ) : void {
67+ this . #tabId = tabId ;
68+ }
69+
6570 setIncludePages ( value : boolean ) : void {
6671 this . #includePages = value ;
6772 }
@@ -398,8 +403,13 @@ Call ${handleDialog.name} to handle it before continuing.`);
398403 const structuredContent : {
399404 snapshot ?: object ;
400405 snapshotFilePath ?: string ;
406+ tabId ?: string ;
401407 } = { } ;
402408
409+ if ( this . #tabId) {
410+ structuredContent . tabId = this . #tabId;
411+ }
412+
403413 if ( data . snapshot ) {
404414 if ( typeof data . snapshot === 'string' ) {
405415 response . push ( `Saved snapshot to ${ data . snapshot } .` ) ;
Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ export interface Response {
7777 attachConsoleMessage ( msgid : number ) : void ;
7878 // Allows re-using DevTools data queried by some tools.
7979 attachDevToolsData ( data : DevToolsData ) : void ;
80+ setTabId ( tabId : string ) : void ;
8081}
8182
8283/**
Original file line number Diff line number Diff line change @@ -289,6 +289,6 @@ export const getTabId = defineTool({
289289 const page = context . getPageById ( request . params . pageId ) ;
290290 // @ts -expect-error _tabId is internal.
291291 const tabId = page . _tabId ;
292- response . appendResponseLine ( tabId ) ;
292+ response . setTabId ( tabId ) ;
293293 } ,
294294} ) ;
Original file line number Diff line number Diff line change @@ -102,7 +102,9 @@ describe('e2e', () => {
102102 continue ;
103103 }
104104 if (
105- maybeTool . annotations ?. conditions ?. includes ( 'experimentalInteropTools' )
105+ maybeTool . annotations ?. conditions ?. includes (
106+ 'experimentalInteropTools' ,
107+ )
106108 ) {
107109 continue ;
108110 }
@@ -126,7 +128,6 @@ describe('e2e', () => {
126128 ) ;
127129 } ) ;
128130
129-
130131 it ( 'has experimental interop tools' , async ( ) => {
131132 await withClient (
132133 async client => {
Original file line number Diff line number Diff line change @@ -329,9 +329,18 @@ describe('pages', () => {
329329 await withMcpContext ( async ( response , context ) => {
330330 const page = context . getSelectedPage ( ) ;
331331 // @ts -expect-error _tabId is internal.
332+ assert . ok ( typeof page . _tabId === 'string' ) ;
333+ // @ts -expect-error _tabId is internal.
332334 page . _tabId = 'test-tab-id' ;
333- await getTabId . handler ( { params : { pageId : 1 } } , response , context ) ;
334- assert . ok ( response . responseLines . includes ( 'test-tab-id' ) ) ;
335+ await getTabId . handler (
336+ { params : { pageId : 1 } } ,
337+ response ,
338+ context ,
339+ ) ;
340+ const result = await response . handle ( 'get_tab_id' , context ) ;
341+ // @ts -expect-error _tabId is internal.
342+ assert . strictEqual ( result . structuredContent . tabId , 'test-tab-id' ) ;
343+ assert . deepStrictEqual ( response . responseLines , [ ] ) ;
335344 } ) ;
336345 } ) ;
337346 } ) ;
You can’t perform that action at this time.
0 commit comments