Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

scroll

Control browser page scrolling by specifying horizontal and vertical pixel amounts with optional smooth animation. Suitable for precise navigation in web automation tasks.

Instructions

Scroll the page by specified amounts with enhanced feedback

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
smoothNoWhether to use smooth scrolling animation (default: false)
xYesHorizontal scroll amount in pixels (positive = right, negative = left)
yYesVertical scroll amount in pixels (positive = down, negative = up)

Implementation Reference

  • The core scroll handler implementation in PlaywrightController class that performs the scrolling using page.evaluate and window.scrollBy, returns before/after positions.
    async scroll(x: number, y: number, smooth: boolean = false): Promise<{before: {x: number, y: number}, after: {x: number, y: number}}> { try { if (!this.isInitialized() || !this.state.page) { throw new Error('Browser not initialized'); } this.log('Scrolling', { x, y, smooth }); // Get scroll position before scrolling const beforeScroll = await this.state.page.evaluate(() => ({ x: window.scrollX, y: window.scrollY })); // Perform scroll with optional smooth behavior await this.state.page.evaluate((args: {x: number, y: number, smooth: boolean}) => { window.scrollBy({ left: args.x, top: args.y, behavior: args.smooth ? 'smooth' : 'auto' }); }, { x, y, smooth }); // Wait for scroll to complete await this.state.page.waitForTimeout(smooth ? 500 : 100); // Get scroll position after scrolling const afterScroll = await this.state.page.evaluate(() => ({ x: window.scrollX, y: window.scrollY })); this.log('Scroll complete', { before: beforeScroll, after: afterScroll }); return { before: beforeScroll, after: afterScroll }; } catch (error: any) { console.error('Scroll error:', error); throw new BrowserError('Failed to scroll', 'Check if scroll values are valid'); } }
  • Input schema definition for the scroll tool, specifying parameters x, y (required numbers), and optional smooth boolean.
    const SCROLL_TOOL: Tool = { name: "scroll", description: "Scroll the page by specified amounts with enhanced feedback", inputSchema: { type: "object", properties: { x: { type: "number", description: "Horizontal scroll amount in pixels (positive = right, negative = left)" }, y: { type: "number", description: "Vertical scroll amount in pixels (positive = down, negative = up)" }, smooth: { type: "boolean", description: "Whether to use smooth scrolling animation (default: false)" } }, required: ["x", "y"] } };
  • src/server.ts:638-664 (registration)
    MCP tool call handler in server.setRequestHandler('callTool') that validates inputs and delegates to playwrightController.scroll, formats response with scroll details.
    case 'scroll': { if (typeof args.x !== 'number' || typeof args.y !== 'number') { return { content: [{ type: "text", text: "X and Y scroll amounts are required" }], isError: true }; } const scrollResult = await playwrightController.scroll( args.x, args.y, args.smooth as boolean || false ); return { content: [{ type: "text", text: JSON.stringify({ message: "Page scrolled successfully", before: scrollResult.before, after: scrollResult.after, scrolled: { x: scrollResult.after.x - scrollResult.before.x, y: scrollResult.after.y - scrollResult.before.y } }, null, 2) }] }; }
  • src/server.ts:520-520 (registration)
    Registration of scroll tool in the tools object passed to MCP Server capabilities.
    scroll: SCROLL_TOOL,

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/jomon003/PlayMCP'

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