Skip to main content
Glama
andresolbach

nodriver-mcp-server

Evaluate JavaScript

evaluate_script

For actions other tools miss, execute custom JavaScript in the page and get JSON results, with optional element references from snapshots.

Instructions

Run JavaScript inside the page and get the result back as JSON.

The escape hatch for anything the other tools do not cover: reading computed styles, calling a page's own JS API, or extracting structured data in a single round trip instead of a dozen snapshot-and-click cycles.

Without args the function runs at page level in the main world. With args, the given uids become real element references, which is how you operate on one specific element from a snapshot.

Return values must be JSON-serialisable — DOM nodes, functions and circular structures are not, so map them to plain values inside the function. Errors are returned as a string beginning with "Error:" rather than raised.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argsNoElement uids from the most recent take_snapshot, resolved to live DOM nodes and passed as the function's arguments. The first uid is also bound as `this`. Omit for page-level scripts.
functionYesA JavaScript function expression, e.g. "() => document.title" or "(el) => el.innerText". It is invoked immediately and its return value is JSON-serialised back to you. Async functions are awaited, so "async () => (await fetch('/api/x')).json()" works. Return a value — console.log output is not captured.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

The description discloses substantial behavioral detail beyond annotations: runs in the main world, args become live DOM element references, return values must be JSON-serialisable, async functions are awaited, errors are returned as strings, and console.log output is not captured. These are non-obvious runtime behaviors that an agent needs to know, and they do not contradict the provided annotations.

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 four sentences, front-loaded with the core purpose, followed by usage context and critical behaviors. Each sentence carries distinct, necessary information with no filler or redundancy, making it efficient and easy to scan.

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

Completeness5/5

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

For a tool with only 2 parameters and full schema coverage, the description covers all essential aspects: invocation mode, argument semantics, return serialization constraints, async handling, error behavior, and a limitation (console.log not captured). With an output schema also present, nothing important is left unexplained.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3, but the description adds operational context: args resolve to DOM nodes rather than strings, page-level vs. element-scoped execution, and the requirement to map DOM nodes to plain values in the return. This supplements the schema's already-solid parameter descriptions with practical usage nuance.

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 identifies the tool as executing JavaScript in the page and returning JSON, and goes further by positioning it as the 'escape hatch' for scenarios other tools don't cover, with concrete examples like reading computed styles and calling page APIs. This strongly distinguishes it from sibling tools such as click, take_snapshot, and navigate_page.

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?

It provides an explicit when-to-use heuristic: 'the escape hatch for anything the other tools do not cover', with illustrative use cases. It also explains the two invocation modes (page-level vs. element-targeted via args). It doesn't name specific alternative tools or say when not to use it, leaving a small gap in guidance.

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/andresolbach/nodriver-mcp-server'

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