Skip to main content
Glama

java_send_keys

Destructive

Sends keyboard shortcuts such as Alt+Y or Ctrl+Shift+S to the focused Java window; focus the target window first if the chord appears to do nothing.

Instructions

Send a keyboard shortcut — alt+y, ctrl+shift+s — to the window.

Use it for an action the application only exposes as a chord: a menu accelerator, a toolbar shortcut, a keystroke a canvas-drawn control listens for.

Nothing is focused and nothing is clicked. The chord goes to whichever window currently has the keyboard focus. That is deliberate on pyjab's side: clicking a control to focus its window would activate that control, and a shortcut usually exists to avoid exactly that.

So if a call seems to do nothing, the window probably does not have focus — and attaching does not focus it (measured in pyjab#180). Call java_focus_window(session_id=...) first and read what it reports: it says whether the window came forward, which is the fact this tool needs. (Before that tool existed this reply said to click something harmless first; that workaround is gone from the shipped text, because it activated whatever it landed on and went through a locator that could have gone stale — which is the thing a shortcut exists to avoid.)

Chords are written with + between key names and are case-insensitive: ctrl, alt, shift, tab, enter, esc, spacebar, the arrow keys, and single letters or digits. Names may be written in any case; the function keys (F1–F24) and escape as another spelling of esc need pyjab 1.12.1, and plus for a literal + needs 1.12.2. A name that is not a key is an error rather than a silent no-op — a wrong chord acts on somebody else's application and cannot be taken back.

This needs pyjab 1.11.0, which released JABDriver.send_keys (gaozhao1989/pyjab#168 went in after 1.10.0). The call is probed rather than assumed, like every pyjab capability here: an install below the pin is told which release has the method instead of raising an AttributeError.

Args: session_id: From java_attach_window. keys: The chord, such as "alt+y".

Returns: What was sent, and the reminder that a shortcut's effect has to be looked for — this tool cannot see what the application did with it.

Errors: is_error for an unknown session, a chord whose key names pyjab does not recognise (with the name it did not recognise), or a pyjab below the pin — which names the release that has the API and what to do instead.

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": {
      "session_id": "<session_id>",
      "keys": "<keys>"
    },
    "name": "java_send_keys"
  }
}

Input Schema

NameRequiredDescriptionDefault
keysYes
session_idYes

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.5/5.0
Behavior4/5

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

Annotations already flag destructiveHint and openWorldHint, and the description adds real context beyond them: the chord lands on whatever window has focus, attaching does not focus, unknown key names raise an error rather than no-op, and a wrong chord acts on another application irreversibly. It also discloses the pyjab 1.11.0 pin and that the capability is probed rather than assumed. The only deduction is that the version-gating detail is spread across several sentences and partly duplicates the Errors section.

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

Conciseness3/5

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

Front-loaded and well organized with bold emphasis and an Errors block, but it carries meta-narrative that does not help an agent act: the parenthetical about pyjab#180 and the removed "click something harmless" workaround explains the description's own revision history. The version-pin discussion is also restated in both the body and the Errors section.

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?

An output schema exists, so return values need not be spelled out, yet the description still notes the tool cannot observe what the application did with the chord — useful for follow-up reasoning. Error cases and the version prerequisite are covered. Slightly redundant rather than incomplete.

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

Parameters5/5

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

Schema coverage is 0%, so the description must carry the parameters, and it does: session_id is sourced from java_attach_window, and keys is fully specified — `+` separator, case-insensitivity, the accepted key-name vocabulary, F1–F24 and `escape` needing 1.12.1, `plus` needing 1.12.2. That is far more than the bare string schema provides.

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 keyboard shortcut ... to the window") and immediately scopes it to chords the app only exposes as accelerators, which separates it from java_click and java_set_text. The bolded "Nothing is focused and nothing is clicked" further pins down what the tool is not.

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

Usage Guidelines5/5

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

Gives explicit when-to-use (menu accelerators, toolbar shortcuts, canvas-drawn controls) and an explicit failure path: if nothing happens, call java_focus_window(session_id=...) first and read whether the window came forward. It also names the condition that makes the tool silently ineffective, which is the main misuse risk.

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