Skip to main content
Glama
andytango
by andytango

get_cookies

Retrieve browser cookies from the current page or specified URLs to enable session management and authentication for automated web interactions.

Instructions

Get cookies for the current page or specified URLs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlsNoURLs to get cookies for (uses current page URL if not specified)
tabIdNoTab ID to operate on (uses active tab if not specified)

Implementation Reference

  • The handler function for the get_cookies tool. It retrieves the page for the given tabId, fetches cookies using Puppeteer's page.cookies() method for specified URLs or current page, maps the cookies to a standardized output format, and handles errors appropriately.
    async ({ urls, tabId }) => {
      const pageResult = await getPageForOperation(tabId);
      if (!pageResult.success) {
        return handleResult(pageResult);
      }
    
      const page = pageResult.data;
    
      try {
        const cookies = await page.cookies(...(urls ?? []));
    
        return handleResult(ok({
          cookies: cookies.map((cookie) => ({
            name: cookie.name,
            value: cookie.value,
            domain: cookie.domain,
            path: cookie.path,
            expires: cookie.expires,
            httpOnly: cookie.httpOnly,
            secure: cookie.secure,
            sameSite: cookie.sameSite,
          })),
        }));
      } catch (error) {
        return handleResult(err(normalizeError(error)));
      }
  • Zod schema defining the input parameters for the get_cookies tool: optional array of URLs and optional tabId.
    export const getCookiesSchema = z.object({
      urls: z.array(z.string().url()).optional().describe('URLs to get cookies for (uses current page URL if not specified)'),
      tabId: tabIdSchema,
    });
  • Registers the get_cookies tool on the MCP server, providing the tool name, description, input schema, and handler function.
    server.tool(
      'get_cookies',
      'Get cookies for the current page or specified URLs',
      getCookiesSchema.shape,
      async ({ urls, tabId }) => {
        const pageResult = await getPageForOperation(tabId);
        if (!pageResult.success) {
          return handleResult(pageResult);
        }
    
        const page = pageResult.data;
    
        try {
          const cookies = await page.cookies(...(urls ?? []));
    
          return handleResult(ok({
            cookies: cookies.map((cookie) => ({
              name: cookie.name,
              value: cookie.value,
              domain: cookie.domain,
              path: cookie.path,
              expires: cookie.expires,
              httpOnly: cookie.httpOnly,
              secure: cookie.secure,
              sameSite: cookie.sameSite,
            })),
          }));
        } catch (error) {
          return handleResult(err(normalizeError(error)));
        }
      }
    );
  • src/server.ts:28-28 (registration)
    Calls registerCookiesTools to register the cookies tools including get_cookies on the main MCP server instance.
    registerCookiesTools(server);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but lacks details on permissions needed, rate limits, whether it returns all cookies or specific types, or how errors are handled. This is insufficient for a tool that interacts with browser data.

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, efficient sentence that directly states the tool's purpose and scope without any unnecessary words. It's front-loaded and appropriately sized for its function.

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

Completeness2/5

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

Given the complexity of browser cookie retrieval, no annotations, and no output schema, the description is incomplete. It doesn't explain what the output looks like (e.g., cookie objects with attributes), potential security considerations, or error cases, leaving significant gaps for an AI agent.

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?

The input schema has 100% description coverage, clearly documenting both parameters ('urls' and 'tabId') with their purposes and default behaviors. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline score of 3.

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

Purpose4/5

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

The description clearly states the action ('Get') and resource ('cookies'), specifying it can target the current page or specified URLs. However, it doesn't explicitly differentiate from sibling tools like 'delete_cookies' or 'set_cookies' beyond the verb difference, which is why it doesn't reach a 5.

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

Usage Guidelines2/5

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

The description provides minimal guidance by mentioning the default behavior (current page if no URLs specified), but it doesn't explain when to use this tool versus alternatives like 'delete_cookies' or 'set_cookies', nor does it outline any prerequisites or exclusions for usage.

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/andytango/puppeteer-mcp'

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