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;
    }
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It fails to mention critical aspects: whether this is a read-only operation, if it requires specific permissions or browser state, what happens if the cookie doesn't exist (e.g., returns null or error), or any rate limits. The description is minimal and lacks behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with just four words, which is efficient for a simple tool. However, it's under-specified rather than optimally concise—it could benefit from a bit more context without becoming verbose. It's front-loaded but lacks depth.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., cookie value, expiration, domain), error conditions, or dependencies on browser state. For a tool interacting with browser cookies, this leaves significant gaps in understanding its behavior and output.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the single parameter 'name' clearly documented in the schema. The description adds no additional meaning beyond what the schema provides (e.g., no examples of cookie names, format constraints, or case sensitivity). Baseline score of 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get a cookie by name' clearly states the action (get) and resource (cookie), but it's vague about scope and lacks differentiation from sibling tools like 'browser_get_cookies' (which retrieves all cookies). It doesn't specify if this returns a single cookie value or metadata, making the purpose somewhat ambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. For example, it doesn't mention when to choose 'browser_get_cookie_by_name' over 'browser_get_cookies' or 'browser_get_attribute', nor does it specify prerequisites like needing an active browser session. Usage context is implied but not explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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