File tree Expand file tree Collapse file tree 5 files changed +41
-28
lines changed Expand file tree Collapse file tree 5 files changed +41
-28
lines changed Original file line number Diff line number Diff line change @@ -329,14 +329,15 @@ export class McpResponse implements Response {
329329 response . push ( line ) ;
330330 }
331331
332- response . push ( '## Network requests inspected in DevTools' ) ;
333- if ( data . devToolsData ?. requestId ) {
334- response . push ( `Network request: reqid=${ data . devToolsData ?. requestId } ` ) ;
335- } else {
336- response . push (
337- `Nothing inspected right now. Call list_pages to check if anything is selected by the user in DevTools.` ,
338- ) ;
339- }
332+ // if (data.devToolsData?.requestId) {
333+ // response.push('## Network requests inspected in DevTools');
334+ // response.push(`Network request: reqid=${data.devToolsData?.requestId}`);
335+ // } else {
336+ // response.push('## Network requests inspected in DevTools');
337+ // response.push(
338+ // `Nothing inspected right now. Call list_pages to check if anything is selected by the user in DevTools.`,
339+ // );
340+ // }
340341
341342 const networkConditions = context . getNetworkConditions ( ) ;
342343 if ( networkConditions ) {
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ import {
2121} from './third_party/index.js' ;
2222import { ToolCategory } from './tools/categories.js' ;
2323import * as consoleTools from './tools/console.js' ;
24- import * as devtoolsTools from './tools/devtools.js' ;
24+ // import * as devtoolsTools from './tools/devtools.js';
2525import * as emulationTools from './tools/emulation.js' ;
2626import * as inputTools from './tools/input.js' ;
2727import * as networkTools from './tools/network.js' ;
@@ -170,7 +170,7 @@ function registerTool(tool: ToolDefinition): void {
170170
171171const tools = [
172172 ...Object . values ( consoleTools ) ,
173- ...Object . values ( devtoolsTools ) ,
173+ // ...Object.values(devtoolsTools),
174174 ...Object . values ( emulationTools ) ,
175175 ...Object . values ( inputTools ) ,
176176 ...Object . values ( networkTools ) ,
Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ export type Context = Readonly<{
103103 text : string ;
104104 timeout ?: number | undefined ;
105105 } ) : Promise < Element > ;
106+ getDevToolsData ( ) : Promise < undefined | { requestId ?: number } > ;
106107} > ;
107108
108109export function defineTool < Schema extends zod . ZodRawShape > (
Original file line number Diff line number Diff line change 44 * SPDX-License-Identifier: Apache-2.0
55 */
66
7- import { ToolCategory } from './categories.js' ;
8- import { defineTool } from './ToolDefinition.js' ;
7+ // import {ToolCategory} from './categories.js';
8+ // import {defineTool} from './ToolDefinition.js';
99
10- export const emulateNetwork = defineTool ( {
11- name : 'list_devtools_data' ,
12- description : `Returns data (network requests) that the user is currently inspecting in DevTools.` ,
13- annotations : {
14- category : ToolCategory . DEBUGGING ,
15- readOnlyHint : true ,
16- } ,
17- schema : { } ,
18- handler : async ( _request , response , _context ) => {
19- response . includeDevtoolsData ( true ) ;
20- } ,
21- } ) ;
10+ // export const listDevToolsData = defineTool({
11+ // name: 'list_devtools_data',
12+ // description: `Returns data (network requests) that the user is currently inspecting in DevTools.`,
13+ // annotations: {
14+ // category: ToolCategory.DEBUGGING,
15+ // readOnlyHint: true,
16+ // },
17+ // schema: {},
18+ // handler: async (_request, response, _context) => {
19+ // response.includeDevtoolsData(true);
20+ // },
21+ // });
Original file line number Diff line number Diff line change @@ -82,19 +82,30 @@ export const listNetworkRequests = defineTool({
8282
8383export const getNetworkRequest = defineTool ( {
8484 name : 'get_network_request' ,
85- description : `Gets a network request by URL. You can get all requests by calling ${ listNetworkRequests . name } .` ,
85+ description : `Gets a network request by reqid. You can get all requests by calling ${ listNetworkRequests . name } .
86+ Get the request currently selected in the DevTools UI by ommitting reqid` ,
8687 annotations : {
8788 category : ToolCategory . NETWORK ,
8889 readOnlyHint : true ,
8990 } ,
9091 schema : {
9192 reqid : zod
9293 . number ( )
94+ . optional ( )
9395 . describe (
94- 'The reqid of a request on the page from the listed network requests ' ,
96+ 'The reqid of the network request. If omitted, looks up the current request selected in DevTools UI. ' ,
9597 ) ,
9698 } ,
97- handler : async ( request , response , _context ) => {
98- response . attachNetworkRequest ( request . params . reqid ) ;
99+ handler : async ( request , response , context ) => {
100+ if ( request . params . reqid ) {
101+ response . attachNetworkRequest ( request . params . reqid ) ;
102+ } else {
103+ const data = await context . getDevToolsData ( ) ;
104+ if ( data ?. requestId ) {
105+ response . attachNetworkRequest ( data ?. requestId ) ;
106+ } else {
107+ response . appendResponseLine ( `Nothing is currently selected in DevTools UI.` )
108+ }
109+ }
99110 } ,
100111} ) ;
You can’t perform that action at this time.
0 commit comments