Skip to main content
Glama

press_key

Send a key or key combination to an app using xdotool-style syntax to trigger shortcuts, menus, or game inputs; optionally set hold duration.

Instructions

Send a key or key combination to the app, using xdotool-style syntax such as Return or ctrl+a. super is Command on macOS, the Windows key on Windows and Super on Linux. Windows holds an omitted duration for 50 ms so frame-polled games can detect taps. If state warns of native IME mode, letter keys may reach the input method; type_text and paste are unaffected. Returns the updated accessibility state after the action; a separate text-only get_app_state is normally unnecessary. Request a new screenshot before later coordinate input.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "app": "<app>",
      "key": "<key>"
    },
    "name": "press_key"
  }
}

Input Schema

NameRequiredDescriptionDefault
appYesApp name or full app path; macOS bundle ID; macOS and Windows pid:<pid>; Windows process name, window title fragment, or Start-menu shortcut name; Linux desktop entry name, executable name or window title fragment
keyYes
scopeNomacOS and Windows: element index from the latest returned state. Read only its retained subtree, renumbered from [1], including after actions. If it disappears, return the whole window with a notice. Linux returns INVALID_ARGUMENT.
durationNoSeconds to hold before releasing, from 0 to 30. Windows press_key defaults to 0.05 seconds when omitted; explicit 0 remains allowed.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.9.0

TDQS

A4.1/5.0
Behavior4/5

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

Annotations only say it is a non-read-only, open-world action; the description adds real context beyond that: the platform mapping of 'super', the Windows 50 ms default hold so frame-polled games register taps, the IME caveat where letter keys may be intercepted, and the fact that it returns updated accessibility state. It does not say whether the target app must be focused/activated first, which is the main behavioral gap for a keystroke injector.

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

Conciseness4/5

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

Front-loaded with the core action and syntax, then caveats in decreasing priority order; every sentence carries operative information. It is dense and slightly run-on across platform, IME, and follow-up concerns, but no sentence is pure filler.

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?

For a 4-parameter input-injection tool with no output schema, it covers syntax, platform modifiers, default hold duration, IME failure mode, the return value, and the required screenshot follow-up. The remaining gap is precondition handling (whether the app must be activated or focused), which is only inferable from the sibling list.

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

Parameters3/5

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

The 'key' parameter has no schema description, and the description compensates with syntax examples (Return, ctrl+a) plus the 'super' platform mapping, which is genuine added meaning. However the 'scope' parameter is not addressed at all and the Windows duration default is already documented in the schema, so the net gain over the structured fields is moderate at 75% coverage.

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?

States a specific verb and resource ('Send a key or key combination to the app') and immediately disambiguates from the text-entry siblings with 'xdotool-style syntax such as Return or ctrl+a'. An agent can tell this apart from type_text and paste without opening any schema.

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?

Gives clear routing advice in two places: under native IME mode it points to type_text and paste as the unaffected alternatives, and it says a separate text-only get_app_state is normally unnecessary after a call. It also prescribes a follow-up (request a new screenshot before later coordinate input). It never explicitly says 'use type_text rather than press_key for string input', so the alternative-selection rule is implied rather than stated.

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