Skip to main content
Glama

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, });

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