Skip to main content
Glama

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
NameRequiredDescriptionDefault
devtools_session_idYesSession ID from interceptor_chrome_devtools_attach
url_filterNoFilter cookies by domain/path substring
domain_filterNoFilter cookies by domain substring
name_filterNoFilter cookies by name substring
offsetNoOffset into results (default: 0)
limitNoMax cookies to return (default: 50, max: 500)
value_max_charsNoMax characters for cookie value previews (default: 256)
sortNoSort order (default: name)name

Implementation Reference

  • 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) }) }] };
        }
      },
    );
Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yfe404/proxy-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server