browser_close
Close the current browser page to manage resources and end web interactions when automation tasks are complete.
Instructions
Close the page
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "browser_close"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/common.ts:31-35 (handler)The core handler function for the 'browser_close' tool. It closes the browser context, instructs the response to include tabs, and adds a code snippet for closing the page.
handle: async (context, params, response) => { await context.closeBrowserContext(); response.setIncludeTabs(); response.addCode(`await page.close()`); }, - src/tools/common.ts:23-29 (schema)The schema definition for the 'browser_close' tool, specifying name, title, description, empty input schema, and readOnly type.
schema: { name: 'browser_close', title: 'Close browser', description: 'Close the page', inputSchema: z.object({}), type: 'readOnly', }, - src/tools.ts:36-52 (registration)Registers the 'browser_close' tool (via ...common import) into the central allTools array used by the backend.
export const allTools: Tool<any>[] = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ]; - src/browserServerBackend.ts:76-77 (registration)The MCP server backend's tools() method exposes the tool schemas, including 'browser_close', to the MCP protocol.
tools(): mcpServer.ToolSchema<any>[] { return this._tools.map(tool => tool.schema); - src/context.ts:155-169 (helper)The implementation of closing the browser context, called by the tool handler via context.closeBrowserContext().
private async _closeBrowserContextImpl() { if (!this._browserContextPromise) return; testDebug('close context'); const promise = this._browserContextPromise; this._browserContextPromise = undefined; await promise.then(async ({ browserContext, close }) => { if (this.config.saveTrace) await browserContext.tracing.stop(); await close(); }); }