Skip to main content
Glama

browser_get_cookie_by_name

Retrieve specific browser cookies by name to access authentication tokens, session data, or user preferences during web automation and testing workflows.

Instructions

Get a cookie by name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the cookie to get

Implementation Reference

  • Registers the 'browser_get_cookie_by_name' tool using McpServer.tool(), including description, input schema, and inline handler function.
    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}` }], }; } );
  • The tool handler function that retrieves the browser driver, creates a CookieService instance, fetches the cookie value by name, and returns it in the MCP response format.
    async ({ name }) => { const driver = stateManager.getDriver(); const cookieService = new CookieService(driver); const cookieValue = await cookieService.getCookieByName(name); return { content: [{ type: 'text', text: `Cookie: ${cookieValue}` }], }; }
  • Zod schema defining the input parameter 'name' as a required string.
    { name: z.string().describe('Name of the cookie to get'), },
  • Helper method in CookieService class that uses Selenium WebDriver's manage().getCookie() to retrieve a specific cookie by name and returns its name-value object or null.
    async getCookieByName(name: string): Promise<any | null> { const cookie = await this.driver.manage().getCookie(name); return cookie ? { name: cookie.name, value: cookie.value } : null; }
  • Higher-level registration call to registerCookieTools within the registerAllTools function.
    registerCookieTools(server, stateManager);

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