Skip to main content
Glama

eval

Run JavaScript in the target browser page and return JSON results, scoped to an element by ref or role/name; use return for multi-statement code to inspect or alter live tabs.

Instructions

Run JavaScript in the page and return the JSON result. With ref, el is that element. Use return for multi-statement code.

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": {
      "code": "<code>"
    },
    "name": "eval"
  }
}

Input Schema

NameRequiredDescriptionDefault
maxNo
refNoElement ref from the latest snapshot, e.g. e12 or f1e5
tabNoTab id. Default: your own target tab (each agent session gets its own)
codeYes
findNoInstead of ref: the role and name as the snapshot shows them, e.g. {role:"button", name:"Save"}; nth:2 picks the second match. Survives reloads and new sessions, so recipes use it
browserNochrome, edge, ... (only when several browsers are connected)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.0.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 behavioral burden, and it omits nearly everything that matters for arbitrary code execution: which execution context the code runs in, whether it can mutate page state or trigger navigation, async/await support, and error/failure behavior. It only discloses the return type (JSON result) and the `el` binding, leaving the risk profile and execution semantics unexplained.

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?

Three short sentences, front-loaded with the core action, with no filler or repetition. The terseness is appropriate in structure, though the space saved is not spent on higher-value behavioral detail.

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?

This is a high-power, unrestricted code-execution tool with six parameters, a nested object parameter, no annotations, and no output schema. Against that complexity the description is far too thin, covering neither the execution environment, side effects, nor the undocumented `max` parameter.

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 67%, so the baseline is around 3, and the description does add real meaning for two parameters: `ref` binds the element to `el`, and `code` uses `return` for multi-statement bodies. However, `max`, `find`, `tab`, and `browser` get no mention in the description, so it does not fully compensate for the coverage gap.

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?

The description states a specific verb and resource ('Run JavaScript in the page and return the JSON result'), which is enough to distinguish it from siblings like click or snapshot. It does not explicitly name an alternative for the arbitrary-code-execution case, so it stops short of a 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 only guidance is mechanical ('With ref, `el` is that element', 'Use `return` for multi-statement code'), not situational. There is no statement of when to prefer eval over purpose-built siblings such as click, type, or select, nor any warning about when not to use it.

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