browser_network_requests
Capture and analyze all network requests made after a page loads, enabling detailed monitoring of web activity for debugging or optimization purposes using Playwright automation.
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)Handler function that fetches network requests from the current browser tab, formats them into a log string using the renderRequest helper, and returns an action to display the log as text content without capturing snapshot or waiting for network.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)Tool schema defining 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/network.ts:49-55 (helper)Helper function to format a network request and optional 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(' '); }
- src/tools/network.ts:57-59 (registration)Exports the defined tool for inclusion in tool arrays.export default [ requests, ];
- src/tools.ts:36-52 (registration)Registers the network tool (via ...network spread) into the snapshotTools array used for MCP tool registration.export const snapshotTools: Tool<any>[] = [ ...common(true), ...console, ...dialogs(true), ...files(true), ...install, ...keyboard(true), ...navigate(true), ...network, ...pdf, ...screenshot, ...snapshot, ...tabs(true), ...testing, ...video, ...wait(true), ];