Skip to main content
Glama

press_key

Simulates user keyboard input in Java Swing apps, sending keys, shortcuts, or sequences to the focused component or a specified ref, and can answer modal dialogs.

Instructions

Press keys like a user: "Enter", "Escape", "Tab", "Shift+Tab", "Up", "F5", "Ctrl+S", "Alt+F4", or several separated by spaces ("Tab Tab Enter"). Keys go to the component that has the keyboard focus (marked "focused" in the snapshot), or to ref after focusing it, so key bindings, menu shortcuts, the default button and focus traversal work as for a user. Without ref, keys go to the open modal dialog if there is one. The application window does not need to be in front. The result says where the focus is afterwards. Waits first (up to timeoutMs) until the component is visible, enabled, editable where needed, and not blocked by a modal dialog or busy overlay, so no wait_for is needed for a component that is about to become usable. Returns the new snapshot.

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": {
      "key": "<key>"
    },
    "name": "press_key"
  }
}

Input Schema

NameRequiredDescriptionDefault
keyYesKey or chord, e.g. Enter, Escape, Ctrl+S, Shift+Tab, F2; several separated by spaces
refNoComponent to focus first (default: the focused component)
modeNokeys (default): key events inside the application; os: real keyboard through the operating system (brings the window to the front)
dialogNoAnswer the modal dialog this action opens with this button (text, or ok/yes/no/cancel); its message is reported. An error if no dialog opens within 3 s
timeoutMsNoHow long to wait for the component to become usable (default 10000)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.3/5.0
Behavior5/5

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

With zero annotations, the description carries the full burden and does so thoroughly: it explains focus targeting, modal-dialog fallback, dialog auto-answering via the 'dialog' param (with a 3 s error condition), wait-until-usable semantics bounded by timeoutMs, that the app window need not be in front, and that focus location plus a new snapshot are returned. This is well beyond what a bare 'press key' tool would convey.

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?

It is a dense but front-loaded paragraph: key examples first, then focus/dialog targeting rules, then waiting, then return value. Almost every sentence carries operational information, though the run-on middle sentences could be split into bullets for faster scanning.

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

Completeness5/5

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

For a five-parameter mutation tool with no annotations and no output schema, the description covers the missing pieces: failure conditions (3 s dialog timeout), waiting behavior, focus outcome, and the returned snapshot. An agent has everything needed to call it correctly the first time.

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 coverage is 100%, so the schema already documents all five parameters and the baseline is 3. The description nonetheless adds interaction semantics the schema does not spell out, notably that 'ref' is focused first, that no-ref presses land on the active modal dialog, that 'dialog' answers the dialog the action opens within a 3 s window, and that `mode: os` fronts the window.

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

Purpose4/5

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

The description opens with a specific verb-plus-resource ('Press keys like a user') and enumerates concrete key examples, chords, and multi-key sequences, so an agent immediately knows what the tool does. It implies but never explicitly states the boundary with the sibling 'type_text' (literal text entry), so differentiation from the nearest alternative must be inferred.

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?

It gives clear routing rules: keys go to the focused component, or to 'ref' after focusing it, and without a ref they go to the open modal dialog. It also states that no wait_for call is needed because the tool pre-waits, and that 'os' mode brings the window to the front. There is no explicit when-not guidance or named alternative for plain text typing.

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