Skip to main content
Glama
yfmeii

WeChat Mini Program Dev MCP

by yfmeii

element_input

Input text into specific elements in WeChat Mini Program pages, including nested components using inner selector parameters for precise targeting.

Instructions

向指定元素输入文本。如需向自定义组件内部的元素输入,请使用 innerSelector 参数:selector 设为组件 ID 选择器(如 #my-component),innerSelector 设为组件内部元素的选择器。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionNo
selectorYes
innerSelectorNo
valueYes

Implementation Reference

  • The createInputTextTool function returns the tool definition including the execute handler which parses args, resolves the element using resolveElement, calls element.input(value), and returns a success message.
    function createInputTextTool(manager: WeappAutomatorManager): AnyTool {
      return {
        name: "element_input",
        description: "向指定元素输入文本。如需向自定义组件内部的元素输入,请使用 innerSelector 参数:selector 设为组件 ID 选择器(如 #my-component),innerSelector 设为组件内部元素的选择器。",
        parameters: inputTextParameters,
        execute: async (rawArgs, context: ToolContext) => {
          const args = inputTextParameters.parse(rawArgs ?? {});
          return manager.withPage(
            context.log,
            { overrides: args.connection },
            async (page) => {
              const element = await resolveElement(
                page,
                args.selector,
                args.innerSelector
              );
    
              await element.input(args.value);
              return toTextResult(
                `已向元素 "${args.selector}"${args.innerSelector ? ` -> "${args.innerSelector}"` : ""} 输入值 "${args.value}"。`
              );
            }
          );
        },
      };
    }
  • Zod schema defining the input parameters for the element_input tool: selector (required string), innerSelector (optional string), value (string or number).
    const inputTextParameters = connectionContainerSchema.extend({
      selector: z.string().trim().min(1),
      innerSelector: z.string().trim().min(1).optional(),
      value: z.union([z.string(), z.coerce.number()]),
    });
  • The element_input tool (via createInputTextTool) is registered in the array returned by createElementTools.
    return [
      createTapElementTool(manager),
      createInputTextTool(manager),
      createCallElementMethodTool(manager),
      createGetElementDataTool(manager),
      createSetElementDataTool(manager),
      createGetInnerElementTool(manager),
      createGetInnerElementsTool(manager),
      createGetElementSizeTool(manager),
      createGetElementWxmlTool(manager),
    ];
  • src/tools.ts:7-13 (registration)
    createTools includes the tools from createElementTools, which contains element_input.
    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 element_input, to the FastMCP server.
    server.addTools(createTools(manager));
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. While it mentions the basic action (input text) and a special case (custom components), it lacks critical behavioral details: what happens if the element doesn't exist, whether this triggers events, if there are rate limits, authentication requirements, or what the return value looks like. For a UI automation tool with no annotation coverage, this is insufficient.

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 perfectly concise - two sentences that each earn their place. The first states the core purpose, the second provides important usage guidance for a specific parameter scenario. No wasted words, front-loaded with the main functionality.

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 (UI automation with connection parameters), no annotations, no output schema, and 0% schema description coverage, the description is incomplete. It covers the basic action and one parameter relationship but misses critical context about error conditions, return values, connection requirements, and how this differs from other element manipulation tools. For a tool with this level of underlying complexity, the description should do more.

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 0%, so the description must compensate. It explains the relationship between selector and innerSelector for custom components, adding meaningful context beyond the schema. However, it doesn't explain the connection parameter (which appears to be for browser/automation setup) or the value parameter's expected format. With 4 parameters total and only partial coverage, this meets the baseline for moderate schema coverage gaps.

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 tool's purpose: '向指定元素输入文本' (input text into a specified element). It specifies the verb ('输入' - input) and resource ('元素' - element), making the action clear. However, it doesn't explicitly differentiate from sibling tools like element_tap or element_setData, which might have overlapping UI interaction purposes.

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 provides clear context for when to use the innerSelector parameter: '如需向自定义组件内部的元素输入' (if you need to input into elements inside custom components). This gives specific guidance on an alternative usage pattern. However, it doesn't mention when NOT to use this tool versus alternatives like element_setData or when to choose between different element interaction tools.

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