Skip to main content
Glama

reset_browser_data

Clear browser cookies, cache, localStorage, and sessionStorage to reset browsing data. Facilitates browser automation and testing for Autoconsent rules in a controlled environment.

Instructions

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

Input Schema

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

Implementation Reference

  • Core handler function that executes the browser data reset logic using Puppeteer's CDP session to clear cookies and cache, and evaluate to clear storage.
    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); } }
  • TypeScript type definition for the input options of the resetBrowserData function.
    export type BrowserResetOptions = { clearCookies?: boolean; clearCache?: boolean; clearLocalStorage?: boolean; clearSessionStorage?: boolean; };
  • src/index.ts:143-169 (registration)
    MCP tool registration in the TOOLS array, including name, description, and input schema matching BrowserResetOptions.
    { 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: [], }, },
  • Dispatcher case in handleToolCall that processes arguments, calls resetBrowserData, and returns the result.
    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, }; }

Other Tools

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

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