Skip to main content
Glama

scroll

Scroll web pages in specified directions (up, down, left, right) with customizable pixel counts and scrolling behavior to enhance browser automation tasks.

Instructions

Scroll the page in the specified direction

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
behaviorNoScrolling behaviorauto
directionNoDirection to scrolldown
pixelsNoNumber of pixels to scroll (optional)

Implementation Reference

  • Handler function for the 'scroll' tool that parses input parameters using ScrollSchema, computes scroll distance, and executes scrolling in the specified direction using Playwright's page.evaluate method on the current page.
    case 'scroll': { if (!currentPage) { throw new Error('No browser page available. Launch a browser first.'); } const params = ScrollSchema.parse(args); const { direction, pixels, behavior } = params; // Determine scroll distance const scrollDistance = pixels !== undefined ? pixels : 100; // Scroll the page await currentPage.evaluate(({ direction, scrollDistance, behavior }) => { let newX = window.scrollX; let newY = window.scrollY; switch (direction) { case 'down': newY += scrollDistance; break; case 'up': newY -= scrollDistance; break; case 'right': newX += scrollDistance; break; case 'left': newX -= scrollDistance; break; } window.scrollTo({ top: newY, left: newX, behavior: behavior }); }, { direction, scrollDistance, behavior }); return { content: [ { type: 'text', text: `Scrolled ${direction} by ${scrollDistance} pixels` } ] }; }
  • Zod schema defining the input parameters for the scroll tool: direction (up/down/left/right), optional pixels, and behavior (auto/smooth).
    const ScrollSchema = z.object({ direction: z.enum(['up', 'down', 'left', 'right']).default('down'), pixels: z.number().optional(), behavior: z.enum(['auto', 'smooth']).default('auto') });
  • src/index.ts:362-386 (registration)
    Registration of the 'scroll' tool in the ListTools response, including name, description, and inputSchema matching the ScrollSchema.
    { name: 'scroll', description: 'Scroll the page in the specified direction', inputSchema: { type: 'object', properties: { direction: { type: 'string', enum: ['up', 'down', 'left', 'right'], default: 'down', description: 'Direction to scroll' }, pixels: { type: 'number', description: 'Number of pixels to scroll (optional)' }, behavior: { type: 'string', enum: ['auto', 'smooth'], default: 'auto', description: 'Scrolling behavior' } } } },

Other Tools

Related 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/Wladastic/AutoProbeMCP'

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