Skip to main content
Glama

select_text_range

Select a specific substring within a DOM element using start and end character offsets to highlight exact text, such as a sentence in a paragraph.

Instructions

Select a specific substring within a DOM element by character offsets. Uses the Range API to highlight text from startOffset to endOffset within the element's text content. Essential for precise text selection like highlighting a specific sentence in a paragraph. Returns the selected text for verification. For selecting an entire element's text, use double-click instead. Related: double_click (select entire word/element text), get_text (read element text to determine offsets), get_dom_snapshot (find container selectors). Multi-agent: agent-scoped tabs; cross-agent reject with TAB_NOT_OWNED; cap configurable (default 8, 1-64). Pass tab_id only when this agent owns multiple tabs; auto-resolves otherwise. RETURNS change_report: when this tool runs, the response includes a change_report field with a compact diff of what the action mutated (URL, dialogs_opened, nodes_added, nodes_removed, attrs_changed, inputs_changed, focus_shift). Use this to learn the consequence without calling read_page next. If the report exceeds the size cap, change_report.truncated:true and change_report_hint are set; call read_page for the full state.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clientYesAllowlisted client label. Validated against the shared v0.9.36 server/extension allowlist (see mcp/src/tools/visual-session.ts -- MCP_VISUAL_CLIENT_LABELS). Required.
tab_idNoOptional. Tab id this action targets. Omit when the calling agent owns exactly one tab; pass to disambiguate when the agent owns multiple. Single-tab agents and legacy popup/sidepanel/autopilot do not need to pass this.
is_finalNoWhen true, the visual session clears immediately after this tool resolves. Optional (default false).
selectorYesCSS selector or element reference for the container element (e.g., "#mw-content-text p:nth-of-type(3)" for third paragraph)
endOffsetYesCharacter offset where selection ends (exclusive, like string.substring)
startOffsetYesCharacter offset where selection starts (0-based, counting from start of element text content)
visual_reasonYesShort human-readable reason shown in the overlay (for example, "Logging in to GitHub"). Required.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.6/5.0
Behavior5/5

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

No annotations are provided, so the description carries the full burden and does so: it discloses agent-scoped tab ownership, the TAB_NOT_OWNED rejection path, a configurable concurrent-session cap (default 8, range 1-64), when tab_id must be passed, and that the result includes a change_report diff with truncation flags. That is unusually rich behavioral disclosure for an unannotated tool.

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 in the first sentence and the alternative routing follows immediately, but the trailing multi-agent and change_report blocks are verbose boilerplate that inflates the definition relative to the simplicity of the action. Still organized and skimmable.

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?

With no output schema, the description supplies the return information itself (selected text for verification, change_report contents and truncation behavior) plus scoping, error and cap behavior. Nothing an agent needs to call this 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 description coverage is 100%, so the baseline is 3. The description restates offset semantics (startOffset/endOffset within the element's text content) and the multi-tab tab_id rule, but this largely duplicates the schema descriptions rather than adding new syntax or constraints.

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+resource (select a substring by character offsets within a DOM element) and immediately distinguishes itself from the sibling double_click for whole-element selection. An agent can tell it apart from get_text and double_click 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?

Explicit when-to-use ('precise text selection like highlighting a specific sentence') paired with a named alternative and its condition ('For selecting an entire element's text, use double-click instead'). It also lists prerequisite siblings (get_text to determine offsets, get_dom_snapshot to find selectors), leaving nothing to inference.

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