Skip to main content
Glama

evaluate_script

Destructive

Execute focused JavaScript functions to inspect DOM state, web storage, page globals, or process a local file, returning runtime values for analysis.

Instructions

Evaluates one focused JavaScript function for DOM/page state, web storage, page-defined globals, a paused-frame expression, or browser-side processing of one local file. Use it when those runtime values are the goal and no narrower evidence tool applies. Do not use document.cookie or page evaluation to investigate HttpOnly/Secure cookies, Set-Cookie provenance, or captured HTTP evidence; use list_network_requests with cookieName/reqid, and use search_in_sources/get_script_source for source discovery. While running, evaluation uses the selected frame's isolated world by default or its page main world with mainWorld=true; while paused, it always uses the chosen call frame and ignores mainWorld. Call get_paused_info before paused evaluation, then step or resume when finished. Arbitrary code can change page/external state and requires confirm=true; inline results are bounded, so use outputFile for exact large or binary results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
confirmNoMust be true to authorize this exact arbitrary-code evaluation, which may mutate page state, send requests, or cause external side effects. Prefer a read-only expression when inspection is sufficient.
functionYesJavaScript function declaration invoked by the tool, for example `() => document.title` or `async () => await Promise.resolve(location.href)`. Return JSON-serializable data; ArrayBuffer/typed arrays require outputFile for exact bytes. With localFilePath, accept `async ({localFile}) => ...` and read localFile.text for UTF-8 or localFile.base64 for exact bytes. Keep the function focused; use mainWorld=true only when page-defined globals are required.
mainWorldNoRunning-page mode only: false uses the selected frame's isolated context; true uses that frame's page main world to access application-defined globals. When execution is paused, evaluation always targets frameIndex and this option is ignored.
frameIndexNoPaused mode only: zero-based call frame from get_paused_info (default: top frame). The index and its callFrameId expire after any step or resume.
outputFileNoSave the exact result locally instead of returning bounded inline content. JSON-serializable values are written as JSON text and ArrayBuffer/typed arrays as raw bytes; the returned filename is resolved and subject to --allowedRoots.
localFilePathNoAbsolute path to one host file passed as localFile; the browser never reads the path directly. Relative paths, file:// URLs, globs, ~, and directories are rejected, access is subject to --allowedRoots, and file contents may expose sensitive host data.
confirmOverwriteNoSet true only to authorize replacing an existing outputFile. A new file does not require overwrite confirmation.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okYesWhether the tool completed successfully.
dataNo
toolYesStable MCP tool name.
errorNo
summaryYesConcise human-readable outcome.
Behavior5/5

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

Annotations already indicate readOnlyHint=false, openWorldHint=true, destructiveHint=true. The description adds significant context: arbitrary code can change page state, requires confirm=true, inline results are bounded, paused mode ignores mainWorld, and frameIndex expires. No contradiction with annotations; instead, it elaborates on safety and behavioral edge cases.

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 well-structured, front-loading the core purpose and then providing specific usage notes. It uses clear, separate sentences for distinct points. While slightly verbose, every sentence conveys necessary information without redundancy. It could be marginally tighter but remains highly effective.

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?

Given the tool complexity (7 parameters, 1 required, annotations, output schema, 23 siblings), the description covers all necessary aspects: purpose, usage alternatives, behavioral details (paused vs running, confirm, outputFile), and parameter semantics. It implicitly addresses return values by distinguishing inline vs outputFile results. No gaps are evident.

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 description coverage is 100%, so baseline is 3. However, the description adds meaningful context beyond schema: function parameter explains async functions, localFile argument, JSON serialization limits; mainWorld clarifies its behavior in paused vs running mode; frameIndex mentions expiration; outputFile specifies JSON or raw bytes; localFilePath warns about rejected patterns and host data exposure. This adds value, justifying a 4.

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 it evaluates JavaScript functions for runtime values like DOM state, web storage, or expressions. It distinguishes itself from siblings by explicitly naming narrower tools (list_network_requests, search_in_sources, get_script_source) and specifying when not to use them. The verb 'evaluate' is specific and the resource ('JavaScript function') is well-defined.

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 on when to use (when runtime values are the goal and no narrower tool applies) and when not to use (for cookies, Set-Cookie provenance). It lists alternative tools (list_network_requests, search_in_sources). It also covers paused vs running mode, confirm requirement, and outputFile usage, giving a complete usage context.

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/zhizhuodemao/js-reverse-mcp'

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