Skip to main content
Glama
dylangroos

Patchright Lite MCP Server

by dylangroos

close

Close a specific browser instance by its ID to free up resources on the Patchright Lite MCP Server, optimizing performance during stealth browser automation tasks.

Instructions

Close browser to free resources

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
browserIdYesBrowser ID to close

Implementation Reference

  • The handler function that closes the specified browser instance using browser.close(), removes it from the tracking map, and returns a 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}` } ] }; } }
  • Input schema defining the required 'browserId' parameter as a string.
    { browserId: z.string().describe("Browser ID to close") },
  • src/index.ts:296-335 (registration)
    Registration of the 'close' tool with the MCP server, including name, description, input 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}` } ] }; } } );

Other Tools

Related 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