Skip to main content
Glama

browser_close

Close the current browser page to manage resources and end web interactions when automation tasks are complete.

Instructions

Close the page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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()`); },
  • 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, ];
  • 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);
  • 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(); }); }

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/maywzh/playwright-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server