Skip to main content
Glama

browser_evaluate

Runs JavaScript in the page context and returns the result, letting you read window globals, DOM data, and computed values directly from the live browser page.

Instructions

在页面上下文执行 JavaScript 并返回结果(读 window 全局变量、DOM 数据等)

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": {
      "script": "<script>"
    },
    "name": "browser_evaluate"
  }
}

Input Schema

NameRequiredDescriptionDefault
scriptYesJS 代码,如 document.title 或返回值的函数

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.0

TDQS

C2.9/5.0
Behavior2/5

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

No annotations are supplied, so the description carries the full burden. It does not say that the script runs with full page privileges and can mutate DOM/window state (the 'read' framing understates this), nor whether the return value must be JSON-serializable, whether promises/async are awaited, or what happens on thrown exceptions. For an arbitrary-code-execution tool these are the decisive behaviors.

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?

A single front-loaded sentence with the verb, context and returned outcome, plus an efficient parenthetical. No filler, but the brevity comes at the cost of the behavioral details an eval tool needs.

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?

With no annotations, no output schema and an arbitrary-code tool, the definition should at least cover return-value shape, side-effect risk and error behavior. None of that is present, so an agent cannot predict what it gets back or what it might break by calling it.

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?

One parameter at 100% schema coverage, and the schema already documents 'script' with an example (document.title or a function returning a value). The description adds only the notion of a returned result, which slightly clarifies the function-vs-expression ambiguity but not the expected return-serialization contract.

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 JavaScript in the page context and return the result. The parenthetical (reading window globals, DOM data) sharpens what 'evaluate' means here versus the other browser_* tools, which are all fixed-purpose actions. It does not explicitly name a sibling it replaces, so it stops short of 5.

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

Usage Guidelines2/5

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

The parenthetical hints at a read-oriented use case, but there is no explicit when-to-use or when-not-to-use guidance and no mention of the obvious alternatives (browser_extract, browser_get_text) for scraping page data. It also fails to flag that arbitrary JS can mutate page state, which is precisely the condition an agent needs to decide whether this is the right tool.

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