Skip to main content
Glama

Press key in browser

browser_press_key
Destructive

Press a key or shortcut in a background Chrome tab, optionally with modifiers, to submit forms, navigate fields, edit text, or trigger page actions without affecting the user's windows.

Instructions

Press a key in one of the agent's tabs, optionally with modifiers held: Enter to submit, Tab to move to the next field, Escape, Backspace, Delete, arrows, Home/End, PageUp/PageDown, F1-F12, a character, or a shortcut such as key='a' modifiers=['cmd'] to select all in the focused field. Works in a background tab: the key goes to that tab's page only, never to the user's windows, and browser shortcuts (close tab, quit) never reach Chrome itself. Editing shortcuts (select all, copy, cut, paste, undo) work with cmd or ctrl on every platform. The reply says where focus is and how many characters are selected. Tab fails rather than leave focus where it was, and Backspace checks the focused field changed. Use browser_type for text and browser_fill to replace a field's value. Never use the desktop press_key or type_text for a Chrome tab: those go to whichever Chrome window is in front, which can be the user's. Enter can submit forms and Backspace deletes, so check the page state with browser_snapshot first.

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

Input Schema

NameRequiredDescriptionDefault
keyYesKey to press: Enter, Tab, Escape, Backspace, Delete, ArrowUp, ArrowDown, ArrowLeft, ArrowRight, Home, End, PageUp, PageDown, Space, F1-F12 or a single character. A combination such as 'cmd+a' is accepted too.
tab_idYestab_id of one of the agent's tabs, from browser_open_tab or browser_list_tabs
modifiersNoModifier keys held during the press. cmd is Command on macOS and the Windows key elsewhere; for editing shortcuts cmd and ctrl mean the same on every platform.
session_idNoStable task or thread ID. Pass the same value on every browser call for this task. Different IDs isolate tabs and cleanup within one MCP process. Omit for the default process session.
return_stateNoAppend a current snapshot and readiness status after acting. Without wait_for_selector, only a short pause and bounded navigation wait are used; SPA readiness is not guaranteed. Snapshot indices replace earlier ones. A timeout does not mean the action failed: re-observe with browser_snapshot before repeating it.
wait_timeout_msNoBound for wait_for_selector in milliseconds (default 8000, maximum 10000; 0 checks once). Requires wait_for_selector. Timeout preserves action success and returns current state. Use browser_snapshot with the same wait to re-observe without repeating an action.
wait_for_selectorNoWait for any visible element matching this CSS selector in the page or any of its frames (iframes), including open shadow roots (web components); a timeout says how many frames could not be searched. On actions requires return_state=true. Returns readiness met, timeout or error; only this condition is checked, not general app readiness. Prefer a selector specific to the expected new UI.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.14.0
    • changedInput schema / properties / wait_for_selector / description
      Previous value: -"Wait for any visible element matching this CSS selector in the page, including open shadow roots (web components); child frames are not searched, and a timeout says how many were visible. On actions requires return_state=true. Returns readiness met, timeout or error; only this condition is checked, not general app readiness. Prefer a selector specific to the expected new UI."New value: +"Wait for any visible element matching this CSS selector in the page or any of its frames (iframes), including open shadow roots (web components); a timeout says how many frames could not be searched. On actions requires return_state=true. Returns readiness met, timeout or error; only this condition is checked, not general app readiness. Prefer a selector specific to the expected new UI."
  2. Changed5 schema fields changedv0.13.0
    • changedInput schema / properties / key / description
      Previous value: -"Key to press"New value: +"Key to press: Enter, Tab, Escape, Backspace, Delete, ArrowUp, ArrowDown, ArrowLeft, ArrowRight, Home, End, PageUp, PageDown, Space, F1-F12 or a single character. A combination such as 'cmd+a' is accepted too."
    • removedInput schema / properties / key / enum
      Removed value: -[
      -  "Enter",
      -  "Tab",
      -  "Escape",
      -  "Backspace"
      -]
    • addedInput schema / properties / key / maxLength
      Added value: +40
    • addedInput schema / properties / key / minLength
      Added value: +1
    • addedInput schema / properties / modifiers
      Added value: +{
      +  "description": "Modifier keys held during the press. cmd is Command on macOS and the Windows key elsewhere; for editing shortcuts cmd and ctrl mean the same on every platform.",
      +  "items": {
      +    "enum": [
      +      "cmd",
      +      "ctrl",
      +      "alt",
      +      "shift"
      +    ],
      +    "type": "string"
      +  },
      +  "maxItems": 4,
      +  "type": "array"
      +}
  3. Changed1 schema field changedv0.11.2
    • changedInput schema / properties / wait_for_selector / description
      Previous value: -"Wait for any visible element matching this CSS selector in the top-level document (not frames or shadow roots). On actions requires return_state=true. Returns readiness met, timeout or error; only this condition is checked, not general app readiness. Prefer a selector specific to the expected new UI."New value: +"Wait for any visible element matching this CSS selector in the page, including open shadow roots (web components); child frames are not searched, and a timeout says how many were visible. On actions requires return_state=true. Returns readiness met, timeout or error; only this condition is checked, not general app readiness. Prefer a selector specific to the expected new UI."
  4. Changed3 schema fields changedv0.7.1
    • changedInput schema / properties / return_state / description
      Previous value: -"After acting, wait for the page to settle (and finish loading, if the action navigated) and append a fresh browser_snapshot of this tab, so you can pick the next index in the same call. Its indices replace earlier ones."New value: +"Append a current snapshot and readiness status after acting. Without wait_for_selector, only a short pause and bounded navigation wait are used; SPA readiness is not guaranteed. Snapshot indices replace earlier ones. A timeout does not mean the action failed: re-observe with browser_snapshot before repeating it."
    • addedInput schema / properties / wait_for_selector
      Added value: +{
      +  "description": "Wait for any visible element matching this CSS selector in the top-level document (not frames or shadow roots). On actions requires return_state=true. Returns readiness met, timeout or error; only this condition is checked, not general app readiness. Prefer a selector specific to the expected new UI.",
      +  "maxLength": 2000,
      +  "minLength": 1,
      +  "type": "string"
      +}
    • addedInput schema / properties / wait_timeout_ms
      Added value: +{
      +  "description": "Bound for wait_for_selector in milliseconds (default 8000, maximum 10000; 0 checks once). Requires wait_for_selector. Timeout preserves action success and returns current state. Use browser_snapshot with the same wait to re-observe without repeating an action.",
      +  "maximum": 10000,
      +  "minimum": 0,
      +  "type": "integer"
      +}
  5. Changed1 schema field changedv0.5.2
    • addedInput schema / properties / return_state
      Added value: +{
      +  "description": "After acting, wait for the page to settle (and finish loading, if the action navigated) and append a fresh browser_snapshot of this tab, so you can pick the next index in the same call. Its indices replace earlier ones.",
      +  "type": "boolean"
      +}
  6. Changed1 schema field changedv0.4.3
    • addedInput schema / properties / session_id
      Added value: +{
      +  "description": "Stable task or thread ID. Pass the same value on every browser call for this task. Different IDs isolate tabs and cleanup within one MCP process. Omit for the default process session.",
      +  "maxLength": 128,
      +  "minLength": 1,
      +  "type": "string"
      +}
  7. Changed2 schema fields changedv0.3.1
    • addedInput schema / properties / key / description
      Added value: +"Key to press"
    • addedInput schema / properties / tab_id / description
      Added value: +"tab_id of one of the agent's tabs, from browser_open_tab or browser_list_tabs"
  8. First observedv0.3.0

TDQS

A4.6/5.0
Behavior5/5

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

Goes well past the destructiveHint annotation: the key is scoped to the background tab and never reaches the user's windows, browser-level shortcuts are suppressed, editing shortcuts are normalized across cmd/ctrl, and Tab/Backspace have defined failure/verification semantics. It even describes the reply contents (focus location, selection length).

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 action and key list, and every sentence carries information, but it is delivered as one dense paragraph and repeats the tab-scoping idea across a couple of clauses. Slightly more structure would help 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 7-parameter destructive tool with no output schema, the description covers side effects, failure modes, return payload, and prerequisite observation. Nothing an agent needs to invoke it safely is missing.

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?

Schema description coverage is 100%, so the input schema already documents key, modifiers, and the wait parameters thoroughly. The description only adds a usage example (key='a' with modifiers=['cmd']) and platform equivalence for cmd/ctrl, both of which are largely restated from the schema; baseline 3 applies.

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 precise verb+resource ('press a key in one of the agent's tabs') and enumerates the key classes it accepts. It explicitly disambiguates from browser_type, browser_fill, and the desktop press_key/type_text, so an agent can pick it without opening a schema.

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?

Names the alternatives and the conditions that select them ('Use browser_type for text', 'browser_fill to replace a field's value') and excludes the desktop tools with a concrete reason. It also gives a precondition ('check the page state with browser_snapshot first') for the destructive cases.

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