Skip to main content
Glama

pilot_set_cookie

Set a cookie on the current page's domain for authentication, testing, or session management. Specify cookie name and value to manually configure browser state.

Instructions

Set a cookie on the current page's domain with a given name and value. Use when the user wants to manually set a cookie for authentication, testing, or session management. The cookie is set on the domain of the currently active page. For bulk cookie import from a real browser, use pilot_import_cookies.

Parameters:

  • name: Cookie name (e.g., "session_id", "theme")

  • value: Cookie value (e.g., "abc123", "dark")

Returns: Confirmation with the cookie name (value is redacted for security).

Errors:

  • "Cannot set cookie without a page": Navigate to a URL first with pilot_navigate.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesCookie name
valueYesCookie value

Implementation Reference

  • Registration function registerSettingsTools that registers 'pilot_set_cookie' (and 'pilot_resize') on the MCP server. The registration is at line 42-75.
    export function registerSettingsTools(server: McpServer, bm: BrowserManager) {
      server.tool(
        'pilot_resize',
        `Set the browser viewport size in pixels to simulate different screen resolutions.
    Use when the user wants to test responsive layouts, simulate a mobile or tablet screen, or change the visible area of the page. For multi-viewport screenshots, use pilot_responsive instead.
    
    Parameters:
    - width: Viewport width in pixels (e.g., 1280 for desktop, 375 for mobile)
    - height: Viewport height in pixels (e.g., 720 for desktop, 812 for mobile)
    
    Returns: Confirmation with the new viewport dimensions.
    
    Errors: None — any valid pixel dimensions are accepted.`,
          {
          width: z.number().describe('Viewport width in pixels'),
          height: z.number().describe('Viewport height in pixels'),
        },
        async ({ width, height }) => {
          await bm.ensureBrowser();
          try {
            await bm.setViewport(width, height);
            return { content: [{ type: 'text' as const, text: `Viewport set to ${width}x${height}` }] };
          } catch (err) {
            return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true };
          }
        }
      );
    
      server.tool(
        'pilot_set_cookie',
        `Set a cookie on the current page's domain with a given name and value.
    Use when the user wants to manually set a cookie for authentication, testing, or session management. The cookie is set on the domain of the currently active page. For bulk cookie import from a real browser, use pilot_import_cookies.
    
    Parameters:
    - name: Cookie name (e.g., "session_id", "theme")
    - value: Cookie value (e.g., "abc123", "dark")
    
    Returns: Confirmation with the cookie name (value is redacted for security).
    
    Errors:
    - "Cannot set cookie without a page": Navigate to a URL first with pilot_navigate.`,
          {
          name: z.string().describe('Cookie name'),
          value: z.string().describe('Cookie value'),
        },
        async ({ name, value }) => {
          await bm.ensureBrowser();
          try {
            const page = bm.getPage();
            const url = new URL(page.url());
            await page.context().addCookies([{
              name,
              value,
              domain: url.hostname,
              path: '/',
            }]);
            return { content: [{ type: 'text' as const, text: `Cookie set: ${name}=****` }] };
          } catch (err) {
            return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true };
          }
        }
      );
  • The handler function for pilot_set_cookie. It gets the current page, extracts the hostname from the URL, and uses Playwright's page.context().addCookies() to set the cookie with name, value, domain (current hostname), and path '/'.
    async ({ name, value }) => {
      await bm.ensureBrowser();
      try {
        const page = bm.getPage();
        const url = new URL(page.url());
        await page.context().addCookies([{
          name,
          value,
          domain: url.hostname,
          path: '/',
        }]);
        return { content: [{ type: 'text' as const, text: `Cookie set: ${name}=****` }] };
      } catch (err) {
        return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true };
      }
    }
  • Zod schema for pilot_set_cookie inputs: 'name' (z.string) and 'value' (z.string).
      {
      name: z.string().describe('Cookie name'),
      value: z.string().describe('Cookie value'),
    },
  • Where registerSettingsTools is called to register the tool on the server.
    registerSettingsTools(effectiveServer, bm);
Behavior4/5

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

No annotations are provided, so the description carries full burden. It discloses the domain scope ('on the domain of the currently active page'), security redaction of value in return, and an error case ('Cannot set cookie without a page'). Minor omission: no mention of expiration or overwrite behavior.

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?

Well-structured with sections for description, usage, parameters, returns, and errors. Every sentence is informative and concise, with no redundancy.

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

Completeness4/5

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

For a simple cookie setter without output schema, the description covers return behavior (confirmation with redacted value) and a key error scenario. Could optionally mention cookie attributes like path, but not essential for basic use.

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

Parameters4/5

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

Schema descriptions are present (100% coverage) but the tool description adds concrete examples (e.g., 'session_id', 'theme', 'abc123', 'dark'), enhancing meaning beyond the schema alone.

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 explicitly states 'Set a cookie on the current page's domain with a given name and value,' clearly indicating the verb, resource, and scope. It distinguishes from the sibling pilot_import_cookies by contrasting manual vs bulk import.

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

Usage Guidelines5/5

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

Provides explicit usage context: 'Use when the user wants to manually set a cookie for authentication, testing, or session management.' Also names a clear alternative: 'For bulk cookie import from a real browser, use pilot_import_cookies.'

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/TacosyHorchata/Pilot'

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