Skip to main content
Glama
andytango
by andytango

delete_cookies

Remove specific browser cookies by name to manage privacy, clear session data, or reset authentication states during automated browser testing.

Instructions

Delete cookies by name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namesYesCookie names to delete
tabIdNoTab ID to operate on (uses active tab if not specified)

Implementation Reference

  • The handler function that implements the delete_cookies tool. It retrieves the current page's cookies, filters those matching the provided names, and deletes them by overwriting with an expired cookie (empty value, expires=0).
    async ({ names, tabId }) => {
      const pageResult = await getPageForOperation(tabId);
      if (!pageResult.success) {
        return handleResult(pageResult);
      }
    
      const page = pageResult.data;
    
      try {
        // Get all cookies first
        const allCookies = await page.cookies();
    
        // Find cookies to delete
        const cookiesToDelete = allCookies.filter((cookie) =>
          names.includes(cookie.name)
        );
    
        // Delete each matching cookie
        const browserResult = await getBrowser();
        if (browserResult.success) {
          const context = browserResult.data.defaultBrowserContext();
    
          for (const cookie of cookiesToDelete) {
            await context.clearPermissionOverrides();
            // Delete by setting empty value and expired date
            await page.setCookie({
              name: cookie.name,
              value: '',
              domain: cookie.domain,
              path: cookie.path,
              expires: 0,
            });
          }
        }
    
        return handleResult(ok({
          deleted: cookiesToDelete.length,
          names: cookiesToDelete.map((c) => c.name),
        }));
      } catch (error) {
        return handleResult(err(normalizeError(error)));
      }
    }
  • The registration of the delete_cookies tool on the MCP server, specifying name, description, input schema, and handler function.
    server.tool(
      'delete_cookies',
      'Delete cookies by name',
      deleteCookiesSchema.shape,
  • Zod schema defining the input for delete_cookies tool: array of cookie names to delete and optional tabId.
    export const deleteCookiesSchema = z.object({
      names: z.array(z.string()).min(1).describe('Cookie names to delete'),
      tabId: tabIdSchema,
    });
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action ('Delete') which implies mutation, but doesn't describe side effects (e.g., whether deletion is permanent, if it affects browser state), authentication needs, rate limits, or error conditions. For a destructive operation with zero annotation coverage, this is inadequate.

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 with zero wasted words. It's front-loaded with the core action and immediately communicates the essential functionality. Every word earns its place.

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?

For a destructive tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after deletion (success/failure indicators), whether multiple cookies can be deleted atomically, or how it interacts with browser state. The agent lacks critical context for safe and effective 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?

Schema description coverage is 100%, with both parameters ('names' and 'tabId') clearly documented in the schema. The description adds no additional parameter semantics beyond what's already in the schema (e.g., format of cookie names, what happens if tabId is invalid). Baseline 3 is appropriate when schema does the heavy lifting.

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 ('Delete') and target resource ('cookies by name'), making the purpose immediately understandable. It distinguishes from sibling tools like 'set_cookies' and 'get_cookies' by specifying deletion rather than creation or retrieval. However, it doesn't explicitly mention the browser context or differentiate from other deletion tools, keeping it at 4 rather than 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 no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an active browser session), when not to use it, or how it relates to sibling tools like 'set_cookies' or 'get_cookies'. The agent must infer usage from the name and schema alone.

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