Skip to main content
Glama

browser_evaluate

Read-onlyIdempotent

Run JavaScript in the page context and return the result. Use for state not in the a11y tree, captcha iframe inspection, DOM events. Expression is either a plain JS value ('document.title') or a zero-arg IIFE ('(() => { … })()'). Inline any runtime values into the expression itself. Result is JSON-serialized; non-serializable values become strings. 256KB cap on output. Card numbers (Luhn-valid 13-19 digits) in the result are masked to the last four digits.

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

Input Schema

NameRequiredDescriptionDefault
page_idYes
expressionYes
in_workspaceNoRun this one call in this workspace id instead of the session's. Nothing is stored; other sessions are not affected.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / in_workspace
      Added value: +{
      +  "description": "Run this one call in this workspace id instead of the session's. Nothing is stored; other sessions are not affected.",
      +  "type": "integer"
      +}
  2. Added
  3. Removed
  4. Added
  5. Removed
  6. Added
  7. Removed
  8. Added
  9. Removed
  10. Added

TDQS

A4.3/5.0
Behavior5/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true, destructiveHint=false, but the description adds substantial behavior the annotations cannot express: results are JSON-serialized, non-serializable values are coerced to strings, output is capped at 256KB, and Luhn-valid card numbers are masked to the last four digits. It also warns that runtime values must be inlined into the expression itself, which is a real behavioral constraint on how calls must be composed.

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?

Every sentence carries a distinct operational fact — purpose, use cases, expression syntax, inlining rule, serialization, size cap, masking — with purpose and scope front-loaded and no filler or repetition of the structured fields.

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?

With no output schema, the description correctly takes on return-value behavior (JSON serialization, 256KB cap, masking), so an agent knows what comes back. It omits error behavior when an expression throws and any note that the page must already be loaded, which are the main remaining gaps for an arbitrary-JS tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is only 33%, with just in_workspace documented in the schema, so the description must carry the expression parameter — and it does, specifying the two accepted forms (plain JS value vs. zero-arg IIFE) with concrete examples and the inlining rule. page_id remains unexplained by both schema and description, which keeps this from a 5.

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 opens with a specific verb+resource pair ('Run JavaScript in the page context and return the result') and immediately carves out the scope where it applies ('state not in the a11y tree, captcha iframe inspection, DOM events'). This implicitly separates it from snapshot/read siblings like browser_get, but no sibling is named outright, so the differentiation is contextual rather than explicit.

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

Usage Guidelines4/5

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

Use cases are concrete and enumerated ('state not in the a11y tree', 'captcha iframe inspection', 'DOM events'), which gives an agent a real selection signal. It stops short of explicit when-not guidance or naming the alternative tool to prefer for ordinary DOM reads, so it lands just below the top band.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources