Skip to main content
Glama

pilot_scroll

Scroll web pages to specific elements or directions using CSS selectors. Navigate to page top, bottom, or scroll up/down for browser automation tasks.

Instructions

Scroll element into view, or scroll to page bottom if no ref provided.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
refNoElement ref or CSS selector to scroll into view
directionNoScroll direction (when no ref)

Implementation Reference

  • The handler function for the pilot_scroll MCP tool, which scrolls either a specific element into view or performs a general page scroll.
    async ({ ref, direction }) => {
      await bm.ensureBrowser();
      try {
        const page = bm.getPage();
        if (ref) {
          const resolved = await bm.resolveRef(ref);
          if ('locator' in resolved) {
            await resolved.locator.scrollIntoViewIfNeeded({ timeout: 5000 });
          } else {
            await page.locator(resolved.selector).scrollIntoViewIfNeeded({ timeout: 5000 });
          }
          bm.resetFailures();
          return { content: [{ type: 'text' as const, text: `Scrolled ${ref} into view` }] };
        }
        const scrollMap: Record<string, string> = {
          up: 'window.scrollBy(0, -window.innerHeight)',
          down: 'window.scrollBy(0, window.innerHeight)',
          top: 'window.scrollTo(0, 0)',
          bottom: 'window.scrollTo(0, document.body.scrollHeight)',
        };
        await page.evaluate(scrollMap[direction || 'bottom']);
        bm.resetFailures();
        return { content: [{ type: 'text' as const, text: `Scrolled ${direction || 'bottom'}` }] };
  • Zod schema defining the input arguments for the pilot_scroll tool.
    {
      ref: z.string().optional().describe('Element ref or CSS selector to scroll into view'),
      direction: z.enum(['up', 'down', 'top', 'bottom']).optional().describe('Scroll direction (when no ref)'),
    },

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/TacosyHorchata/Pilot'

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