launch_browser
Initiate browser connections to Chrome debugging ports, enabling automation and maintaining persistent login sessions for streamlined testing and debugging workflows.
Instructions
启动浏览器连接,连接到Chrome调试端口以保持登录状态
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| remote_host | No | 可选的远程Chrome主机URL (例如: http://localhost:9222) |
Implementation Reference
- src/browserSession.ts:116-133 (handler)The core handler function that connects to or launches a browser session via Chrome debugging port, handling remote host if provided, and returns success or error.async launchBrowser(remoteBrowserHost?: string): Promise<BrowserActionResult> { console.log("启动浏览器连接"); if (this.browser) { await this.closeBrowser(); } const remoteConnected = await this.connectToRemoteBrowser(remoteBrowserHost); if (!remoteConnected) { return { success: false, error: "无法连接到Chrome调试端口。请确保Chrome以 --remote-debugging-port=9222 参数启动" }; } return { success: true }; }
- src/index.ts:48-60 (schema)The tool schema definition including name, description, and input schema for remote_host parameter, provided in the listTools response.name: "launch_browser", description: "启动浏览器连接,连接到Chrome调试端口以保持登录状态", inputSchema: { type: "object", properties: { remote_host: { type: "string", description: "可选的远程Chrome主机URL (例如: http://localhost:9222)", }, }, }, }, {
- src/index.ts:174-176 (registration)The dispatch/registration case in the CallToolRequestSchema handler that invokes the browserSession.launchBrowser method.case "launch_browser": result = await this.browserSession.launchBrowser(args?.remote_host as string); break;