browser_close
Close the active browser instance to free system resources and complete automation sessions in Playwright MCP Server.
Instructions
Close the browser
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:288-303 (handler)The handler function that closes the Playwright browser instance and resets the state, returning a confirmation message.private async handleClose() { if (this.browserState.browser) { await this.browserState.browser.close(); this.browserState.browser = null; this.browserState.page = null; } return { content: [ { type: 'text', text: 'Browser closed', }, ], }; }
- src/server.ts:139-146 (schema)The schema definition for the browser_close tool, including name, description, and empty input schema (no parameters required).{ name: 'browser_close', description: 'Close the browser', inputSchema: { type: 'object', properties: {}, }, },
- src/server.ts:172-173 (registration)The switch case that registers and dispatches the browser_close tool call to its handler function.case 'browser_close': return await this.handleClose();
- src/server.ts:57-149 (registration)The ListToolsRequestHandler that registers the browser_close tool by including it in the list of available tools.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: 'browser_navigate', description: 'Navigate to a URL', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'The URL to navigate to', }, }, required: ['url'], }, }, { name: 'browser_snapshot', description: 'Capture accessibility snapshot of the current page', inputSchema: { type: 'object', properties: {}, }, }, { name: 'browser_click', description: 'Click on an element', inputSchema: { type: 'object', properties: { element: { type: 'string', description: 'Human-readable element description', }, ref: { type: 'string', description: 'Exact target element reference from page snapshot', }, }, required: ['element', 'ref'], }, }, { name: 'browser_type', description: 'Type text into an element', inputSchema: { type: 'object', properties: { element: { type: 'string', description: 'Human-readable element description', }, ref: { type: 'string', description: 'Exact target element reference from page snapshot', }, text: { type: 'string', description: 'Text to type into the element', }, }, required: ['element', 'ref', 'text'], }, }, { name: 'browser_take_screenshot', description: 'Take a screenshot of the current page', inputSchema: { type: 'object', properties: { filename: { type: 'string', description: 'File name to save the screenshot to', }, fullPage: { type: 'boolean', description: 'Take screenshot of full page', }, }, }, }, { name: 'browser_close', description: 'Close the browser', inputSchema: { type: 'object', properties: {}, }, }, ] as Tool[], }; });