Skip to main content
Glama
Rainmen-xia

Chrome Debug MCP Server

by Rainmen-xia

hover

Simulate mouse hover at specified coordinates in a Chrome browser session using the Chrome Debug MCP Server for precise browser automation tasks.

Instructions

将鼠标悬停在指定坐标位置

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
coordinateYes悬停位置的坐标,格式为 'x,y'

Implementation Reference

  • The core handler function for the 'hover' tool. It moves the mouse to the specified coordinate using Puppeteer, handles potential network activity after the hover, takes a screenshot, and returns the result.
    async hover(coordinate: string): Promise<BrowserActionResult> { return this.doAction(async (page) => { await this.handleMouseInteraction(page, coordinate, async (x, y) => { await page.mouse.move(x, y); // 小延迟以允许任何悬停效果出现 await delay(300); }); }); }
  • Input schema definition for the 'hover' tool, specifying the required 'coordinate' parameter as a string in 'x,y' format.
    name: "hover", description: "将鼠标悬停在指定坐标位置", inputSchema: { type: "object", properties: { coordinate: { type: "string", description: "悬停位置的坐标,格式为 'x,y'", }, }, required: ["coordinate"], }, },
  • src/index.ts:211-216 (registration)
    Registration/dispatch in the CallToolRequest handler switch statement. Validates input and delegates execution to browserSession.hover().
    case "hover": if (!args?.coordinate) { throw new Error("coordinate参数是必需的"); } result = await this.browserSession.hover(args.coordinate as string); break;
  • src/index.ts:46-163 (registration)
    Tool registration in the ListToolsRequest handler, including name, description, and schema for discovery by MCP clients.
    tools: [ { name: "launch_browser", description: "启动浏览器连接,连接到Chrome调试端口以保持登录状态", inputSchema: { type: "object", properties: { remote_host: { type: "string", description: "可选的远程Chrome主机URL (例如: http://localhost:9222)", }, }, }, }, { name: "close_browser", description: "关闭浏览器连接", inputSchema: { type: "object", properties: {}, }, }, { name: "navigate_to", description: "导航到指定URL,智能管理标签页(相同域名复用标签页)", inputSchema: { type: "object", properties: { url: { type: "string", description: "要导航到的URL", }, }, required: ["url"], }, }, { name: "click", description: "在指定坐标位置点击", inputSchema: { type: "object", properties: { coordinate: { type: "string", description: "点击位置的坐标,格式为 'x,y'", }, }, required: ["coordinate"], }, }, { name: "type_text", description: "输入文本内容", inputSchema: { type: "object", properties: { text: { type: "string", description: "要输入的文本内容", }, }, required: ["text"], }, }, { name: "scroll_down", description: "向下滚动页面一个视口高度", inputSchema: { type: "object", properties: {}, }, }, { name: "scroll_up", description: "向上滚动页面一个视口高度", inputSchema: { type: "object", properties: {}, }, }, { name: "hover", description: "将鼠标悬停在指定坐标位置", inputSchema: { type: "object", properties: { coordinate: { type: "string", description: "悬停位置的坐标,格式为 'x,y'", }, }, required: ["coordinate"], }, }, { name: "resize_browser", description: "调整浏览器窗口大小", inputSchema: { type: "object", properties: { size: { type: "string", description: "窗口大小,格式为 'width,height'", }, }, required: ["size"], }, }, { name: "get_page_content", description: "获取当前页面的HTML内容", inputSchema: { type: "object", properties: {}, }, }, ] as Tool[], };
  • Supporting helper function used by 'hover' (and 'click') to parse coordinates, perform the mouse action, monitor network requests triggered by the interaction, and wait for page stability.
    private async handleMouseInteraction( page: Page, coordinate: string, action: (x: number, y: number) => Promise<void>, ): Promise<void> { const [x, y] = coordinate.split(",").map(Number); // 设置网络请求监控 let hasNetworkActivity = false; const requestListener = () => { hasNetworkActivity = true; }; page.on("request", requestListener); // 执行鼠标操作 await action(x, y); this.currentMousePosition = coordinate; // 小延迟检查操作是否触发了任何网络活动 await delay(100); if (hasNetworkActivity) { // 如果检测到网络活动,等待导航/加载 await page .waitForNavigation({ waitUntil: ["domcontentloaded", "networkidle2"], timeout: 15000, }) .catch(async () => { // 如果networkidle2失败,尝试仅等待domcontentloaded console.log("鼠标交互后网络静默等待失败,尝试仅等待DOM"); await page.waitForNavigation({ waitUntil: ["domcontentloaded"], timeout: 15000, }).catch(() => { // 如果还是失败,就忽略,继续执行 console.log("鼠标交互后导航等待失败,继续执行"); }); }); await this.waitTillHTMLStable(page); } // 清理监听器 page.off("request", requestListener); }

Other Tools

Related Tools

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/Rainmen-xia/chrome-debug-mcp'

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