Skip to main content
Glama
epi-builder
by epi-builder

browser_close

Close the active browser instance to free system resources and complete automation sessions in Playwright MCP Server.

Instructions

Close the browser

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that closes the Playwright browser instance and resets the state, returning a confirmation message.
    private async handleClose() {
      if (this.browserState.browser) {
        await this.browserState.browser.close();
        this.browserState.browser = null;
        this.browserState.page = null;
      }
      
      return {
        content: [
          {
            type: 'text',
            text: 'Browser closed',
          },
        ],
      };
    }
  • The schema definition for the browser_close tool, including name, description, and empty input schema (no parameters required).
    {
      name: 'browser_close',
      description: 'Close the browser',
      inputSchema: {
        type: 'object',
        properties: {},
      },
    },
  • src/server.ts:172-173 (registration)
    The switch case that registers and dispatches the browser_close tool call to its handler function.
    case 'browser_close':
      return await this.handleClose();
  • src/server.ts:57-149 (registration)
    The ListToolsRequestHandler that registers the browser_close tool by including it in the list of available tools.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: 'browser_navigate',
            description: 'Navigate to a URL',
            inputSchema: {
              type: 'object',
              properties: {
                url: {
                  type: 'string',
                  description: 'The URL to navigate to',
                },
              },
              required: ['url'],
            },
          },
          {
            name: 'browser_snapshot',
            description: 'Capture accessibility snapshot of the current page',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'browser_click',
            description: 'Click on an element',
            inputSchema: {
              type: 'object',
              properties: {
                element: {
                  type: 'string',
                  description: 'Human-readable element description',
                },
                ref: {
                  type: 'string',
                  description: 'Exact target element reference from page snapshot',
                },
              },
              required: ['element', 'ref'],
            },
          },
          {
            name: 'browser_type',
            description: 'Type text into an element',
            inputSchema: {
              type: 'object',
              properties: {
                element: {
                  type: 'string',
                  description: 'Human-readable element description',
                },
                ref: {
                  type: 'string',
                  description: 'Exact target element reference from page snapshot',
                },
                text: {
                  type: 'string',
                  description: 'Text to type into the element',
                },
              },
              required: ['element', 'ref', 'text'],
            },
          },
          {
            name: 'browser_take_screenshot',
            description: 'Take a screenshot of the current page',
            inputSchema: {
              type: 'object',
              properties: {
                filename: {
                  type: 'string',
                  description: 'File name to save the screenshot to',
                },
                fullPage: {
                  type: 'boolean',
                  description: 'Take screenshot of full page',
                },
              },
            },
          },
          {
            name: 'browser_close',
            description: 'Close the browser',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
        ] as Tool[],
      };
    });

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.8/5.0
Behavior2/5

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

No annotations are provided, so the description carries full burden. 'Close the browser' is vague about side effects: does it terminate the entire session, close the current tab, or prompt for unsaved data? No disclosure of destructive behavior or irreversible state changes.

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?

Extremely concise at three words, with no wasted text. However, it may be too brief for an agent to fully understand the tool's scope. Still, it is well-structured and front-loaded.

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 the tool is a destructive action with no annotations or output schema, the description is inadequate. It does not explain what happens after closing, how to reopen, or what the agent should do beforehand. Lacks completeness for safe usage.

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?

Tool has zero parameters, so baseline is 4. The description adds no parameter information, but the input schema already shows no properties. No additional semantic value needed beyond the schema.

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?

Description states 'Close the browser', which is a clear verb+resource action. However, it is minimal and essentially a tautology of the tool name 'browser_close', and does not differentiate from siblings like 'browser_navigate_back' or 'browser_tabs' which also affect browser state.

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 on when to use this tool versus alternatives such as 'browser_navigate_back' or 'browser_snapshot' before closing. The description offers no context about prerequisites or typical workflows.

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