closeBrowser
Terminate the browser session to free system resources and complete automation tasks in PlayMCP Browser Automation Server.
Instructions
Close the browser
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/controllers/playwright.ts:59-71 (handler)The main handler function that closes the Playwright browser instance, context, and page, then resets the state.async closeBrowser(): Promise<void> { try { this.log('Closing browser'); await this.state.page?.close(); await this.state.context?.close(); await this.state.browser?.close(); this.state = { browser: null, context: null, page: null, debug: false }; this.log('Browser closed'); } catch (error: any) { console.error('Browser close error:', error); throw new BrowserError('Failed to close browser', 'The browser might have already been closed'); } }
- src/server.ts:504-512 (schema)Tool schema definition including name, description, and empty input schema (no parameters required).const CLOSE_BROWSER_TOOL: Tool = { name: "closeBrowser", description: "Close the browser", inputSchema: { type: "object", properties: {}, required: [] } };
- src/server.ts:552-552 (registration)Registration of the closeBrowser tool in the tools object passed to MCP server capabilities.closeBrowser: CLOSE_BROWSER_TOOL
- src/server.ts:998-1003 (handler)Dispatch handler in MCP 'callTool' request that invokes the closeBrowser method.case 'closeBrowser': { await playwrightController.closeBrowser(); return { content: [{ type: "text", text: "Browser closed successfully" }] }; }