browser_launch
Launch and control web browsers on Windows systems for automated testing, data extraction, or web interaction tasks. Supports headless mode and session management.
Instructions
启动浏览器
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| headless | No | 是否无头模式(可选,默认 false) | |
| sessionId | No | 会话 ID(可选) |
Implementation Reference
- src/tools/browser.js:146-167 (handler)The main handler function that implements the logic for launching a Puppeteer browser instance and page for a given session.async launchBrowser(headless = false, sessionId = 'default') { try { if (this.browsers.has(sessionId)) { return { success: true, message: '浏览器已存在', sessionId }; } const browser = await this.puppeteer.launch({ headless, defaultViewport: null, args: ['--start-maximized'] }); const page = await browser.newPage(); this.browsers.set(sessionId, browser); this.pages.set(sessionId, page); return { success: true, message: '浏览器已启动', sessionId }; } catch (error) { return { success: false, error: error.message }; } }
- src/tools/browser.js:27-37 (registration)Registers the browser_launch tool including its name, description, and input schema in the getToolDefinitions() method.{ name: 'browser_launch', description: '启动浏览器', inputSchema: { type: 'object', properties: { headless: { type: 'boolean', description: '是否无头模式(可选,默认 false)' }, sessionId: { type: 'string', description: '会话 ID(可选)' }, }, }, },
- src/tools/browser.js:30-36 (schema)Defines the input schema for the browser_launch tool, specifying optional headless and sessionId parameters.inputSchema: { type: 'object', properties: { headless: { type: 'boolean', description: '是否无头模式(可选,默认 false)' }, sessionId: { type: 'string', description: '会话 ID(可选)' }, }, },
- src/tools/browser.js:127-128 (handler)Dispatch handler in executeTool switch statement that calls the launchBrowser method.case 'browser_launch': return await this.launchBrowser(args.headless, args.sessionId);