File tree Expand file tree Collapse file tree 5 files changed +16
-36
lines changed Expand file tree Collapse file tree 5 files changed +16
-36
lines changed Original file line number Diff line number Diff line change @@ -329,15 +329,6 @@ 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- }
340-
341332 const networkConditions = context . getNetworkConditions ( ) ;
342333 if ( networkConditions ) {
343334 response . push ( `## Network emulation` ) ;
Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ 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' ;
2524import * as emulationTools from './tools/emulation.js' ;
2625import * as inputTools from './tools/input.js' ;
2726import * as networkTools from './tools/network.js' ;
@@ -170,7 +169,6 @@ function registerTool(tool: ToolDefinition): void {
170169
171170const tools = [
172171 ...Object . values ( consoleTools ) ,
173- ...Object . values ( devtoolsTools ) ,
174172 ...Object . values ( emulationTools ) ,
175173 ...Object . values ( inputTools ) ,
176174 ...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 > (
Load Diff This file was deleted.
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