Skip to main content
Glama
ochen1
by ochen1

evaluate_script

Execute JavaScript functions in a web page to extract data or perform actions, returning results as JSON for automated testing or content retrieval.

Instructions

Evaluate a JavaScript function inside the currently selected page. Returns the response as JSON, so returned values have to be JSON-serializable.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
functionYesA JavaScript function declaration to be executed by the tool in the currently selected page. Example without arguments: `() => { return document.title }` or `async () => { return await fetch("example.com") }`. Example with arguments: `(el) => { return el.innerText; }`
argsNoAn optional list of arguments to pass to the function.
dialogActionNoHandle dialogs while execution. "accept", "dismiss", or string for response of window.prompt. Defaults to accept.
Behavior3/5

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

Annotations indicate readOnlyHint=false, suggesting a write operation, but the description doesn't clarify this behavior. It adds useful context about JSON-serializable returns and execution in the page context, which annotations don't cover. However, it lacks details on side effects, error handling, or execution environment constraints.

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 two concise sentences that efficiently state the core functionality and return format. It's front-loaded with the main purpose. However, the second sentence could be integrated more smoothly, and it lacks structural elements like bullet points for clarity.

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?

Given the tool's complexity (executing arbitrary JavaScript in a page context) and lack of output schema, the description is minimally adequate. It covers the basic purpose and return format but misses details on execution safety, error cases, or how it fits with sibling tools. With annotations only covering read/write hint, more behavioral context would be helpful.

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 fully documents parameters. The description doesn't add meaning beyond the schema's details about function declarations, args as element UIDs, or dialogAction options. It mentions JSON-serializable returns, which relates to output but not input parameters.

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 clearly states the tool's purpose: 'Evaluate a JavaScript function inside the currently selected page.' It specifies the verb ('Evaluate'), resource ('JavaScript function'), and context ('currently selected page'). However, it doesn't explicitly differentiate from sibling tools like 'get_console_message' or 'take_snapshot' that also interact with page content.

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 doesn't mention prerequisites (e.g., needing a selected page), exclusions, or compare it to sibling tools like 'get_console_message' for retrieving console output or 'take_snapshot' for capturing page state.

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/ochen1/chrome-devtools-mcp-mux'

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