Skip to main content
Glama

interceptor_browser_get_cookie

Retrieve a browser cookie's full value by its cookie_id, with an adjustable character limit to control output size.

Instructions

Get one cookie by cookie_id with full value (subject to a hard cap to keep output bounded).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
target_idYesTarget ID from interceptor_browser_launch or interceptor_camoufox_launch
cookie_idYescookie_id from interceptor_browser_list_cookies
value_max_charsNoMax characters for cookie value (default: 20000)

Implementation Reference

  • Registration of the 'interceptor_browser_get_cookie' tool via server.tool() with schema and handler.
    server.tool(
      "interceptor_browser_get_cookie",
      "Get one cookie by cookie_id with full value (subject to a hard cap to keep output bounded).",
      {
        target_id: z.string().describe("Target ID from interceptor_browser_launch or interceptor_camoufox_launch"),
        cookie_id: z.string().describe("cookie_id from interceptor_browser_list_cookies"),
        value_max_chars: z.number().optional().default(HARD_VALUE_CAP_CHARS)
          .describe(`Max characters for cookie value (default: ${HARD_VALUE_CAP_CHARS})`),
      },
      async ({ target_id, cookie_id, value_max_chars }) => {
        try {
          const context = await getContextForTarget(target_id);
          const cookies = await context.cookies();
          const found = cookies.find((c) => cookieStableId(c) === cookie_id) ?? null;
          if (!found) {
            return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: `Cookie '${cookie_id}' not found. Re-run list tool.` }) }] };
          }
          const capped = capValue(found.value, Math.max(0, Math.min(HARD_VALUE_CAP_CHARS, Math.trunc(value_max_chars ?? HARD_VALUE_CAP_CHARS))));
          return {
            content: [{
              type: "text",
              text: truncateResult({
                status: "success",
                target_id,
                cookie_id,
                cookie: { ...found, value: capped.value },
                value_length: capped.valueLength,
                value_truncated: capped.truncated,
                value_max_chars: capped.maxChars,
              }),
            }],
          };
        } catch (e) {
          return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: errorToString(e) }) }] };
        }
      },
    );
  • Handler function for interceptor_browser_get_cookie: gets a BrowserContext for the target, retrieves all cookies, finds the one matching the cookie_id (using cookieStableId), caps its value, and returns it.
    async ({ target_id, cookie_id, value_max_chars }) => {
      try {
        const context = await getContextForTarget(target_id);
        const cookies = await context.cookies();
        const found = cookies.find((c) => cookieStableId(c) === cookie_id) ?? null;
        if (!found) {
          return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: `Cookie '${cookie_id}' not found. Re-run list tool.` }) }] };
        }
        const capped = capValue(found.value, Math.max(0, Math.min(HARD_VALUE_CAP_CHARS, Math.trunc(value_max_chars ?? HARD_VALUE_CAP_CHARS))));
        return {
          content: [{
            type: "text",
            text: truncateResult({
              status: "success",
              target_id,
              cookie_id,
              cookie: { ...found, value: capped.value },
              value_length: capped.valueLength,
              value_truncated: capped.truncated,
              value_max_chars: capped.maxChars,
            }),
          }],
        };
      } catch (e) {
        return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: errorToString(e) }) }] };
      }
    },
  • Input schema for interceptor_browser_get_cookie: target_id, cookie_id, and optional value_max_chars (defaults to HARD_VALUE_CAP_CHARS=20000).
    {
      target_id: z.string().describe("Target ID from interceptor_browser_launch or interceptor_camoufox_launch"),
      cookie_id: z.string().describe("cookie_id from interceptor_browser_list_cookies"),
      value_max_chars: z.number().optional().default(HARD_VALUE_CAP_CHARS)
        .describe(`Max characters for cookie value (default: ${HARD_VALUE_CAP_CHARS})`),
    },
  • cookieStableId helper function used to generate a stable SHA1-based identifier for a cookie, used both in list_cookies (to return cookie_id) and get_cookie (to look up by cookie_id).
    function cookieStableId(cookie: { name?: string; domain?: string; path?: string; secure?: boolean; httpOnly?: boolean; sameSite?: string; partitionKey?: string }): string {
      const parts = [
        cookie.name ?? "",
        cookie.domain ?? "",
        cookie.path ?? "",
        String(!!cookie.secure),
        String(!!cookie.httpOnly),
        cookie.sameSite ?? "",
        cookie.partitionKey ?? "",
      ];
      return `ck_${createHash("sha1").update(parts.join("|"), "utf8").digest("hex")}`;
    }
  • capValue helper function that truncates a string value to a maximum character count, appending '...' if truncated. Used to bound cookie values.
    function capValue(value: string, maxChars: number): { value: string; valueLength: number; truncated: boolean; maxChars: number } {
      const valueLength = value.length;
      const effectiveMax = Math.max(0, Math.min(HARD_VALUE_CAP_CHARS, Math.trunc(maxChars)));
      if (effectiveMax === 0) {
        return { value, valueLength, truncated: false, maxChars: 0 };
      }
      if (valueLength <= effectiveMax) {
        return { value, valueLength, truncated: false, maxChars: effectiveMax };
      }
      return { value: value.slice(0, effectiveMax) + "...", valueLength, truncated: true, maxChars: effectiveMax };
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description notes a 'hard cap to keep output bounded', which signals potential truncation, but lacks details on side effects, authentication needs, or error handling. Since no annotations are provided, the description should carry more behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with a parenthetical qualifier. It is concise and contains no superfluous information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 3 parameters, no output schema, and no annotations, the description covers the core purpose and a key behavioral constraint. It could mention what happens if the cookie_id is invalid or the cap is exceeded, but overall it is sufficient for basic use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

All three parameters are fully described in the input schema (100% coverage). The description adds a general note about the hard cap but does not elaborate on parameter-specific semantics beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Get one cookie by cookie_id', specifying the verb (get) and resource (cookie), and adds a constraint about a hard cap. It distinguishes from sibling tools like interceptor_browser_list_cookies which returns multiple cookies.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use when a specific cookie's full value is needed, but it does not explicitly state when to use this tool versus alternatives (e.g., list_cookies for multiple, or get_storage_value for other storage). No when-not or alternatives are given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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