browser_network_requests
Capture network requests during web page interactions to monitor API calls and resource loading for debugging and analysis purposes.
Instructions
Returns all network requests since loading the page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| includeStatic | No | Whether to include successful static resources like images, fonts, scripts, etc. Defaults to false. |
Implementation Reference
- src/tools/network.ts:33-46 (handler)The main handler function for the 'browser_network_requests' tool. It retrieves network requests from the current browser tab, formats them using renderRequest, and returns a textual log via an action.handle: async context => { const requests = context.currentTabOrDie().requests(); const log = [...requests.entries()].map(([request, response]) => renderRequest(request, response)).join('\n'); return { code: [`// <internal code to list network requests>`], action: async () => { return { content: [{ type: 'text', text: log }] }; }, captureSnapshot: false, waitForNetwork: false, }; },
- src/tools/network.ts:25-31 (schema)Input/output schema definition for the tool, specifying name, title, description, empty input schema, and readOnly type.schema: { name: 'browser_network_requests', title: 'List network requests', description: 'Returns all network requests since loading the page', inputSchema: z.object({}), type: 'readOnly', },
- src/tools/network.ts:57-59 (registration)Exports the defined tool for registration in the MCP system.export default [ requests, ];
- src/tools/network.ts:22-47 (registration)Defines the tool using defineTool, including schema and handler.const requests = defineTool({ capability: 'core', schema: { name: 'browser_network_requests', title: 'List network requests', description: 'Returns all network requests since loading the page', inputSchema: z.object({}), type: 'readOnly', }, handle: async context => { const requests = context.currentTabOrDie().requests(); const log = [...requests.entries()].map(([request, response]) => renderRequest(request, response)).join('\n'); return { code: [`// <internal code to list network requests>`], action: async () => { return { content: [{ type: 'text', text: log }] }; }, captureSnapshot: false, waitForNetwork: false, }; }, });
- src/tools/network.ts:49-55 (helper)Helper function to format a network request and optional response into a string.function renderRequest(request: playwright.Request, response: playwright.Response | null) { const result: string[] = []; result.push(`[${request.method().toUpperCase()}] ${request.url()}`); if (response) result.push(`=> [${response.status()}] ${response.statusText()}`); return result.join(' '); }