Skip to main content
Glama

Evaluate JS in the page

browser_evaluate

Evaluate a JavaScript expression in a Firefox page and return its JSON value, awaiting promises. Use it to inspect or modify page state, treating changes as writes.

Instructions

Run an expression in the page and return its value (JSON). Promises are awaited. It can change the page, so treat it as a write.

Input Schema

NameRequiredDescriptionDefault
contextNoTab context id (default: the active tab)
expressionYesJavaScript expression to evaluate

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.8/5.0
Behavior4/5

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

Goes beyond the readOnlyHint=false annotation by explaining the mutation risk in plain terms ('it can change the page, so treat it as a write') and by disclosing that promises are awaited and the result is returned as JSON. Missing details like execution world, CSP behavior, or whether navigation can occur, but it adds genuine context on top of the annotation.

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, front-loaded with the verb and return value, then mutation risk. Nothing redundant and no 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?

No output schema exists, and the description covers the critical unknowns – return shape (JSON) and async handling (promises awaited) – plus the write-risk caveat. A note on execution context or failure modes would make it complete for a high-power arbitrary-code 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 both 'expression' and 'context' (default active tab) are already documented in the schema. The description adds no parameter-level meaning, so baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb ('Run an expression') and resource ('in the page') plus the return contract (its value, JSON). It's clearly distinguishable from siblings like browser_page_source or browser_dom_tree, though it never explicitly names an alternative to disambiguate against browser_console or browser_run_in_extension.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Implied usage only – an agent infers this is the escape hatch for arbitrary JS when no dedicated tool exists. There is no explicit when-to-use statement and no named sibling as an alternative, which matters in a 150-tool namespace with browser_console and browser_run_in_extension nearby.

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

Deploy Server

Other Tools