Skip to main content
Glama
BrowserGenie

BrowserGenie MCP Server

by BrowserGenie

get_cookies

Retrieve cookies for the current page or any specified URL, with optional filtering by cookie name.

Instructions

Get cookies for the current page or a specific URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlNoURL to get cookies for (defaults to current page URL)
nameNoFilter by cookie name
apiKeyNoAPI key for authentication

Implementation Reference

  • Handler function for the 'get_cookies' tool that sends a command via WebSocket bridge to get cookies for the current page or a specific URL, with optional name filter.
    server.tool(
      'get_cookies',
      'Get cookies for the current page or a specific URL',
      {
        url: z.string().optional().describe('URL to get cookies for (defaults to current page URL)'),
        name: z.string().optional().describe('Filter by cookie name'),
        apiKey: z.string().optional().describe('API key for authentication'),
      },
      async ({ url, name, apiKey }) => {
        const result = await bridge.sendCommand({ command: 'get_cookies', params: { url, name }, apiKey });
        if (!result.success) return { content: [{ type: 'text' as const, text: `Error: ${result.error?.message}` }], isError: true };
        return { content: [{ type: 'text' as const, text: JSON.stringify(result.data, null, 2) }] };
      }
    );
  • Input schema for the 'get_cookies' tool with optional url, name, and apiKey parameters using Zod validation.
    {
      url: z.string().optional().describe('URL to get cookies for (defaults to current page URL)'),
      name: z.string().optional().describe('Filter by cookie name'),
      apiKey: z.string().optional().describe('API key for authentication'),
    },
  • Registration of the 'get_cookies' tool on the MCP server via server.tool() call in the registerDevtoolsStorageTools function.
    server.tool(
      'get_cookies',
      'Get cookies for the current page or a specific URL',
      {
        url: z.string().optional().describe('URL to get cookies for (defaults to current page URL)'),
        name: z.string().optional().describe('Filter by cookie name'),
        apiKey: z.string().optional().describe('API key for authentication'),
      },
      async ({ url, name, apiKey }) => {
        const result = await bridge.sendCommand({ command: 'get_cookies', params: { url, name }, apiKey });
        if (!result.success) return { content: [{ type: 'text' as const, text: `Error: ${result.error?.message}` }], isError: true };
        return { content: [{ type: 'text' as const, text: JSON.stringify(result.data, null, 2) }] };
      }
    );
  • The sendCommand helper on WebSocketBridge that sends the 'get_cookies' command (with params, apiKey) to the Chrome extension over WebSocket and returns the response.
    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));
      });
    }
Behavior2/5

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

No annotations are present, so the description must carry the full burden. It does not disclose behavioral traits such as authentication needs (apiKey is in schema but not mentioned), side effects, or format of returned data.

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

Conciseness5/5

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

The description is a single sentence of 11 words with no extraneous information. It front-loads the action and resource, making it easy to scan.

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

Completeness3/5

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

For a simple retrieval tool with no output schema, the description is adequate but lacks mention of return format, error conditions, or behavior when no cookies exist. It could be more helpful with typical usage examples.

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 coverage is 100% with descriptions for all parameters. The description adds minimal extra value by clarifying that the url parameter defaults to the current page URL. This is sufficient for a baseline score of 3.

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

Purpose5/5

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

The description clearly states the action ('get cookies') and the resource ('current page or a specific URL'). It distinguishes the tool from siblings like 'set_cookie' and 'delete_cookie' by specifying retrieval only.

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?

The description provides no guidance on when to use this tool versus alternatives (e.g., 'set_cookie', 'delete_cookie') or when not to use it. No context about prerequisites or limitations.

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