Skip to main content
Glama

browser_evaluate

Execute JavaScript in the active browser tab for shadow-DOM traversal, reading window state, or programmatic clicks during automation.

Instructions

Execute JavaScript in the active tab via CDP Runtime.evaluate. Returns a serialized value (or {ok:false,error} on exception). Useful for shadow-DOM traversal, reading window state, or programmatic clicks when extensions intercept the synthetic mouse events. The expression is run in the page context as a real user gesture.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionYesJS expression. Wrap statements in an IIFE if needed: `(()=>{ ... return value; })()`.
awaitPromiseNoIf the expression returns a Promise, await it before returning.
returnByValueNoSerialize the result. Set false to get an opaque objectId for later use (rare).
timeoutMsNo
tabIdNo
Behavior4/5

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

Discloses return format (serialized value or error object), mentions execution context ('run in the page context as a real user gesture'), and notes exception handling. With no annotations provided, this adequately conveys behavioral traits.

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 concise sentences with no redundant information. The most important action ('Execute JavaScript...') is front-loaded, and each sentence adds value without waste.

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

Completeness3/5

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

Covers key aspects like purpose, use cases, and return format, but leaves gaps: no information on timeoutMs, tabId, or limitations (e.g., CSP, permissions). With no output schema or annotations, these omissions reduce completeness.

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

Parameters2/5

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

Schema description coverage is 60% (low), but the description does not add details for undocumented parameters like timeoutMs and tabId. While it gives usage examples, it fails to compensate for the missing parameter descriptions.

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?

Clearly states 'Execute JavaScript in the active tab via CDP Runtime.evaluate', which specifies the verb (execute) and resource (JavaScript in active tab). Distinguishes from sibling tools like browser_click or browser_navigate by focusing on arbitrary code execution.

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?

Provides concrete use cases: 'shadow-DOM traversal, reading window state, or programmatic clicks when extensions intercept the synthetic mouse events.' Implies when to use over alternatives like browser_click, though does not explicitly list when not to use.

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/DevZonayed/Mochi'

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