Skip to main content
Glama

Run JavaScript in the page

browser_evaluate

Evaluate JavaScript expressions in browser page context and return results as JSON. Use it to read values hidden from the accessibility tree.

Instructions

Evaluate an expression in page context and return the result as JSON. The escape hatch for reading values the accessibility tree does not expose. Prefer browser_snapshot for reading structure and browser_click for interacting — synthetic events dispatched from here behave differently from real input and some sites notice.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetNoEvaluate against this element instead of the page.
tabIndexNoAct on this tab just for this call, without changing which tab is active. Defaults to the active tab. To switch tabs for good, use browser_tabs with action 'select'.
profileIdYesBrowser profile id, as passed to start_profile.
expressionYesAn expression (`document.title`) or a function (`() => { … }`). With `target`, the element is available as `el` — write `el.value` or `el => el.value`.
Behavior4/5

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

Annotations already indicate non-read-only and open-world behavior, and the description adds valuable specifics: 'synthetic events dispatched from here behave differently from real input and some sites notice.' This goes beyond the generic annotation flags and provides a concrete behavioral caveat. It also frames the tool as an 'escape hatch,' implying it bypasses normal accessibility paths.

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 sentences, front-loaded with the core action, then usage alternatives, then a behavioral caveat. Every sentence earns its place with no redundancy or filler.

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?

Given the tool's complexity (4 params, nested object, no output schema), the description covers purpose, alternatives, and a key behavioral risk. The return type is mentioned ('return the result as JSON'). It could potentially note error behavior or async support, but current coverage is strong for a browser automation 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 description coverage is 100%, so the input schema already explains all parameters including target, expression, tabIndex, and profileId. The description adds no new parameter-level semantics beyond what's in the schema, so the baseline of 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?

The description opens with a specific verb+resource: 'Evaluate an expression in page context and return the result as JSON.' It clearly establishes the tool as an escape hatch for reading values the accessibility tree does not expose, distinguishing it from sibling tools like browser_snapshot and browser_click.

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 states when to prefer alternatives: 'Prefer browser_snapshot for reading structure and browser_click for interacting.' Also warns about the nuance of synthetic events, giving clear context for when this tool is appropriate versus when it is not.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/someorgyouwontcareabout/DolphinMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server