launch_browser
Start a browser connection to Chrome debugging ports for browser automation with persistent login sessions.
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)Core handler function that establishes connection to Chrome debugging port using provided remote host or automatic discovery.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-59 (schema)Input schema definition for the launch_browser tool, including optional remote_host parameter.name: "launch_browser", description: "启动浏览器连接,连接到Chrome调试端口以保持登录状态", inputSchema: { type: "object", properties: { remote_host: { type: "string", description: "可选的远程Chrome主机URL (例如: http://localhost:9222)", }, }, }, },
- src/index.ts:47-59 (registration)Registration of the launch_browser tool in the ListToolsRequestSchema handler.{ name: "launch_browser", description: "启动浏览器连接,连接到Chrome调试端口以保持登录状态", inputSchema: { type: "object", properties: { remote_host: { type: "string", description: "可选的远程Chrome主机URL (例如: http://localhost:9222)", }, }, }, },
- src/index.ts:174-176 (handler)MCP CallToolRequestSchema dispatch handler that invokes the browserSession.launchBrowser method.case "launch_browser": result = await this.browserSession.launchBrowser(args?.remote_host as string); break;
- src/browserSession.ts:9-16 (schema)Output schema/interface for browser action results, used by launchBrowser.export interface BrowserActionResult { screenshot?: string; logs?: string; currentUrl?: string; currentMousePosition?: string; success?: boolean; error?: string; }