Skip to main content
Glama
dylangroos

Patchright Lite MCP Server

by dylangroos

close

Close a browser instance to free system resources after completing web automation tasks with the Patchright Lite MCP Server.

Instructions

Close browser to free resources

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
browserIdYesBrowser ID to close

Implementation Reference

  • The handler function that executes the 'close' tool: retrieves the browser instance by ID, closes the browser, removes it from the instances map, and returns success or error message.
    async ({ browserId }: { browserId: string }) => {
      try {
        // Get the browser instance
        const instance = browserInstances.get(browserId);
        if (!instance) {
          throw new Error(`Browser instance not found: ${browserId}`);
        }
        
        // Close the browser
        await instance.browser.close();
        
        // Remove from the map
        browserInstances.delete(browserId);
        
        return {
          content: [
            {
              type: "text",
              text: `Successfully closed browser: ${browserId}`
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Failed to close browser: ${error}`
            }
          ]
        };
      }
    }
  • The input schema for the 'close' tool, defining the required 'browserId' parameter as a string.
    {
      browserId: z.string().describe("Browser ID to close")
    },
  • src/index.ts:296-335 (registration)
    The registration of the 'close' tool on the MCP server using server.tool(), including name, description, schema, and handler function.
    server.tool(
      "close",
      "Close browser to free resources",
      {
        browserId: z.string().describe("Browser ID to close")
      },
      async ({ browserId }: { browserId: string }) => {
        try {
          // Get the browser instance
          const instance = browserInstances.get(browserId);
          if (!instance) {
            throw new Error(`Browser instance not found: ${browserId}`);
          }
          
          // Close the browser
          await instance.browser.close();
          
          // Remove from the map
          browserInstances.delete(browserId);
          
          return {
            content: [
              {
                type: "text",
                text: `Successfully closed browser: ${browserId}`
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Failed to close browser: ${error}`
              }
            ]
          };
        }
      }
    );
Behavior2/5

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

With no annotations, the description carries full burden. It states the tool closes a browser to free resources, implying a destructive action that terminates a session, but doesn't disclose behavioral traits like whether it's reversible, requires specific permissions, affects other tools, or has side effects (e.g., losing unsaved data). The mention of 'free resources' adds some context but is minimal.

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, efficient sentence with zero waste, front-loading the key action and purpose. It's appropriately sized for a simple tool with one parameter.

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, no output schema, and a destructive action implied by 'close', the description is incomplete. It lacks details on what happens after closing (e.g., return values, error conditions), prerequisites, or integration with sibling tools. For a tool that likely terminates a resource, more context is needed.

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 parameter 'browserId' fully documented in the schema. The description adds no meaning beyond the schema, as it doesn't explain what a 'browserId' is, how to obtain it, or its format. Baseline 3 is appropriate since the schema does the heavy lifting.

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 clearly states the action ('Close') and the resource ('browser'), specifying it's to 'free resources'. It distinguishes from sibling tools like 'browse' (open/access) and 'interact' (use while open), but doesn't explicitly contrast with 'extract' (which might operate on a closed or open browser).

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 implies usage when resources need freeing, but provides no explicit guidance on when to use this tool versus alternatives (e.g., whether to close after 'browse' or 'extract'), prerequisites, or exclusions. It lacks context for decision-making relative to siblings.

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/dylangroos/patchright-mcp-lite'

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