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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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:
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden and does well by disclosing key behavioral traits: it uses Hyprland's native sendshortcut, can target windows without focusing them, and defaults to the active window if target is omitted. It lacks details on error handling or rate limits, but covers essential operational context effectively.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose, followed by technical context and parameter details in a structured format. Every sentence adds value without redundancy, making it efficient and easy to parse for an AI agent.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, no annotations, but with an output schema), the description is largely complete: it explains what the tool does, when to use it, and parameter meanings. The output schema likely handles return values, so no need to detail them. It could improve by mentioning error cases or limitations, but covers the essentials well.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate, and it does by explaining both parameters: 'keys' with examples like 'ctrl+c' and 'target' with its optional nature and effect (sends to active window if omitted). It adds meaningful semantics beyond the bare schema, though it could specify format constraints more explicitly.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Press a key combination') and resource (keyboard input), distinguishing it from siblings like 'type_into' (continuous typing) and 'send_shortcut' (similar but not explicitly using Hyprland's native method). It provides a precise verb+resource combination that is immediately understandable.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description includes clear context about when to use it ('can target specific windows without focusing them') and implies alternatives by mentioning Hyprland's native sendshortcut, but does not explicitly name when-not-to-use cases or compare with all siblings like 'send_shortcut'. It provides useful guidance without being exhaustive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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