Skip to main content
Glama

browser_eval

Evaluate JavaScript expressions in browser tabs to read page state, scroll content, or trigger DOM changes using Chrome DevTools Protocol integration.

Instructions

Evaluate a JavaScript expression in a browser tab and return the result. Use for reading page state, scrolling, or triggering simple DOM mutations. Pass lensId (from perception_register) to verify tab identity and readyState before evaluating and receive post.perception state feedback without a screenshot. Caveats: Returns JSON-serializable values only — DOM nodes cannot be returned directly. React / Vue / Svelte controlled inputs cannot be updated via element.value = ... or native-setter + dispatchEvent — the framework's internal state is not refreshed; use keyboard_type (click the field first, pass windowTitle) for such form fields.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionYesJavaScript expression to evaluate in the browser tab
tabIdNoTab ID from browser_connect. Omit to use the first page tab.
portNoChrome/Edge CDP remote debugging port.
includeContextNoWhen true, append activeTab and readyState context to the response.
lensIdNoOptional perception lens ID. Guards (target.identityStable) are evaluated before eval. Note: browser_eval returns raw text, so no perception envelope is attached (guards only).
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: returns JSON-serializable values only (DOM nodes cannot be returned), limitations with framework-controlled inputs, and the role of lensId for tab identity verification and perception feedback. However, it doesn't mention error handling, performance implications, or security considerations.

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?

The description is appropriately sized and front-loaded with the core purpose. Each sentence adds valuable information: use cases, parameter context, limitations, and alternatives. While slightly dense, there's little waste, and the structure guides the reader from general to specific details.

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 (JavaScript evaluation in browser context) and lack of annotations and output schema, the description does a good job covering essential aspects: purpose, usage guidelines, key behaviors, and limitations. It could be more complete by detailing return value formats or error cases, but it provides sufficient context for effective use.

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 schema already documents all parameters thoroughly. The description adds minimal parameter-specific information beyond the schema, mainly explaining the lensId's purpose for guards and perception feedback. This meets the baseline for high schema coverage.

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 clearly states the tool's purpose: 'Evaluate a JavaScript expression in a browser tab and return the result.' It specifies the action (evaluate JavaScript), resource (browser tab), and distinguishes from siblings by mentioning use cases like reading page state, scrolling, or triggering simple DOM mutations, unlike tools like browser_click_element or browser_navigate.

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?

The description provides explicit guidance on when to use this tool vs alternatives. It states 'Use for reading page state, scrolling, or triggering simple DOM mutations' and warns against using it for React/Vue/Svelte controlled inputs, recommending 'keyboard_type' instead. This clearly defines appropriate and inappropriate contexts.

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/Harusame64/desktop-touch-mcp'

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