Skip to main content
Glama

ui_press_key

ui_press_key

Presses a specified key or key combination on a focused or CSS-selected element to trigger form submission, navigation, or other browser UI interactions during automated tests.

Instructions

Press a key (Playwright key name such as Enter, Tab, Escape, ArrowDown, or a combo like Control+a). With selector it presses on that element; without, on whatever has focus. Enter in a text input submits its form. Selectors containing "nth=" are positional: call ui_get_page_state again after the page changes before reusing them.

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": "ui_press_key"
  }
}

Input Schema

NameRequiredDescriptionDefault
keyYesPlaywright key name, e.g. Enter, Tab, Escape, ArrowDown
selectorNoCSS selector, or the `selector` value of an element from ui_get_page_state, passed unchanged; omit to press on the focused element
session_idNoWhich open session to act on, as returned by ui_start_session. Optional with one open session; required when several are open.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.9/5.0
Behavior3/5

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

No annotations are supplied, so the description carries the whole burden. It does disclose real behavior a schema cannot: focus fallback, the implicit form submission side effect, and the staleness hazard of 'nth=' selectors, but it says nothing about waiting/auto-wait, failure modes for a missing element, or what the call returns.

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?

Three tight sentences: key syntax first, targeting semantics second, then the trap about positional selectors. No restatement of the name or filler, and the most error-prone detail is placed last where it is read just before invocation.

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 3-parameter tool with no annotations and no output schema, the definition covers the parts an agent could get wrong: key format, target resolution, and selector reuse after page mutation. It leaves open what happens when the target is absent or disabled, which is a modest gap rather than a blocking one.

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 baseline is 3; the description still earns above that by adding combo syntax ('Control+a') beyond the schema's single-key examples and by explaining that the `selector` string is passed through unchanged and may be positional. Only `session_id` is left entirely to the schema.

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?

States a specific verb and resource ('Press a key') and immediately scopes the accepted key vocabulary with Playwright names and combos. The selector-vs-focus split makes the operation unambiguous, though it never contrasts itself with the adjacent typing tool (ui_type), leaving that distinction to 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?

Clearly states the two invocation modes (with `selector` vs. focused element) and adds a concrete consequence case ('Enter in a text input submits its form'), plus a re-query rule for positional selectors. It stops short of naming alternatives or exclusions, so it is context-rich but not a full when/when-not guide.

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