browser_network_requests
Capture and analyze all network requests initiated after a page loads, enabling detailed monitoring and debugging of web activity within browser automation workflows.
Instructions
Returns all network requests since loading the page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/network.ts:33-46 (handler)The main handler function that executes the tool: retrieves all network requests from the current browser tab, renders them using renderRequest helper, and returns a structured response with the log as text content.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)Schema definition for the tool, including name, title, description, empty input schema (no parameters), 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.ts:35-50 (registration)Registration of the network tool (via ...network) in the snapshotTools array, which aggregates tools for snapshot context.export const snapshotTools: Tool<any>[] = [ ...common(true), ...console, ...dialogs(true), ...files(true), ...install, ...keyboard(true), ...navigate(true), ...network, ...pdf, ...screenshot, ...snapshot, ...tabs(true), ...testing, ...wait(true), ];
- src/tools.ts:52-66 (registration)Registration of the network tool (via ...network) in the visionTools array, which aggregates tools for vision context.export const visionTools: Tool<any>[] = [ ...common(false), ...console, ...dialogs(false), ...files(false), ...install, ...keyboard(false), ...navigate(false), ...network, ...pdf, ...tabs(false), ...testing, ...vision, ...wait(false), ];
- src/tools/network.ts:49-55 (helper)Helper function used by the handler to format individual network request and response into a readable 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(' '); }