browser_close
Closes the current browser session to free system resources and end automation tasks in Selenium WebDriver.
Instructions
Close the current browser session
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/browserTools.ts:399-423 (handler)The inline handler function for the 'browser_close' tool, registered via server.tool(). It retrieves the current driver, quits it, cleans up the session state, and returns a confirmation or error message.server.tool('browser_close', 'Close the current browser session', {}, async () => { try { const driver = stateManager.getDriver(); await driver.quit(); const sessionId = stateManager.getCurrentSession(); if (sessionId) { stateManager.removeDriver(sessionId); } stateManager.resetCurrentSession(); return { content: [{ type: 'text', text: `Browser session ${sessionId} closed` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error closing session: ${(e as Error).message}`, }, ], }; } });
- src/tools/browserTools.ts:399-423 (registration)The 'browser_close' tool is registered here within the registerBrowserTools function using server.tool(), with no input schema and the handler inline.server.tool('browser_close', 'Close the current browser session', {}, async () => { try { const driver = stateManager.getDriver(); await driver.quit(); const sessionId = stateManager.getCurrentSession(); if (sessionId) { stateManager.removeDriver(sessionId); } stateManager.resetCurrentSession(); return { content: [{ type: 'text', text: `Browser session ${sessionId} closed` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error closing session: ${(e as Error).message}`, }, ], }; } });