Skip to main content
Glama

evaluate_script

Execute a JavaScript function in a Chrome page and return the result as JSON. Use it to extract data, inspect the DOM, or pass element UIDs as arguments.

Instructions

Evaluate a JavaScript function inside the page. Returns the result as JSON.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argsNoElement uids from the latest snapshot, passed as function arguments.
pageIdNoTargets a specific page by ID. Defaults to the selected page.
filePathNo
functionYesA JavaScript function declaration. Example: () => document.title, or (el) => el.innerText
dialogActionNo"accept", "dismiss", or text for window.prompt. Defaults to accept.
waitForStableDomNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.4.3

TDQS

C2.8/5.0
Behavior2/5

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

With no annotations, the description carries the full behavioral burden. It only states that the function is evaluated and the result returned as JSON. It does not disclose whether the operation can mutate the page, whether it requires specific permissions, whether it waits for the page to be ready, or any security implications. This is a significant gap for an arbitrary code execution tool.

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?

The description is two short sentences, front-loaded with the core action and return format. There is no wasted verbiage.

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

Completeness2/5

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

Given the complexity of evaluating arbitrary JavaScript, the lack of annotations, and the absence of an output schema, the description is too sparse. It omits critical context such as execution environment, security restrictions, side effects, and how errors are surfaced. An agent would need to infer or discover much of the tool's behavior.

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?

The input schema provides descriptions for four of six parameters (args, pageId, function, dialogAction), covering 67%. The description adds no parameter semantics at all. Two parameters (filePath, waitForStableDom) lack any description in the schema or the description text, leaving their purpose unclear.

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?

The description states a specific verb 'Evaluate' and resource 'JavaScript function inside the page', and notes the return format (JSON). It is clear enough to distinguish from most sibling tools like click or navigate, but it does not explicitly differentiate from cdp or other scripting alternatives.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It does not mention conditions, prerequisites, or exclusions. The implied usage is that it runs custom JavaScript, but this is not stated explicitly.

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