Skip to main content
Glama

执行 JavaScript

page_evaluate

Run JavaScript in the current page context and return the result, including awaited Promises. Use it to inspect state, test expressions, or automate browser console tasks.

Instructions

在当前页面上下文执行一段 JavaScript 并返回结果(支持 await Promise),等价于 DevTools Console。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionYes要执行的 JS 表达式或语句
awaitPromiseNo是否等待返回的 Promise,默认 true
returnByValueNo是否按值返回,默认 true

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.7/5.0
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It usefully equates the tool to the DevTools Console, which conveys full page-context access and mutation capability, but it says nothing about side effects, destructive potential, serialization limits, or sandboxing. Given arbitrary code execution is possible, this is a meaningful gap.

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?

A single, front-loaded sentence that states action, context, return behavior, and the mental model (DevTools Console). Every clause earns its place with no redundancy.

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?

With no annotations and no output schema, the description must carry more weight. It adequately describes what happens for the happy path (returns result, supports await) but omits serialization behavior tied to returnByValue, failure modes, and safety implications of running arbitrary JS in the page context.

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%, so all three parameters (expression, awaitPromise, returnByValue) and their defaults are already documented in the schema. The description's mention of await Promise support is already captured by the awaitPromise parameter, so it adds no new meaning beyond the schema.

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?

States a specific verb (执行/execute) and a specific resource (JavaScript in the current page context), plus the return behavior and await support. No sibling tool shares this purpose, so the agent can immediately tell it apart from page_dom, storage_read or console_read.

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 DevTools Console equivalence implies when the tool is appropriate, but there is no explicit when-to-use or when-not-to-use guidance relative to alternatives like page_dom or console_read. Usage is left to inference from the stated purpose.

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