Skip to main content
Glama

element_callMethod

Invokes a method on a custom component instance identified by a selector and returns the serialized result. Use for calling component methods during WeChat mini program debugging.

Instructions

调用自定义组件实例的方法(element.callMethod()),返回该方法的返回值(序列化后放在 result)。仅对自定义组件实例有效,普通 WXML 元素会失败;调用页面级方法请用 page_callMethod。读/写组件实例数据用 element_getData / element_setData。method:方法名;args:按顺序展开传入方法的参数数组。要定位嵌套在外层组件内的组件,用 selector + innerSelector。selector 支持 [index=N](仅作用于 selector)。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argsNo
methodYes
maxBytesNo
selectorYes
connectionNo可选连接覆盖(不传则用默认会话)。可用字段:mode(launch|connect)、cliPath、projectPath、wsEndpoint、timeout、port(【自动化端口】→ cli auto --auto-port,默认 9420;不是 IDE HTTP 服务端口,别把 IDE 服务端口传进来)、account、ticket、trustProject、args、cwd、autoClose、autoLaunch、launchTimeout、connectTimeout。
innerSelectorNo
Behavior4/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 explains that the method is called via element.callMethod(), returns the serialized result, and fails on non-custom components. This is transparent, though it could mention error handling for missing methods.

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 paragraph but is concise and informative. Every sentence adds value, though a bulleted list would improve readability. No redundancy.

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

Completeness4/5

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

Given no output schema, the description adequately explains the return value (serialized method result). It also addresses failure conditions and distinguishes from the many sibling tools. Minor omission: no mention of timeout or synchronous nature.

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

Parameters4/5

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

Schema description coverage is low (17%), but the description explains key parameters: method, args, selector, and innerSelector. It clarifies that args are spread in order and that selector supports [index=N]. It does not explain maxBytes or repeat connection's schema description, which is acceptable.

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 calls a method on a custom component instance and returns the result, using specific verb '调用' and resource '自定义组件实例的方法'. It distinguishes from sibling tools like page_callMethod and element_getData/element_setData.

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

Usage Guidelines5/5

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

Explicitly states when to use this tool (custom component instances only, not normal WXML elements) and when to use alternatives (page_callMethod for page-level, element_getData/element_setData for data). Also provides guidance on nested component selection and index syntax.

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/Chaixueyuan/weapp-agent-mcp'

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