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}` } ] }; } } );
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