Skip to main content
Glama
yfmeii

WeChat Mini Program Dev MCP

by yfmeii

element_scrollTo

Scroll a scroll-view component to specific coordinates within a WeChat Mini Program. Provide a CSS selector and x, y values to set the scroll position.

Instructions

滚动 scroll-view 组件到指定位置。仅适用于 scroll-view 组件。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionNo
selectorYes
innerSelectorNo
xYes
yYes

Implementation Reference

  • The execute function that performs the scrollTo logic: parses parameters, resolves the element, checks it's a scroll-view, and calls element.scrollTo(x, y).
    function createScrollToTool(manager: WeappAutomatorManager): AnyTool {
      return {
        name: "element_scrollTo",
        description: "滚动 scroll-view 组件到指定位置。仅适用于 scroll-view 组件。",
        parameters: scrollToParameters,
        execute: async (rawArgs, context: ToolContext) =>
          withUserErrorResult(async () => {
          const args = scrollToParameters.parse(rawArgs ?? {});
          return manager.withPage(
            context.log,
            { overrides: args.connection },
            async (page) => {
              const element = await resolveElement(
                page,
                args.selector,
                args.innerSelector
              );
    
              if (typeof element.scrollTo !== "function") {
                throw new UserError(
                  `元素 "${args.selector}" 不支持滚动操作,仅 scroll-view 组件可使用此功能。`
                );
              }
    
              await element.scrollTo(args.x, args.y);
    
              return toTextResult(
                `已将元素 "${args.selector}"${args.innerSelector ? ` -> "${args.innerSelector}"` : ""} 滚动到位置 (${args.x}, ${args.y})。`
              );
            }
          );
          }),
      };
    }
  • Zod schema defining input parameters: selector (required), innerSelector (optional), x and y (coerced numbers).
    const scrollToParameters = connectionContainerSchema.extend({
      selector: z.string().trim().min(1),
      innerSelector: z.string().trim().min(1).optional(),
      x: z.coerce.number(),
      y: z.coerce.number(),
    });
  • The createScrollToTool(manager) is included in the createElementTools array, registering it as an available tool.
    export function createElementTools(
      manager: WeappAutomatorManager
    ): AnyTool[] {
      return [
        createTapElementTool(manager),
        createInputTextTool(manager),
        createCallElementMethodTool(manager),
        createGetElementDataTool(manager),
        createSetElementDataTool(manager),
        createGetInnerElementTool(manager),
        createGetInnerElementsTool(manager),
        createGetElementWxmlTool(manager),
        createGetElementStylesTool(manager),
        createScrollToTool(manager),
        createGetAttributesTool(manager),
        createGetBoundingClientRectTool(manager),
      ];
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses the tool scrolls to a position and applies only to scroll-view, but lacks details on prerequisites (e.g., connection), side effects, or behavior if the element is not scrollable.

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 short and front-loaded with the core action. However, it may be too concise given the complex input schema, but it remains clear and free of unnecessary wording.

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?

The description lacks information on prerequisites (e.g., connection setup), return values, and whether scrolling is animated. Given the schema with many parameters and no output schema, this is incomplete for an agent to use effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description adds very little parameter context. It does not explain key parameters like selector, innerSelector, x, y, or the connection object. The agent would need to guess their meanings.

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

Purpose5/5

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

The description clearly states the tool scrolls a scroll-view component to a specified position, and specifies it only applies to scroll-view components. This distinguishes it from sibling tools like element_tap or element_callMethod.

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

Usage Guidelines4/5

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

The description explicitly states the tool is only for scroll-view components, guiding when to use it. However, it does not mention when not to use it or suggest alternatives for non-scroll-view elements.

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/yfmeii/weapp-dev-mcp'

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