Skip to main content
Glama
congzhou09

chrome-dev-mcp

evaluate_js

Evaluate a JavaScript expression in the page's global scope using DevTools console semantics. Returns serializable values or readable previews for complex objects.

Instructions

Evaluate a JavaScript expression in the page, in global scope, with the same semantics as the DevTools console. Returns the real value when it serialises; objects that cannot (DOM nodes, Errors, Maps, class instances) come back as a preview instead: class name plus a first level of properties, marked … where Chrome truncated it — readable, not parseable as the value. Top-level await works, but an expression that merely RETURNS a promise is NOT awaited — it comes back as a pending Promise, exactly as in the console. The call returns as soon as your expression finishes its synchronous work, before queued microtasks run, so the state triggered by a click is not visible in the same call: put await Promise.resolve() between the click and the read, or read in a second call. At a breakpoint this still evaluates globally and cannot see local or closure variables — use evaluate_at_frame for those. For the element selected in the Elements panel ($0), use get_inspected_element.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.1.0

TDQS

A4.9/5.0
Behavior5/5

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

Annotations only include a title with no behavioral hints, so the description fully bears the transparency burden. It discloses serialization behavior (real values vs. previews for DOM nodes, Errors, Maps, etc.), async semantics (top-level await works but returned promises are not awaited), microtask timing (state changes not visible immediately), and scope limitations at breakpoints. This is thorough and accurate, with no contradictions.

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 long but every sentence adds critical information—serialization, async, microtasks, breakpoint scope, and alternatives. It is well-structured with semicolons and clear transitions, front-loads the core purpose, and avoids redundancy. There is no fluff; each clause earns its place.

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's complexity (async, microtasks, serialization, breakpoint scope) and the absence of an output schema, the description covers all aspects an agent needs to invoke it correctly. It explains return value formats, timing behavior, scope limitations, and routes to siblings where appropriate. Nothing essential is missing.

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?

The schema has one parameter 'expression' with no description (coverage 0%). The description implicitly defines it through the entire tool purpose, repeatedly referring to 'expression' and its evaluation. While it doesn't explicitly state 'the expression parameter should be a JavaScript expression string', the context makes this obvious. For a single simple parameter, this is sufficient, but slightly more explicit wording could earn a 5.

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 the tool evaluates a JavaScript expression in the page's global scope with DevTools console semantics. It explicitly contrasts with siblings evaluate_at_frame (for local/closure variables) and get_inspected_element (for $0), making the purpose unambiguous and distinguishing it from similar tools.

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 this tool versus alternatives: it names evaluate_at_frame for local/closure variables at breakpoints and get_inspected_element for the inspected element. It also gives practical usage tips about async behavior (use await Promise.resolve() between click and read) and microtask timing, so an agent knows exactly how to sequence calls correctly.

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