Skip to main content
Glama

scroll

Automate page scrolling in specified directions (up, down, left, right) with customizable pixel counts and smooth or auto behaviors using the MCP Browser Server.

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

  • The main handler for the 'scroll' tool. Parses input using ScrollSchema, calculates scroll distance (default 100px), executes scrolling via page.evaluate using window.scrollTo based on direction.
    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 for validating 'scroll' tool inputs: direction (up/down/left/right, default 'down'), optional pixels, behavior (auto/smooth, default 'auto').
    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:363-386 (registration)
    Tool registration in the ListTools response, defining name 'scroll', description, and inputSchema matching 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' } } } },

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/mcp-browser-server'

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