Skip to main content
Glama
Browser Session MCP

Browser Session MCP

evaluate

Destructive

Execute JavaScript in a browser tab or frame and return the JSON-serializable result. Promises are awaited, and thrown errors return their exception messages.

Instructions

Run JavaScript in a tab and return its value as JSON in { result }. A bare expression returns its value; for several statements use return ...; promises are awaited. Values that aren't JSON come back reduced: undefined as null and DOM nodes as {}. It runs in the page's main world (can read page globals like window.dataLayer); on stealth sessions (see set_stealth) it runs in an isolated world instead, which sees the DOM but not page-defined globals. tabIndex runs it in another tab without switching to it, and frame in an embedded frame. The code can change the page like any script, so prefer take_snapshot or wait_for when they suffice, and click or type for interaction. Fails with the JS exception's message if the code throws.

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": {
      "sessionId": "<sessionId>",
      "expression": "<expression>"
    },
    "name": "evaluate"
  }
}

Input Schema

NameRequiredDescriptionDefault
frameNoRun in the frame whose URL contains this (an embedded form from another site, e.g. `greenhouse.io`), in an isolated world that sees its DOM but not its page globals. Default: the top document.
tabIndexNoTab to run in, by its 0-based list_pages index. Default: the active tab.
sessionIdYesThe id returned by open_browser_session. Errors if no open session has it.
expressionYesJavaScript to run. Promises are awaited; the value must be JSON-serializable.

Output Schema

NameRequiredDescriptionDefault
resultYesThe expression's value; null for undefined.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.1.23
    • addedInput schema / properties / frame
      Added value: +{
      +  "description": "Run in the frame whose URL contains this (an embedded form from another site, e.g. `greenhouse.io`), in an isolated world that sees its DOM but not its page globals. Default: the top document.",
      +  "type": "string"
      +}
  2. Changed1 schema field changedv0.1.5
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "https://json-schema.org/draft/2020-12/schema",
      +  "properties": {
      +    "result": {
      +      "description": "The expression's value; null for undefined."
      +    }
      +  },
      +  "required": [
      +    "result"
      +  ],
      +  "type": "object"
      +}
  3. Changed3 schema fields changed
    • addedInput schema / properties / expression / description
      Added value: +"JavaScript to run. Promises are awaited; the value must be JSON-serializable."
    • addedInput schema / properties / sessionId / description
      Added value: +"The id returned by open_browser_session. Errors if no open session has it."
    • addedInput schema / properties / tabIndex / description
      Added value: +"Tab to run in, by its 0-based list_pages index. Default: the active tab."
  4. First observedv0.1.2

TDQS

A4.6/5.0
Behavior4/5

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

Goes well beyond the annotations by disclosing execution world semantics (main world vs. isolated world under stealth, with different global visibility), promise awaiting, value coercion rules (undefined → null, DOM nodes → {}), and the failure mode (throws surface the JS exception message). The destructive/openWorld hints are corroborated rather than contradicted. It stops short of describing rate limits or resource cost, but the essential behavior is covered.

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?

Front-loaded with purpose and return shape, then moves through evaluation semantics, world context, targeting, cautions, and error behavior in a logical order. Dense but nearly every clause carries information; a slightly tighter grouping of the tabIndex/frame material would help, but there is no filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a code-execution tool with an output schema, this covers everything an agent needs: evaluation model, world isolation caveat, target selection, coercion of non-JSON values, and throw behavior. Nothing required to call it correctly is missing.

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 100%, so the baseline is 3; the description still adds meaning by explaining that tabIndex runs code in another tab without switching to it and that frame targets an embedded frame's DOM in an isolated world. That is behavioral context the schema's terse descriptions do not convey.

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?

Opens with a specific verb and resource — "Run JavaScript in a tab" — and states the return contract ({ result } JSON). It also distinguishes itself from siblings by naming take_snapshot, wait_for, click, and type as the preferred tools when they suffice.

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

Usage Guidelines5/5

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

Explicitly says when NOT to reach for this tool ("prefer take_snapshot or wait_for when they suffice, and click or type for interaction"), which is exactly the routing guidance an agent needs against a large sibling set. It also frames the framing/tab targeting choices as usage contexts.

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