Skip to main content
Glama

evaluate_js

Run arbitrary JavaScript in the active browser tab to inspect dynamic state, modify DOM, or trigger interactions. Returns JSON-serialized results, with promises automatically awaited.

Instructions

Executes arbitrary JavaScript code in the page context, returning evaluated results as JSON-serializable values. Side effects: may modify DOM, state, or trigger network requests. Prerequisites: requires an active Chrome tab; script context must allow execution. Returns: JSON-serialized return value (or error if promise rejected). Use this for dynamic inspection, DOM manipulation, complex interactions. Alternatives: 'inspect_dom' for read-only DOM queries, 'click_element' for UI interactions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tab_idNoThe Tab ID of the target tab. Omit to use the active tab.
expressionYesJavaScript code expression to execute. Constraints: valid JavaScript (single expression or IIFE). Interactions: automatically awaits promises; 'returnByValue' returns serialized results. Defaults to: None (required).
instance_idNoChrome instance id from open_instance/list_instances. Omit for the default instance.
Behavior4/5

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

With no annotations, the description carries the full burden. It discloses side effects (may modify DOM, state, trigger network requests), prerequisites, return behavior (JSON-serializable values, error on promise rejection), and context requirements. This is comprehensive, though it omits details like potential CSP restrictions or permission scopes, leaving a small gap.

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 dense but every sentence earns its place: purpose, side effects, prerequisites, return, usage, and alternatives. It is well-structured and front-loaded with the core purpose, though the inclusion of both prerequisites and usage could be slightly streamlined without losing value.

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?

For a side-effect-capable tool with no annotations or output schema, the description covers all essential aspects: what it does, side effects, prerequisites, return format, error handling, and distinctions from siblings. It does not go into error specifics or permission nuances, but it is sufficient for an agent to invoke it correctly in most scenarios.

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?

Input schema coverage is 100%, with each parameter documented. The description adds minimal extra meaning: it mentions that promises are awaited, but the schema already states this. It does not elaborate on tab_id or instance_id beyond what the schema provides, so the baseline 3 applies as the description relies on the schema for parameter semantics.

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 action — "Executes arbitrary JavaScript code in the page context" — with a specific resource (JavaScript) and context (page). It immediately distinguishes its purpose from read-only inspection and UI interaction by naming alternatives, ensuring an agent can identify its niche.

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: "Use this for dynamic inspection, DOM manipulation, complex interactions" and lists concrete alternatives ('inspect_dom' for read-only queries, 'click_element' for UI interactions). It also states prerequisites (active Chrome tab, script context must allow execution), giving clear when-to-use and when-not-to-use conditions.

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/raultov/chrome-debug-mcp'

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