Skip to main content
Glama

web_eval

Executes arbitrary JavaScript in a chosen browser tab and returns the result, enabling data extraction, DOM inspection, and custom page automation.

Instructions

Run arbitrary JavaScript in the page and return the result. The power tool; can be disabled with WEBAI_NO_EVAL.

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": "web_eval"
  }
}

Input Schema

NameRequiredDescriptionDefault
target_idNoTab id from web_tabs. Omit to use the first/active tab.
expressionYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

B3.2/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 disclose one real constraint (can be disabled via WEBAI_NO_EVAL), but it says nothing about execution context restrictions (CSP), whether promises are awaited, how non-serializable return values are handled, or that arbitrary JS can mutate page state. For an unannotated 'power tool' that is a substantial gap.

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?

Two short sentences, front-loaded with the core behavior, and no filler. The environment-variable note is compact and useful rather than padding.

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 should explain the shape of the returned result and the risks of arbitrary execution. It only says 'return the result', leaving serialization behavior and failure modes unstated, though it is adequate for a two-parameter 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 50%: target_id is documented in the schema (tab id from web_tabs, omit for active tab), while expression has no schema description. The description partially compensates by establishing that expression is JavaScript source and that its evaluated result is returned.

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 arbitrary JavaScript in the current page and return the result. That is clearly distinct from read-oriented siblings like web_read and web_html, though the description never names them explicitly.

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 power tool" hints that this is the heavyweight/last-resort option, but there is no explicit guidance on when to prefer web_read, web_html, or web_click instead, and no statement of prerequisites such as a page being loaded.

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