Skip to main content
Glama

browser_add_cookie_by_name

Add a cookie to the browser by specifying its name and value for web automation and testing purposes.

Instructions

Add a cookie to the browser

Input Schema

NameRequiredDescriptionDefault
nameYesName of the cookie to add
valueYesValue of the cookie to add

Input Schema (JSON Schema)

{ "properties": { "name": { "description": "Name of the cookie to add", "type": "string" }, "value": { "description": "Value of the cookie to add", "maxLength": 4096, "minLength": 1, "type": "string" } }, "required": [ "name", "value" ], "type": "object" }

Implementation Reference

  • Registration of the 'browser_add_cookie_by_name' tool, including description, Zod input schema for 'name' and 'value', and the inline handler function that uses CookieService to add the cookie.
    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}` }], }; } );
  • Zod schema defining the input parameters for the tool.
    { name: z.string().describe('Name of the cookie to add'), value: z.string().min(1).max(4096).describe('Value of the cookie to add'), },
  • Handler function that executes the tool logic by retrieving the browser driver, instantiating CookieService, adding the cookie, and returning a text response.
    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}` }], }; }
  • Helper method in CookieService that performs the actual cookie addition using Selenium WebDriver's manage().addCookie().
    async addCookieByName(name: string, value: string): Promise<void> { await this.driver.manage().addCookie({ name, value }); }
  • Higher-level registration call to registerCookieTools within registerAllTools.
    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