Skip to main content
Glama
alderban107

hyprland-mcp

by alderban107

mouse_drag

Drag the mouse from specified start to end coordinates while holding a button, enabling precise screen interactions in Hyprland desktop automation.

Instructions

Drag from one position to another.

Args: start_x: Starting X coordinate start_y: Starting Y coordinate end_x: Ending X coordinate end_y: Ending Y coordinate button: Mouse button to hold during drag ("left", "right", "middle")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_xYes
start_yYes
end_xYes
end_yYes
buttonNoleft

Implementation Reference

  • The actual implementation of the drag logic using ydotool to simulate button-down, move, and button-up events.
    async def drag(
        start_x: int,
        start_y: int,
        end_x: int,
        end_y: int,
        button: str = "left",
    ) -> None:
        """Drag from one position to another."""
        require_tool("ydotool")
        down_code = _BUTTON_DOWN.get(button)
        up_code = _BUTTON_UP.get(button)
        if down_code is None:
            raise InputError(f"Unknown button: {button}")
    
        # Move to start position
        await move_cursor(start_x, start_y)
        await asyncio.sleep(0.05)
    
        # Button down
        proc = await asyncio.create_subprocess_exec(
            "ydotool", "click", down_code,
            stdout=asyncio.subprocess.PIPE,
            stderr=asyncio.subprocess.PIPE,
        )
        await proc.communicate()
    
        await asyncio.sleep(0.05)
    
        # Move to end position
        await move_cursor(end_x, end_y)
        await asyncio.sleep(0.05)
    
        # Button up
        proc = await asyncio.create_subprocess_exec(
            "ydotool", "click", up_code,
            stdout=asyncio.subprocess.PIPE,
            stderr=asyncio.subprocess.PIPE,
        )
        await proc.communicate()
  • MCP tool registration for mouse_drag.
    async def mouse_drag(
        start_x: int,
        start_y: int,
        end_x: int,
        end_y: int,
        button: str = "left",
    ) -> str:
        """Drag from one position to another.
    
        Args:
            start_x: Starting X coordinate
            start_y: Starting Y coordinate
            end_x: Ending X coordinate
            end_y: Ending Y coordinate
            button: Mouse button to hold during drag ("left", "right", "middle")
        """
        from . import input as inp
        await inp.drag(start_x, start_y, end_x, end_y, button)
        return f"Dragged {button} from ({start_x},{start_y}) to ({end_x},{end_y})"

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/alderban107/hyprland-mcp'

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