Skip to main content
Glama

browser_select_frame

Execute JavaScript in a specific browser frame by its index, including cross-site frames, or return that frame's text when no code is provided.

Instructions

Execute JavaScript in a specific frame by frame index, through the Chrome debugger in that frame's own context - also a frame from another site. Use browser_list_frames first to find the right index. A returned promise is awaited; without code it returns the frame's text (first 5000 characters). The frame is identified by a one-time mark the extension puts in that frame's document, not by its address or position; if the mark is not found, nothing is run (error frame-not-reachable, and retry says whether calling again can help; a frame whose document is replaced while the call looks for it gives retry: true). The call answers within 29.5 s; if the time runs out before the code is sent, the answer is error call-timeout with sent:false (nothing ran). If no answer reaches the server within 45 s (Chrome itself stalled), the answer is error no-answer with sent:"unknown": the code MAY have run, it is not repeated, and you should call again only if it is safe to run twice.

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": {
      "frame_index": "<frame_index>"
    },
    "name": "browser_select_frame"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeNoJavaScript EXPRESSION to evaluate in the frame (default: returns its text content)
partitionNoRun this call in a partition from browser_partition (an id like "p1"). Leave it out for the default partition. An unknown or closed id is an error; the call is never sent to the default partition instead.
frame_indexYesFrame index from browser_list_frames (0 = main frame)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.33.0
    • addedInput schema / properties / partition
      Added value: +{
      +  "description": "Run this call in a partition from browser_partition (an id like \"p1\"). Leave it out for the default partition. An unknown or closed id is an error; the call is never sent to the default partition instead.",
      +  "type": "string"
      +}
  2. Changed1 schema field changedv1.31.0
    • changedInput schema / properties / code / description
      Previous value: -"JavaScript to execute in the frame (default: returns text content)"New value: +"JavaScript EXPRESSION to evaluate in the frame (default: returns its text content)"
  3. First observedv1.0.0

TDQS

A4.1/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does: it discloses the frame-resolution mechanism (one-time mark, not address/position), the exact timeout budget (29.5 s), three distinct error shapes with their semantics (frame-not-reachable, call-timeout with sent:false, no-answer with sent:"unknown"), and the non-idempotency warning that the code may have run and should only be retried if safe.

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?

Purpose is front-loaded, followed by prerequisite, return behavior, then failure modes in order of likelihood. The timeout sentence is dense and parenthetical, but every clause conveys operational information an agent needs rather than filler.

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?

No output schema and no annotations, yet the description covers return value, truncation, all failure modes, timing budgets, and retry safety for a tool with non-trivial async and idempotency hazards. Nothing an agent needs in order to call it correctly 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 coverage is 100% and already documents all three parameters, including the default text-return of code and the frame_index source. The description largely restates that (index from browser_list_frames, no-code returns first 5000 characters) and adds little new per-parameter meaning, so the baseline 3 applies.

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 ('Execute JavaScript in a specific frame by frame index ... in that frame's own context') and adds the cross-origin case ('also a frame from another site'). It does not explicitly contrast itself with the sibling browser_execute_script, so an agent must infer that this is the frame-scoped variant, but the frame-scoping is unambiguous.

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 an explicit prerequisite ('Use browser_list_frames first to find the right index') and an implied second use case ('without code it returns the frame's text'), plus retry guidance tied to specific error outcomes. It does not state exclusions such as when to prefer browser_execute_script instead.

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