Skip to main content
Glama
BrowserGenie

BrowserGenie MCP Server

by BrowserGenie

set_cookie

Set a browser cookie with specified name, value, domain, path, and security flags for session management or authentication.

Instructions

Set a cookie

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesCookie name
valueYesCookie value
urlNoURL to associate the cookie with
domainNoCookie domain
pathNoCookie path
secureNoSecure flag
httpOnlyNoHttpOnly flag
sameSiteNoSameSite attribute
expirationDateNoExpiration as Unix timestamp in seconds
apiKeyNoAPI key for authentication

Implementation Reference

  • The tool 'set_cookie' is registered with the MCP server via server.tool() in the registerDevtoolsStorageTools function.
    );
    
    server.tool(
  • The handler function for 'set_cookie' which sends a 'set_cookie' command via the WebSocket bridge and returns the result.
      async ({ apiKey, ...params }) => {
        const result = await bridge.sendCommand({ command: 'set_cookie', params, apiKey });
        if (!result.success) return { content: [{ type: 'text' as const, text: `Error: ${result.error?.message}` }], isError: true };
        return { content: [{ type: 'text' as const, text: `Cookie "${params.name}" set` }] };
      }
    );
  • Zod schema defining input parameters for the 'set_cookie' tool: name, value, url, domain, path, secure, httpOnly, sameSite, expirationDate, and apiKey.
    {
      name: z.string().describe('Cookie name'),
      value: z.string().describe('Cookie value'),
      url: z.string().optional().describe('URL to associate the cookie with'),
      domain: z.string().optional().describe('Cookie domain'),
      path: z.string().optional().describe('Cookie path'),
      secure: z.boolean().optional().describe('Secure flag'),
      httpOnly: z.boolean().optional().describe('HttpOnly flag'),
      sameSite: z.enum(['no_restriction', 'lax', 'strict']).optional().describe('SameSite attribute'),
      expirationDate: z.number().optional().describe('Expiration as Unix timestamp in seconds'),
      apiKey: z.string().optional().describe('API key for authentication'),
  • The WebSocketBridge.sendCommand method is the helper that dispatches the 'set_cookie' command to the Chrome extension over WebSocket.
    async sendCommand(cmd: BridgeCommand): Promise<BridgeResponse> {
      if (!this.isConnected()) {
        return {
          success: false,
          error: {
            code: 'NOT_CONNECTED',
            message: 'Chrome extension is not connected. Ensure the extension is installed, enabled, and the browser is running.',
          },
        };
      }
    
      const id = crypto.randomUUID();
      const timeout = cmd.timeout ?? DEFAULT_TIMEOUT;
    
      return new Promise<BridgeResponse>((resolve, reject) => {
        const timer = setTimeout(() => {
          this.pending.delete(id);
          resolve({
            success: false,
            error: {
              code: 'TIMEOUT',
              message: `Command '${cmd.command}' timed out after ${timeout}ms`,
            },
          });
        }, timeout);
    
        this.pending.set(id, { resolve, reject, timer });
    
        const message = {
          id,
          type: 'request',
          command: cmd.command,
          params: cmd.params,
          tabId: cmd.tabId,
          apiKey: cmd.apiKey,
          timestamp: Date.now(),
        };
    
        this.client!.send(JSON.stringify(message));
      });
    }
  • The registration function that contains 'set_cookie' is invoked in registerAllTools, which is the central tool registration entry point.
      registerDevtoolsStorageTools(server, bridge);
      registerDevtoolsConsoleTools(server, bridge);
    
      registerAccessibilityTools(server, bridge);
      registerEmulationTools(server, bridge);
      registerElementTools(server, bridge);
      registerAuditTools(server, bridge);
      registerInteractionTools(server, bridge);
      registerMonitoringTools(server, bridge);
      registerQaTools(server, bridge);
      registerGestureTools(server, bridge);
      registerMacroTools(server, bridge);
      registerVisualRegressionTools(server, bridge);
    }
Behavior2/5

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

With no annotations, the description fails to disclose behavioral traits like overwriting behavior, authentication needs, or scope (e.g., cookie for current domain).

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

Conciseness3/5

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

Extremely concise at three words, but lacks structure and additional context that could be added without verbosity.

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 10 parameters and no output schema, the description is too minimal to provide complete understanding of how the tool behaves or what it returns.

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 covers 100% of parameters with descriptions, so the description adds no additional meaning. Baseline 3 is appropriate.

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

Purpose4/5

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

The description 'Set a cookie' clearly indicates the verb and resource, but does not differentiate it from sibling tools like 'get_cookies' or 'delete_cookie'.

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, such as when cookies already exist or require specific parameters.

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/BrowserGenie/mcp'

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