Skip to main content
Glama

reset_browser_data

Clear browser cookies, cache, localStorage, and sessionStorage to reset browser state for testing consent management platforms.

Instructions

Reset browser data including cookies, cache, localStorage, and sessionStorage

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clearCookiesNoClear browser cookies (default: true)
clearCacheNoClear browser cache (default: true)
clearLocalStorageNoClear localStorage (default: true)
clearSessionStorageNoClear sessionStorage (default: true)

Implementation Reference

  • The core handler function that implements the reset_browser_data tool logic, clearing cookies, cache, localStorage, and sessionStorage using Puppeteer's CDP session and page.evaluate.
    export async function resetBrowserData( page: Page, options: BrowserResetOptions = { clearCookies: true, clearCache: true, clearLocalStorage: true, clearSessionStorage: true, }, ): Promise<void> { const client = await page.target().createCDPSession(); // Clear cookies if (options.clearCookies) { await client.send("Network.clearBrowserCookies"); } // Clear browser cache if (options.clearCache) { await client.send("Network.clearBrowserCache"); } // Clear localStorage and sessionStorage if (options.clearLocalStorage || options.clearSessionStorage) { await page.evaluate((opts) => { if (opts.clearLocalStorage && typeof localStorage !== "undefined") { localStorage.clear(); } if (opts.clearSessionStorage && typeof sessionStorage !== "undefined") { sessionStorage.clear(); } }, options); } }
  • Type definition for the options parameter used in resetBrowserData, matching the tool's inputSchema.
    export type BrowserResetOptions = { clearCookies?: boolean; clearCache?: boolean; clearLocalStorage?: boolean; clearSessionStorage?: boolean; };
  • src/index.ts:143-169 (registration)
    Registration of the reset_browser_data tool in the TOOLS array, including name, description, and inputSchema.
    { name: "reset_browser_data", description: "Reset browser data including cookies, cache, localStorage, and sessionStorage", inputSchema: { type: "object", properties: { clearCookies: { type: "boolean", description: "Clear browser cookies (default: true)", }, clearCache: { type: "boolean", description: "Clear browser cache (default: true)", }, clearLocalStorage: { type: "boolean", description: "Clear localStorage (default: true)", }, clearSessionStorage: { type: "boolean", description: "Clear sessionStorage (default: true)", }, }, required: [], }, },
  • Wrapper handler in the main tool dispatch switch (handleToolCall) that processes arguments and calls the resetBrowserData function.
    case "reset_browser_data": try { const options = { clearCookies: args.clearCookies ?? true, clearCache: args.clearCache ?? true, clearLocalStorage: args.clearLocalStorage ?? true, clearSessionStorage: args.clearSessionStorage ?? true, }; await resetBrowserData(page, options); const clearedItems = []; if (options.clearCookies) clearedItems.push("cookies"); if (options.clearCache) clearedItems.push("cache"); if (options.clearLocalStorage) clearedItems.push("localStorage"); if (options.clearSessionStorage) clearedItems.push("sessionStorage"); return { content: [ { type: "text", text: `Successfully cleared: ${clearedItems.join(", ")}`, }, ], isError: false, }; } catch (error) { return { content: [ { type: "text", text: `Failed to reset browser data: ${(error as Error).message}`, }, ], isError: true, }; }

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/noisysocks/autoconsent-mcp'

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