openBrowser
Launch a new browser instance for web automation tasks like scraping, testing, and interaction using Playwright technology.
Instructions
Launch a new browser instance
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| headless | No | ||
| debug | No |
Implementation Reference
- src/controllers/playwright.ts:25-57 (handler)Core handler function that launches the Chromium browser instance, creates a new browser context and page, with support for headless mode and debug logging.async openBrowser(headless: boolean = false, debug: boolean = false): Promise<void> { try { this.state.debug = debug; this.log('Attempting to launch browser'); if (this.state.browser?.isConnected()) { this.log('Browser already running'); return; } this.log('Launching new browser instance', { headless }); this.state.browser = await chromium.launch({ headless, args: ['--no-sandbox'] }); this.log('Creating browser context'); this.state.context = await this.state.browser.newContext({ viewport: { width: 1280, height: 720 } }); this.log('Creating new page'); this.state.page = await this.state.context.newPage(); this.log('Browser successfully launched'); } catch (error: any) { console.error('Browser launch error:', error); throw new BrowserError( 'Failed to launch browser', `Technical details: ${error?.message || 'Unknown error'}` ); } }
- src/server.ts:576-584 (handler)MCP server request handler for the openBrowser tool call that delegates to the Playwright controller with input arguments.case 'openBrowser': { await playwrightController.openBrowser( args.headless as boolean, args.debug as boolean ); return { content: [{ type: "text", text: "Browser opened successfully" }] }; }
- src/server.ts:6-17 (schema)Tool schema definition specifying the name, description, and input parameters (headless and debug booleans).const OPEN_BROWSER_TOOL: Tool = { name: "openBrowser", description: "Launch a new browser instance", inputSchema: { type: "object", properties: { headless: { type: "boolean" }, debug: { type: "boolean" } }, required: [] } };
- src/server.ts:514-553 (registration)Registration of the openBrowser tool in the tools object passed to the MCP server capabilities.const tools = { openBrowser: OPEN_BROWSER_TOOL, navigate: NAVIGATE_TOOL, type: TYPE_TOOL, click: CLICK_TOOL, moveMouse: MOVE_MOUSE_TOOL, scroll: SCROLL_TOOL, screenshot: SCREENSHOT_TOOL, getPageSource: GET_PAGE_SOURCE_TOOL, getPageText: GET_PAGE_TEXT_TOOL, getPageTitle: GET_PAGE_TITLE_TOOL, getPageUrl: GET_PAGE_URL_TOOL, getScripts: GET_SCRIPTS_TOOL, getStylesheets: GET_STYLESHEETS_TOOL, getMetaTags: GET_META_TAGS_TOOL, getLinks: GET_LINKS_TOOL, getImages: GET_IMAGES_TOOL, getForms: GET_FORMS_TOOL, getElementContent: GET_ELEMENT_CONTENT_TOOL, getElementHierarchy: GET_ELEMENT_HIERARCHY_TOOL, executeJavaScript: EXECUTE_JAVASCRIPT_TOOL, goForward: GO_FORWARD_TOOL, hover: HOVER_TOOL, dragAndDrop: DRAG_AND_DROP_TOOL, selectOption: SELECT_OPTION_TOOL, pressKey: PRESS_KEY_TOOL, waitForText: WAIT_FOR_TEXT_TOOL, waitForSelector: WAIT_FOR_SELECTOR_TOOL, resize: RESIZE_TOOL, handleDialog: HANDLE_DIALOG_TOOL, getConsoleMessages: GET_CONSOLE_MESSAGES_TOOL, getNetworkRequests: GET_NETWORK_REQUESTS_TOOL, uploadFiles: UPLOAD_FILES_TOOL, evaluateWithReturn: EVALUATE_WITH_RETURN_TOOL, takeScreenshot: TAKE_SCREENSHOT_TOOL, mouseMove: MOUSE_MOVE_TOOL, mouseClick: MOUSE_CLICK_TOOL, mouseDrag: MOUSE_DRAG_TOOL, closeBrowser: CLOSE_BROWSER_TOOL };