Skip to main content
Glama
alderban107

hyprland-mcp

by alderban107

key_press

Send keyboard shortcuts to Hyprland windows, optionally targeting specific applications without changing window focus. Use key combinations like "ctrl+c" or "alt+F4" for desktop automation.

Instructions

Press a key combination.

Uses Hyprland's native sendshortcut — can target specific windows without focusing them.

Args: keys: Key combo string like "ctrl+c", "alt+F4", "super+1", "Return" target: Optional window selector to send the key to (e.g. "class:firefox"). If omitted, sends to the active window.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keysYes
targetNo

Implementation Reference

  • The core implementation of the key_press functionality that dispatches the command to hyprctl.
    async def key_press(keys: str, target: str | None = None) -> None:
        """Press a key combination using hyprctl dispatch sendshortcut.
    
        Args:
            keys: Key combo like "ctrl+c", "alt+F4", "Return", "super+1"
            target: Optional window selector
        """
        # Parse "ctrl+shift+c" into mods="CTRL SHIFT" and key="c"
        parts = keys.split("+")
        if len(parts) == 1:
            mods = ""
            key = parts[0]
        else:
            key = parts[-1]
            mods = " ".join(p.upper() for p in parts[:-1])
    
        target_str = target or ""
        await hyprctl.dispatch("sendshortcut", f"{mods}, {key}, {target_str}")
  • The MCP tool registration for key_press.
    @mcp.tool()
    async def type_text(text: str, delay_ms: int = 0) -> str:
        """Type text as if from a keyboard.
    
        Args:
            text: The text to type
            delay_ms: Delay between keystrokes in milliseconds (0 = instant)
        """
        from . import input as inp
        await inp.type_text(text, delay_ms=delay_ms)
        return f"Typed {len(text)} characters"
    
    
    @mcp.tool()
    async def key_press(keys: str, target: str | None = None) -> str:

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