File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -168,6 +168,11 @@ export const cliOptions = {
168168 'Whether to include all kinds of pages such as webviews or background pages as pages.' ,
169169 hidden : true ,
170170 } ,
171+ experimentalInteropTools : {
172+ type : 'boolean' ,
173+ describe : 'Whether to enable interoperability tools' ,
174+ hidden : true ,
175+ } ,
171176 chromeArg : {
172177 type : 'array' ,
173178 describe :
Original file line number Diff line number Diff line change @@ -139,6 +139,12 @@ function registerTool(tool: ToolDefinition): void {
139139 ) {
140140 return ;
141141 }
142+ if (
143+ tool . annotations . conditions ?. includes ( 'experimentalInteropTools' ) &&
144+ ! args . experimentalInteropTools
145+ ) {
146+ return ;
147+ }
142148 server . registerTool (
143149 tool . name ,
144150 {
Original file line number Diff line number Diff line change @@ -269,3 +269,26 @@ export const handleDialog = defineTool({
269269 response . setIncludePages ( true ) ;
270270 } ,
271271} ) ;
272+
273+ export const getTabId = defineTool ( {
274+ name : 'get_tab_id' ,
275+ description : `Get the tab ID of the page` ,
276+ annotations : {
277+ category : ToolCategory . NAVIGATION ,
278+ readOnlyHint : true ,
279+ conditions : [ 'experimentalInteropTools' ] ,
280+ } ,
281+ schema : {
282+ pageId : zod
283+ . number ( )
284+ . describe (
285+ `The ID of the page to get the tab ID for. Call ${ listPages . name } to get available pages.` ,
286+ ) ,
287+ } ,
288+ handler : async ( request , response , context ) => {
289+ const page = context . getPageById ( request . params . pageId ) ;
290+ // @ts -expect-error _tabId is internal.
291+ const tabId = page . _tabId ;
292+ response . appendResponseLine ( tabId ) ;
293+ } ,
294+ } ) ;
Original file line number Diff line number Diff line change @@ -101,6 +101,11 @@ describe('e2e', () => {
101101 if ( maybeTool . annotations ?. conditions ?. includes ( 'computerVision' ) ) {
102102 continue ;
103103 }
104+ if (
105+ maybeTool . annotations ?. conditions ?. includes ( 'experimentalInteropTools' )
106+ ) {
107+ continue ;
108+ }
104109 definedNames . push ( maybeTool . name ) ;
105110 }
106111 }
@@ -120,4 +125,16 @@ describe('e2e', () => {
120125 [ '--experimental-vision' ] ,
121126 ) ;
122127 } ) ;
128+
129+
130+ it ( 'has experimental interop tools' , async ( ) => {
131+ await withClient (
132+ async client => {
133+ const { tools} = await client . listTools ( ) ;
134+ const getTabId = tools . find ( t => t . name === 'get_tab_id' ) ;
135+ assert . ok ( getTabId ) ;
136+ } ,
137+ [ '--experimental-interop-tools' ] ,
138+ ) ;
139+ } ) ;
123140} ) ;
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import {
1717 navigatePage ,
1818 resizePage ,
1919 handleDialog ,
20+ getTabId ,
2021} from '../../src/tools/pages.js' ;
2122import { withMcpContext } from '../utils.js' ;
2223
@@ -322,4 +323,16 @@ describe('pages', () => {
322323 } ) ;
323324 } ) ;
324325 } ) ;
326+
327+ describe ( 'get_tab_id' , ( ) => {
328+ it ( 'returns the tab id' , async ( ) => {
329+ await withMcpContext ( async ( response , context ) => {
330+ const page = context . getSelectedPage ( ) ;
331+ // @ts -expect-error _tabId is internal.
332+ page . _tabId = 'test-tab-id' ;
333+ await getTabId . handler ( { params : { pageId : 1 } } , response , context ) ;
334+ assert . ok ( response . responseLines . includes ( 'test-tab-id' ) ) ;
335+ } ) ;
336+ } ) ;
337+ } ) ;
325338} ) ;
You can’t perform that action at this time.
0 commit comments