Skip to main content
Glama

smart_scroll

Scroll elements into view across browsers, virtual lists, and native apps using CDP, UIA, or image-based detection strategies.

Instructions

Purpose: Scroll any element into the viewport — handles nested scroll layers, virtualised lists, sticky-header occlusion, and image-only fallbacks in a single call. Details: Three paths selected by strategy:'auto' (default): (1) CDP (Chrome/Edge): walks scroll ancestor chain, handles overflow:hidden (expandHidden), virtualised lists (TanStack/data-index bisect), detects sticky headers and compensates. (2) UIA (native Windows apps): uses ScrollPattern.SetScrollPercent on ancestor containers then ScrollItemPattern for final snap. (3) Image: binary-search via Win32 GetScrollInfo (exact ratio) or scrollbar-strip pixel sampling (overlay scrollbars), with dHash verification — detects no-op scrolls (Hamming < 5). All paths emit a unified response: ok, path, attempts, pageRatio (0..1), scrolled (bool), ancestors[], viewportPosition. pageRatio is the normalised vertical position of the element on the full page (0=top, 1=bottom). Set verifyWithHash:true to explicitly check that pixels changed (auto-enabled on image path). Nested scroll: ancestors[] is ordered outer→inner; the tool scrolls outer containers first. Virtual lists: set virtualIndex + virtualTotal for O(log n) bisect (≤6 iterations). Prefer: Use instead of scroll_to_element when: content is virtualised (React Virtualized, TanStack Virtual), multiple scroll containers nest, or scroll_to_element returns scrolled:true but the viewport did not actually move. For a simple single-container non-virtual scroll, scroll_to_element is lighter. Caveats: CDP path requires browser_connect. Cross-origin iframes are not traversed (warning returned). expandHidden mutates live CSS (overflow:auto); previous value is stored in data-dt-prev-overflow and restored on the next smart_scroll call (or after 30 s). Image path cannot determine whether the target element is in-view — viewportPosition is null. Call screenshot(detail='text') afterwards to verify. UIA ScrollPattern may not be available in all native apps — falls through to image path. Examples: smart_scroll({target: '#create-release-btn'}) — CDP, nested container, no virtual list smart_scroll({target: '[data-index]', virtualIndex: 500, virtualTotal: 10000}) — TanStack virtual list smart_scroll({target: 'Create Release', windowTitle: 'File Explorer', strategy: 'uia'}) — native UIA smart_scroll({target: 'readme section', windowTitle: 'MyApp', strategy: 'image', hint: 'below'}) — image binary-search

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetYesCSS selector (Chrome/Edge) or partial UIA name (native apps). For CDP path, must be a valid CSS selector (starts with #, ., tag, or [ ). For UIA path, a partial name match against element Name property.
windowTitleNoPartial window title. Required for UIA and image paths. For CDP path, optional.
tabIdNoCDP tab ID (Chrome path only). Omit for first page tab.
portNoCDP port (default 9222)
strategyNoauto (default): try CDP → UIA → image in order. cdp: Chrome/Edge only. uia: native Windows UIA. image: image + Win32 binary-search.auto
directionNoScroll direction. into-view: scroll until target element is visible (default). Other values scroll unconditionally.into-view
inlineNoVertical alignment after scroll (CDP path). Default: center.center
maxDepthNoMax number of ancestor scroll containers to walk. Default 3.
retryCountNoMax scroll attempts (image path binary-search). Default 3, cap 4.
verifyWithHashNoVerify scroll effectiveness via perceptual hash comparison. Automatically enabled for image path.
virtualIndexNoTarget row index in a virtualised list (0-based). Enables direct TanStack/data-index seeking.
virtualTotalNoTotal row count in a virtualised list. Required when virtualIndex is set.
expandHiddenNoTemporarily set overflow:hidden ancestors to overflow:auto to unlock scroll. Mutates live CSS.
hintNoScroll direction hint for binary-search (image path). Seeds lo/hi bounds to reduce attempts.
Behavior5/5

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

With no annotations provided, the description carries full burden and delivers comprehensive behavioral details: it explains three implementation paths (CDP, UIA, image) with their mechanisms, mentions CSS mutation and restoration for 'expandHidden', describes fallback behaviors, warns about cross-origin iframe limitations, and details response structure including 'pageRatio' and 'ancestors[]'.

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?

The description is well-structured with clear sections (Purpose, Details, Prefer, Caveats, Examples) but is quite lengthy. While every sentence adds value, it could be more front-loaded; the detailed implementation explanations, while useful, make it dense rather than concise.

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 complex tool with 14 parameters and no annotations/output schema, the description provides extensive context: purpose, usage guidelines, behavioral details, parameter semantics, and examples. It adequately compensates for the lack of structured fields, though the absence of output schema means return values are only partially described in the 'Details' section.

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 description coverage is 100%, so baseline is 3. The description adds significant value by explaining parameter interactions and practical usage: it clarifies how 'strategy' selects different paths, how 'virtualIndex' and 'virtualTotal' enable O(log n) bisect, when 'verifyWithHash' is auto-enabled, and provides concrete examples showing parameter combinations in context.

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?

The description starts with a clear purpose statement: 'Scroll any element into the viewport' and specifies it handles 'nested scroll layers, virtualised lists, sticky-header occlusion, and image-only fallbacks'. It distinguishes from sibling 'scroll_to_element' by explaining when to prefer each tool.

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?

The description explicitly states when to use this tool vs. 'scroll_to_element' under 'Prefer:' and 'Caveats:' sections, including specific scenarios like virtualised content, multiple scroll containers, or when scroll_to_element returns false positives. It also mentions prerequisites like 'CDP path requires browser_connect'.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Harusame64/desktop-touch-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server