Skip to main content
Glama

browser_delete_cookies

Remove all browser cookies to clear stored session data, login credentials, and tracking information during web automation testing.

Instructions

Delete cookies from the browser

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "properties": {}, "type": "object" }

Implementation Reference

  • The handler function for the 'browser_delete_cookies' tool. It retrieves the WebDriver from stateManager, instantiates CookieService, calls deleteAllCookies(), and returns a success message.
    server.tool('browser_delete_cookies', 'Delete cookies from the browser', {}, async () => { const driver = stateManager.getDriver(); const cookieService = new CookieService(driver); await cookieService.deleteAllCookies(); return { content: [{ type: 'text', text: 'Deleted all cookies' }], }; });
  • Helper method in CookieService that deletes all cookies using Selenium WebDriver's deleteAllCookies().
    async deleteAllCookies(): Promise<void> { await this.driver.manage().deleteAllCookies(); }
  • Function that registers the cookie tools, including browser_delete_cookies, to the MCP server.
    export function registerCookieTools(server: McpServer, stateManager: StateManager) { server.tool('browser_get_cookies', 'Get all cookies', {}, async () => { const driver = stateManager.getDriver(); const cookieService = new CookieService(driver); const cookies = await cookieService.getCookies(); return { content: [{ type: 'text', text: `Cookies: ${cookies.join(', ')}` }], }; }); server.tool( 'browser_get_cookie_by_name', 'Get a cookie by name', { name: z.string().describe('Name of the cookie to get'), }, async ({ name }) => { const driver = stateManager.getDriver(); const cookieService = new CookieService(driver); const cookieValue = await cookieService.getCookieByName(name); return { content: [{ type: 'text', text: `Cookie: ${cookieValue}` }], }; } ); server.tool( 'browser_add_cookie_by_name', 'Add a cookie to the browser', { name: z.string().describe('Name of the cookie to add'), value: z.string().min(1).max(4096).describe('Value of the cookie to add'), }, async ({ name, value }) => { const driver = stateManager.getDriver(); const cookieService = new CookieService(driver); await cookieService.addCookieByName(name, value); return { content: [{ type: 'text', text: `Added cookie: ${name}` }], }; } ); server.tool( 'browser_set_cookie_object', 'Set a cookie in the browser', { cookie: z.string().min(1).max(4096).describe("Cookie string to set, e.g. 'name=value; Path=/; HttpOnly'"), }, async ({ cookie }) => { const driver = stateManager.getDriver(); const cookieService = new CookieService(driver); await cookieService.setCookie(cookie); return { content: [{ type: 'text', text: `Set cookie: ${cookie}` }], }; } ); server.tool( 'browser_delete_cookie', 'Delete a cookie from the browser', { name: z.string().describe('Name of the cookie to delete'), }, async ({ name }) => { const driver = stateManager.getDriver(); const cookieService = new CookieService(driver); await cookieService.deleteCookie(name); return { content: [{ type: 'text', text: `Deleted cookie: ${name}` }], }; } ); server.tool('browser_delete_cookies', 'Delete cookies from the browser', {}, async () => { const driver = stateManager.getDriver(); const cookieService = new CookieService(driver); await cookieService.deleteAllCookies(); return { content: [{ type: 'text', text: 'Deleted all cookies' }], }; }); }

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/pshivapr/selenium-mcp'

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