Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

closeBrowser

Terminate active browser sessions in the PlayMCP Browser Automation Server. Ensures clean closure of browser instances after web automation tasks like scraping or testing.

Instructions

Close the browser

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Executes the closeBrowser tool by closing the Playwright page, browser context, browser instance, resetting state, with logging and error handling.
    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'); } }
  • Defines the input/output schema for the closeBrowser tool, specifying no required parameters.
    const CLOSE_BROWSER_TOOL: Tool = { name: "closeBrowser", description: "Close the browser", inputSchema: { type: "object", properties: {}, required: [] } };
  • src/server.ts:552-552 (registration)
    Registers the closeBrowser tool in the central tools dictionary passed to the MCP Server constructor.
    closeBrowser: CLOSE_BROWSER_TOOL
  • src/server.ts:998-1003 (registration)
    Maps incoming 'closeBrowser' tool calls in the MCP server's callTool handler to invoke playwrightController.closeBrowser().
    case 'closeBrowser': { await playwrightController.closeBrowser(); return { content: [{ type: "text", text: "Browser closed successfully" }] }; }

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/jomon003/PlayMCP'

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