Skip to main content
Glama

在小程序 App 上下文执行表达式

wdt_evaluate

Executes JavaScript expressions or function bodies in the WeChat Mini Program context and returns serializable results for local debugging.

Instructions

在 miniProgram.evaluate 中执行表达式或函数体,返回可序列化结果。默认把输入当表达式自动包成函数;mode=function 时原样传入函数声明。可通过 $args 访问 args 参数。仅用于本地调试,注意副作用。

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "expression": "<expression>"
    },
    "name": "wdt_evaluate"
  }
}

Input Schema

NameRequiredDescriptionDefault
argsNo传给函数的参数,可在表达式里用 $args 访问
modeNoauto 默认;expression 强制按表达式;statements 按语句块;function 原样传入
expressionYes表达式(如 getCurrentPages().length)或函数源码

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.2

TDQS

A3.6/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does a fair job: it discloses that results must be serializable, that input is auto-wrapped as a function by default, that mode=function passes source through verbatim, and it warns about side effects. Missing only error behavior and any environment/permission preconditions.

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?

Four short clauses, front-loaded with purpose, then mode behavior, then $args, then the safety caveat — no filler. It is dense to the point of terseness, but every sentence carries informational weight.

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

Completeness3/5

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

For a 3-parameter evaluation tool with no annotations and no output schema, the description covers invocation semantics reasonably but leaves return-value shape ('可序列化结果'), error handling, and any connection prerequisites unspecified. Adequate but not fully complete for an arbitrary-code-execution tool.

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 coverage is 100%, including an enum for mode and a note that args is reachable via $args, so the schema already explains all three parameters. The description restates the mode semantics and adds only the marginal detail that the default auto-wraps the input into a function — helpful, but not much beyond the structured fields.

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?

States a specific verb and resource: execute an expression or function body inside miniProgram.evaluate and return a serializable result. That is clearly distinct from the sibling tools (connect, navigate, page_data, wx_method), though it never names a sibling to contrast with. The purpose is unambiguous without opening the schema.

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

Usage Guidelines3/5

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

It gives one real constraint: '仅用于本地调试' plus a side-effect warning, which tells the agent this is for ad-hoc debugging rather than production flows. It does not say when to prefer a specific sibling (e.g., wdt_query or wdt_page_data) over free-form evaluation, so the routing guidance is only implied.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.