Skip to main content
Glama
wooter-s

weixin-devtools-mcp

by wooter-s

evaluate_script

Execute JavaScript in a WeChat mini-program's AppService context to access wx APIs, getApp(), and getCurrentPages(), returning JSON-serializable results.

Instructions

在小程序 AppService 上下文中执行 JavaScript 代码并返回结果。 支持访问 wx API、getApp()、getCurrentPages() 等小程序全局对象。 返回值必须是 JSON 可序列化的类型。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argsNo可选的参数数组,传递给函数执行。 参数必须是 JSON 可序列化的类型(字符串、数字、布尔值、对象、数组等)。 示例: - 单个参数: ["testKey"] - 多个参数: ["key", 123, { foo: "bar" }] - 复杂对象: [{ name: "test", data: [1, 2, 3] }]
functionYesJavaScript 函数声明,将在小程序 AppService 上下文中执行。 支持同步和异步函数,可访问 wx API 和 getApp()。 注意:函数会被序列化传递,无法使用闭包引用外部变量。 无参数示例: `() => { return wx.getSystemInfoSync(); }` 或使用字符串形式: `"() => wx.getSystemInfoSync()"` 异步示例: `async () => { return new Promise(resolve => { wx.getSystemInfo({ success: result => resolve(result) }); }); }` 带参数示例: `(key, value) => { wx.setStorageSync(key, value); return { success: true }; }` 访问全局数据示例: `() => { const app = getApp(); return app.globalData; }` 访问当前页面示例: `() => { const pages = getCurrentPages(); const currentPage = pages[pages.length - 1]; return currentPage.data; }`

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okYes
codeYes
dataYes
metaYes
errorYes
warningsYes
nextActionsYes
observationYes
partialDataYes
schemaVersionYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.7.0

TDQS

A3.8/5.0
Behavior3/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It discloses the execution context, supported globals, and the JSON-serializable return requirement, which are useful. However, it does not mention potential side effects of arbitrary code execution (e.g., modifying storage or app state), error handling, or timeout behavior, which are significant for a code execution tool.

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 concise and front-loaded: the first sentence states the action and result, the second lists accessible globals, and the third sets the return type. Every sentence adds value and there is no redundancy or filler.

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?

The tool is moderately complex (arbitrary code execution) but the schema descriptions are rich (100% coverage) and an output schema exists, so the description need not explain return structure. The description covers the essential execution context, supported globals, and serialization requirement. It falls short only in not addressing side-effect risk and use-case guidance, but overall it is sufficiently complete for correct invocation.

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 100%, and the input schema already provides detailed explanations for both 'args' and 'function', including examples and constraints. The tool description adds context about the AppService environment and return constraint but does not add per-parameter semantics beyond what the schema provides, so the baseline score of 3 applies.

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 a specific verb ('执行' / execute) and resource ('小程序 AppService 上下文' / mini-program AppService context), and explains it returns results. This distinguishes it from sibling tools like click, get_value, and navigate_to which handle UI or state, not arbitrary code execution.

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?

The description implies usage for executing JavaScript logic in the mini-program environment and lists accessible globals, but it does not explicitly state when to use this tool versus alternatives or provide exclusions. There is no reference to sibling tools or conditions that would route an agent to this tool over others.

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