Skip to main content
Glama
webdriverio

WebDriverIO MCP Server

Official

scroll

Scroll the page vertically by a pixel amount. Choose direction up or down for browser automation.

Instructions

Scrolls the page vertically by a pixel amount. Browser-only — for mobile scrolling use swipe. Only supports up/down; no horizontal scrolling.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directionYesScroll direction
pixelsNoNumber of pixels to scroll

Implementation Reference

  • The core execution logic for the scroll tool: validates session type is 'browser', computes scroll amount (positive for down, negative for up), and executes window.scrollBy(0, amount) via browser.execute(). Returns success or error text.
    export const scrollAction = async (direction: 'up' | 'down', pixels = 500): Promise<CallToolResult> => {
      try {
        const browser = getBrowser();
        const state = getState();
        const metadata = state.sessionMetadata.get(state.currentSession);
        const sessionType = metadata?.type;
    
        if (sessionType !== 'browser') {
          throw new Error('scroll only works in browser sessions. For mobile, use the swipe tool.');
        }
    
        const scrollAmount = direction === 'down' ? pixels : -pixels;
        await browser.execute((amount) => {
          window.scrollBy(0, amount);
        }, scrollAmount);
    
        return {
          content: [{ type: 'text', text: `Scrolled ${direction} ${pixels} pixels` }],
        };
      } catch (e) {
        return {
          isError: true,
          content: [{ type: 'text', text: `Error scrolling: ${e}` }],
        };
      }
  • The scrollTool callback adapter: destructures direction/pixels and delegates to scrollAction.
    export const scrollTool: ToolCallback = async ({ direction, pixels = 500 }: { direction: 'up' | 'down'; pixels?: number }) =>
      scrollAction(direction, pixels);
  • scrollToolDefinition: defines tool name ('scroll'), description, annotations, and input schema (direction enum up/down, optional pixels with default 500).
    export const scrollToolDefinition: ToolDefinition = {
      name: 'scroll',
      description: 'Scrolls the page vertically by a pixel amount. Browser-only — for mobile scrolling use swipe. Only supports up/down; no horizontal scrolling.',
      annotations: { title: 'Scroll Page', destructiveHint: false },
      inputSchema: {
        direction: z.enum(['up', 'down']).describe('Scroll direction'),
        pixels: z.number().optional().default(500).describe('Number of pixels to scroll'),
      },
    };
  • src/server.ts:132-132 (registration)
    Registration of the scroll tool in the MCP server, wrapping scrollTool with withRecording('scroll', scrollTool).
    registerTool(scrollToolDefinition, withRecording('scroll', scrollTool));
  • Code generator for the scroll recording step: generates 'await browser.execute(() => window.scrollBy(0, scrollAmount));' based on direction and pixels.
    case 'scroll': {
      const scrollAmount = (p.direction as string) === 'down' ? (p.pixels as number) : -(p.pixels as number);
      return `await browser.execute(() => window.scrollBy(0, ${scrollAmount}));`;
    }
Behavior4/5

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

Annotations already indicate destructiveHint=false and title. The description adds that scrolling is browser-only and pixel-based, with no horizontal support. It does not contradict annotations. However, it could mention whether scrolling is smooth or instant, or behavior when reaching limits, but for a simple scroll action this is sufficient.

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 concise sentences, each serving a distinct purpose: purpose, usage guideline, and constraint. No redundant or superfluous content. Information is front-loaded with the action stated first.

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 simple scalar scroll tool with full schema coverage and clear annotations, the description covers all necessary aspects: action, scope, platform, limits, and alternative. No output schema needed as return is trivial (void). Context is fully provided.

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%, so baseline is 3. The description adds 'by a pixel amount' and 'only up/down', which mirrors the enum and parameter description. It does not provide additional semantic detail beyond what the schema already conveys. Hence, no added value.

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 clearly states the action ('scrolls'), the resource ('page'), and the specific scope ('vertically by a pixel amount'). It also specifies 'Browser-only' and distinguishes from the sibling 'swipe' tool for mobile scrolling. This makes the purpose unambiguous and aids in tool selection.

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 ('Browser-only') and when to use an alternative ('for mobile scrolling use swipe'). It also notes that only up/down scrolling is supported, no horizontal. This provides clear context and exclusion criteria.

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/webdriverio/mcp'

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