Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

scroll

Automatically scroll web pages horizontally or vertically by specified pixel amounts during browser automation tasks.

Instructions

Scroll the page by specified amounts with enhanced feedback

Input Schema

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

Implementation Reference

  • Core implementation of the scroll tool logic: captures scroll position before and after using window.scrollBy via page.evaluate
    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');
      }
    }
  • MCP server request handler case for 'scroll' tool: input validation, delegates to controller, formats detailed response with scroll delta
    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)
        }]
      };
    }
  • Definition and input schema for the 'scroll' tool, specifying parameters x, y (required), smooth (optional)
    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:514-553 (registration)
    Registration of scroll tool in the tools object passed to MCP Server capabilities
    const tools = {
      openBrowser: OPEN_BROWSER_TOOL,
      navigate: NAVIGATE_TOOL,
      type: TYPE_TOOL,
      click: CLICK_TOOL,
      moveMouse: MOVE_MOUSE_TOOL,
      scroll: SCROLL_TOOL,
      screenshot: SCREENSHOT_TOOL,
      getPageSource: GET_PAGE_SOURCE_TOOL,
      getPageText: GET_PAGE_TEXT_TOOL,
      getPageTitle: GET_PAGE_TITLE_TOOL,
      getPageUrl: GET_PAGE_URL_TOOL,
      getScripts: GET_SCRIPTS_TOOL,
      getStylesheets: GET_STYLESHEETS_TOOL,
      getMetaTags: GET_META_TAGS_TOOL,
      getLinks: GET_LINKS_TOOL,
      getImages: GET_IMAGES_TOOL,
      getForms: GET_FORMS_TOOL,
      getElementContent: GET_ELEMENT_CONTENT_TOOL,
      getElementHierarchy: GET_ELEMENT_HIERARCHY_TOOL,
      executeJavaScript: EXECUTE_JAVASCRIPT_TOOL,
      goForward: GO_FORWARD_TOOL,
      hover: HOVER_TOOL,
      dragAndDrop: DRAG_AND_DROP_TOOL,
      selectOption: SELECT_OPTION_TOOL,
      pressKey: PRESS_KEY_TOOL,
      waitForText: WAIT_FOR_TEXT_TOOL,
      waitForSelector: WAIT_FOR_SELECTOR_TOOL,
      resize: RESIZE_TOOL,
      handleDialog: HANDLE_DIALOG_TOOL,
      getConsoleMessages: GET_CONSOLE_MESSAGES_TOOL,
      getNetworkRequests: GET_NETWORK_REQUESTS_TOOL,
      uploadFiles: UPLOAD_FILES_TOOL,
      evaluateWithReturn: EVALUATE_WITH_RETURN_TOOL,
      takeScreenshot: TAKE_SCREENSHOT_TOOL,
      mouseMove: MOUSE_MOVE_TOOL,
      mouseClick: MOUSE_CLICK_TOOL,
      mouseDrag: MOUSE_DRAG_TOOL,
      closeBrowser: CLOSE_BROWSER_TOOL
    };
  • src/server.ts:555-565 (registration)
    MCP Server initialization with tools capabilities including the scroll tool
    const server = new Server(
      {
        name: "playmcp-browser",
        version: "1.0.0",
      },
      {
        capabilities: {
          tools,
        },
      }
    );
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'enhanced feedback' but doesn't clarify what that means—whether it's visual cues, return values, or error handling. For a tool with no annotations, this leaves key behavioral traits like side effects or response format unspecified.

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 a single, efficient sentence that front-loads the core action ('scroll the page'). It avoids unnecessary words, though 'with enhanced feedback' could be more specific to improve clarity without adding bulk.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete. It doesn't explain what 'enhanced feedback' includes, how errors are handled, or what the tool returns. For a 3-parameter tool with no structured support, more detail on behavior and outcomes is needed.

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 description coverage is 100%, so the schema fully documents parameters (x, y, smooth). The description adds no additional meaning beyond implying scrolling occurs 'by specified amounts', which aligns with the schema but doesn't provide extra context like units or default behaviors beyond what's in schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('scroll') and the resource ('the page'), specifying it's done 'by specified amounts with enhanced feedback'. However, it doesn't explicitly differentiate from sibling tools like 'mouseDrag' or 'mouseMove' which might also involve movement, though scrolling is distinct in purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'mouseDrag' for dragging or 'navigate' for page navigation, there's no indication of when scrolling is preferred over other methods or what 'enhanced feedback' entails in context.

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

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