android_devtools_capture_network
Capture network requests made by a page running on the device over a time window via CDP. Enables the Network domain and collects request/response/loadingFinished/loadingFailed events. LIVE-WINDOW collector: only captures requests made AFTER it attaches — to capture a navigation/reload/fetch, pass triggerJs (fired inside the window) rather than triggering it from a separate tool call (which races the attach and returns 0 records). Returns { records, bodiesOmitted? } in summary format, or a HAR 1.2 document when format="har". Each record: { requestId, method, url, requestHeaders?, status?, statusText?, mimeType?, resourceType?, responseHeaders?, encodedDataLength?, state, errorText?, startTimestamp?, endTimestamp?, body?, bodyTruncated?, bodyError? }. Set includeBodies=true to fetch response bodies for completed text-like responses (json|text|xml|javascript|html|css|svg|x-www-form-urlencoded); per-body cap: 10 000 chars (bodyTruncated=true when hit); total cap: 200 000 chars (excess records counted in bodiesOmitted). Body fetch failures set bodyError on that record. Set throttle to emulate network conditions for the capture window only (cleared in a finally block): slow-3g (latency 2000ms, 400kbps down/up), fast-3g (latency 563ms, 1.6Mbps down / 750kbps up), offline. When throttle was active, a top-level throttle field appears in the output. Set blockUrls (URL patterns) to block matching requests, or extraHeaders to inject request headers (e.g. Authorization), for the capture window only — both cleared afterward. Returns at most limit records (default 100, most-recent first) so heavy pages stay within the token budget — filter with urlSubstring / onlyErrors; total/returned appear when records were dropped. Default window: 5 000 ms. Maximum: 30 000 ms. Omit pageId to auto-select the visible/active page.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| udid | Yes | Device serial number (UDID) | |
| limit | No | Max records to return, most-recent first (default 100). Heavy pages make hundreds of requests; the default keeps the response within the MCP token budget. total/returned are included when records were dropped. | |
| format | No | Output format: "summary" (default) returns { records, bodiesOmitted? }; "har" returns a HAR 1.2 document | |
| pageId | No | Target page id (auto-picked when omitted) | |
| socket | No | Abstract unix socket name (default: chrome_devtools_remote) | |
| throttle | No | Emulate network conditions for the capture window only (cleared in a finally block). slow-3g: latency 2000ms, 400kbps down/up. fast-3g: latency 563ms, 1.6Mbps down / 750kbps up. offline: no connectivity. | |
| blockUrls | No | Block requests whose URL matches any of these patterns (wildcards allowed, e.g. "*.doubleclick.net", "*/analytics*") for the capture window ONLY (cleared afterward). Blocked requests surface as failed. Use to capture without third-party/analytics noise. | |
| triggerJs | No | JavaScript run INSIDE the capture window (right after the collector attaches) so the requests it triggers are captured race-free — e.g. "location.reload()", "location.href='https://example.com'", or "fetch('/api/x')". Prefer this over navigating/reloading from a separate tool call, which races the collector attach and yields 0 records. | |
| durationMs | No | Collection window in milliseconds (default: 5000, max: 30000) | |
| onlyErrors | No | Only failed / 5xx records | |
| extraHeaders | No | Extra HTTP headers added to every request for the capture window ONLY (cleared afterward), e.g. { "Authorization": "Bearer …" } to capture authenticated requests. These are session-scoped, which is why they apply only during this capture. | |
| urlSubstring | No | Only records whose URL contains this substring — target the requests you care about | |
| includeBodies | No | Fetch response body for completed text-like responses (default: true). Request bodies (postData) are always captured. Set false to skip response bodies for a lighter payload. Per-body cap: 10 000 chars. Total cap: 200 000 chars. |