interceptor_chrome_devtools_list_cookies
List and filter browser cookies from Chrome DevTools sessions with pagination and value truncation for network traffic analysis and debugging.
Instructions
List browser cookies for the bound Chrome session with pagination and truncated values by default.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| devtools_session_id | Yes | Session ID from interceptor_chrome_devtools_attach | |
| url_filter | No | Filter cookies by domain/path substring | |
| domain_filter | No | Filter cookies by domain substring | |
| name_filter | No | Filter cookies by name substring | |
| offset | No | Offset into results (default: 0) | |
| limit | No | Max cookies to return (default: 50, max: 500) | |
| value_max_chars | No | Max characters for cookie value previews (default: 256) | |
| sort | No | Sort order (default: name) | name |
Implementation Reference
- src/tools/devtools.ts:780-881 (handler)Implementation of the 'interceptor_chrome_devtools_list_cookies' tool. It retrieves cookies for a specific DevTools session target and returns them with pagination and value truncation.
"interceptor_chrome_devtools_list_cookies", "List browser cookies for the bound Chrome session with pagination and truncated values by default.", { devtools_session_id: z.string().describe("Session ID from interceptor_chrome_devtools_attach"), url_filter: z.string().optional().describe("Filter cookies by domain/path substring"), domain_filter: z.string().optional().describe("Filter cookies by domain substring"), name_filter: z.string().optional().describe("Filter cookies by name substring"), offset: z.number().optional().default(0).describe("Offset into results (default: 0)"), limit: z.number().optional().default(DEFAULT_LIST_LIMIT).describe("Max cookies to return (default: 50, max: 500)"), value_max_chars: z.number().optional().default(DEFAULT_VALUE_MAX_CHARS) .describe("Max characters for cookie value previews (default: 256)"), sort: z.enum(["name", "domain", "expires"]).optional().default("name").describe("Sort order (default: name)"), }, async ({ devtools_session_id, url_filter, domain_filter, name_filter, offset, limit, value_max_chars, sort }) => { try { const session = devToolsBridge.getSession(devtools_session_id); if (!session) { return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: `DevTools session '${devtools_session_id}' not found.` }) }] }; } const { targetId } = await ensureSessionTargetIsAlive(devtools_session_id); const { pageUrl, wsUrl } = await getCdpPageEndpoint(targetId); const cookies = await cdpGetCookies(wsUrl, pageUrl); const urlNeedle = url_filter?.toLowerCase(); const domainNeedle = domain_filter?.toLowerCase(); const nameNeedle = name_filter?.toLowerCase(); const filtered = cookies.filter((c) => { const name = typeof c.name === "string" ? c.name : ""; const domain = typeof c.domain === "string" ? c.domain : ""; const path = typeof c.path === "string" ? c.path : ""; if (urlNeedle && !`${domain}${path}`.toLowerCase().includes(urlNeedle)) return false; if (domainNeedle && !domain.toLowerCase().includes(domainNeedle)) return false; if (nameNeedle && !name.toLowerCase().includes(nameNeedle)) return false; return true; }); const sorted = filtered.sort((a, b) => { const aName = typeof a.name === "string" ? a.name : ""; const bName = typeof b.name === "string" ? b.name : ""; const aDomain = typeof a.domain === "string" ? a.domain : ""; const bDomain = typeof b.domain === "string" ? b.domain : ""; const aExpires = typeof a.expires === "number" ? a.expires : 0; const bExpires = typeof b.expires === "number" ? b.expires : 0; switch (sort) { case "domain": return aDomain.localeCompare(bDomain) || aName.localeCompare(bName); case "expires": return aExpires - bExpires || aDomain.localeCompare(bDomain) || aName.localeCompare(bName); case "name": default: return aName.localeCompare(bName) || aDomain.localeCompare(bDomain); } }); const total = sorted.length; const o = normalizeOffset(offset); const l = normalizeLimit(limit); const page = sorted.slice(o, o + l); const valueCap = Math.max(0, Math.min(HARD_VALUE_CAP_CHARS, Math.trunc(value_max_chars ?? DEFAULT_VALUE_MAX_CHARS))); const summaries = page.map((c) => { const name = typeof c.name === "string" ? c.name : ""; const domain = typeof c.domain === "string" ? c.domain : ""; const path = typeof c.path === "string" ? c.path : ""; const value = typeof c.value === "string" ? c.value : ""; const capped = capValue(value, valueCap); return { cookie_id: cookieStableId(c), name, domain, path, expires: typeof c.expires === "number" ? c.expires : null, httpOnly: typeof c.httpOnly === "boolean" ? c.httpOnly : null, secure: typeof c.secure === "boolean" ? c.secure : null, sameSite: typeof c.sameSite === "string" ? c.sameSite : null, value_preview: capped.value, value_length: capped.valueLength, value_truncated: capped.truncated, }; }); return { content: [{ type: "text", text: truncateResult({ status: "success", devtools_session_id, target_id: targetId, total, offset: o, limit: l, showing: summaries.length, cookies: summaries, }), }], }; } catch (e) { return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: errorToString(e) }) }] }; } }, );