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 tasks.

Instructions

Get a cookie by name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the cookie to get

Implementation Reference

  • The handler function for the 'browser_get_cookie_by_name' tool. It gets the WebDriver from stateManager, creates a CookieService instance, calls getCookieByName on it, and returns the result as text content.
    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 input schema defining the 'name' parameter as a required string.
    { name: z.string().describe('Name of the cookie to get'), },
  • Registration of the 'browser_get_cookie_by_name' tool on the MCP server using server.tool(), including description, schema, and handler.
    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}` }], }; } );
  • Core helper method in CookieService class that retrieves a cookie by name using Selenium WebDriver's getCookie method and returns an object with name and value 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; }

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