Skip to main content
Glama
yfmeii

WeChat Mini Program Dev MCP

by yfmeii

page_getElement

Retrieve page elements using CSS selectors in WeChat Mini Program development for automation and testing purposes.

Instructions

通过选择器获取页面元素。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionNo
selectorYes
innerSelectorNo

Implementation Reference

  • The execute function that handles the page_getElement tool: parses input parameters, connects to the page via manager, resolves the element using the selector and optional innerSelector, summarizes the element, and returns a formatted JSON text result.
    execute: async (rawArgs, context: ToolContext) => {
      const args = getElementParameters.parse(rawArgs ?? {});
      return manager.withPage<ContentResult>(
        context.log,
        { overrides: args.connection },
        async (page) => {
          const element = await resolveElement(
            page,
            args.selector,
            args.innerSelector
          );
          const summary = await summarizeElement(element);
          return toTextResult(formatJson(summary));
        }
      );
    },
  • Zod schema defining the input parameters for the page_getElement tool, extending connectionContainerSchema with required selector and optional innerSelector.
    const getElementParameters = connectionContainerSchema.extend({
      selector: z.string().trim().min(1),
      innerSelector: z.string().trim().min(1).optional(),
    });
  • Registers the page_getElement tool (via createGetElementTool) among other page tools in the createPageTools function.
    export function createPageTools(manager: WeappAutomatorManager): AnyTool[] {
      return [
        createGetElementTool(manager),
        createWaitForElementTool(manager),
        createWaitForTimeoutTool(manager),
        createGetPageDataTool(manager),
        createSetPageDataTool(manager),
        createCallPageMethodTool(manager),
      ];
    }
  • src/tools.ts:7-13 (registration)
    Aggregates and registers page tools (including page_getElement) with application and element tools in createTools.
    export function createTools(manager: WeappAutomatorManager): AnyTool[] {
      return [
        ...createApplicationTools(manager),
        ...createPageTools(manager),
        ...createElementTools(manager),
      ];
    }
  • src/index.ts:17-17 (registration)
    Final registration of all tools, including page_getElement, to the FastMCP server instance.
    server.addTools(createTools(manager));
Behavior1/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but offers none. It doesn't mention whether this is a read-only operation, what happens if the selector matches multiple elements, error conditions, performance implications, or any authentication/connection requirements implied by the complex 'connection' parameter.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's appropriately sized for a simple tool concept and front-loads the core purpose immediately.

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 the complexity (3 parameters including a nested object with 12 sub-properties, 0% schema coverage, no annotations, and no output schema), the description is severely incomplete. It doesn't address how to establish the connection, what the tool returns, error handling, or how it differs from similar sibling tools.

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?

Schema description coverage is 0%, so the description must compensate but fails to do so. It mentions 'selector' but doesn't explain what format it expects (CSS, XPath, etc.), nor does it mention the 'connection' or 'innerSelector' parameters at all. The description adds minimal value beyond the parameter names visible in the schema.

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

Purpose3/5

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

The description states the tool's purpose as '通过选择器获取页面元素' (get page elements via selector), which is a clear verb+resource combination. However, it doesn't differentiate from sibling tools like 'element_getInnerElement' or 'page_waitElement', making it somewhat vague about its specific scope within the broader element/page manipulation context.

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 multiple sibling tools for element retrieval and page interaction (e.g., element_getInnerElement, page_waitElement), there's no indication of whether this tool is for initial element selection, nested element access, or waiting for elements to appear.

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