Skip to main content
Glama

Run JS

browser_eval

Evaluates a JavaScript expression in a selected Chrome tab and returns JSON, acting as an escape hatch when other browser tools cannot read or modify page DOM.

Instructions

Evaluates a JavaScript expression in the tab and returns the result as JSON. Escape hatch only when other tools can't do it. Runs in an isolated world: DOM can be read and modified, but globals created by page scripts (window.appVar, etc.) are not visible.

Input Schema

NameRequiredDescriptionDefault
tabNoTarget tab: number (1, 2…) or ID ("t7"). Use the stable ID when agents share a slot. Required for action tools when there are multiple tabs.
slotYesBrowser slot 1-30. "3", "slot 3", "browser 3" → 3. If the user gives a port like 14052, subtract 14049.
agentNoYour display name, shown to other agents. Subagents must always set it. Default "claude-1e1b".
summaryNoOne-line note of what you are doing (e.g. "comparing laptop prices"). Shown in browser_status (not the status line). Omit to keep the previous one.
multiSlotNotrue only when one agent must handle several slots together (e.g. comparing). Normally omit (one agent = one slot; use subagents for the rest)
expressionYesJS expression (Promises are awaited)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.1.10
    • changedInput schema / properties / agent / description
      Previous value: -"Your display name, shown to other agents. Subagents must always set it. Default \"claude-68d9\"."New value: +"Your display name, shown to other agents. Subagents must always set it. Default \"claude-1e1b\"."
  2. First observedv0.1.0

TDQS

A4.2/5.0
Behavior4/5

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

With no annotations, the description carries the burden and does real work: it discloses the isolated-world execution model, that DOM read/write is possible, and that page-created globals (window.appVar) are invisible. That last point is exactly the kind of surprise an agent needs warned about. It does not discuss permission needs, mutation side effects, or rate limits.

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?

Three short sentences, no filler. Purpose and return are front-loaded, then the escape-hatch restriction, then the isolated-world caveat — a well-ordered information hierarchy.

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?

No output schema exists, and the description does state the return is JSON. Combined with the isolated-world caveat, an agent has what it needs to invoke this correctly. Minor gaps remain around failure modes and whether mutations persist across evaluations.

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 description coverage is 100% across all 6 parameters, so the schema already documents slot, tab, agent, summary, multiSlot and expression. The description adds only that Promises are awaited and results come back as JSON, which the schema largely covers already. Baseline 3 is appropriate.

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?

States a specific verb (evaluates) and resource (a JavaScript expression in the tab) plus the return shape (result as JSON). The 'escape hatch' framing immediately distinguishes it from the dozens of purpose-built browser_* action tools.

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?

Explicitly scopes usage to 'only when other tools can't do it', which is a clear when-to-use rule and a de facto exclusion. It stops short of naming which alternative tool to reach for first, so it is not fully self-routing.

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