Skip to main content
Glama
chrome-dev-mcp

chrome-dev-mcp

evaluate_js

Evaluates a JavaScript expression in the page’s global scope using DevTools console semantics, returning serialized values or previews for non-serializable 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

NameRequiredDescriptionDefault
expressionYesJS source evaluated as-is. A function is not called — wrap it: `(() => { ... })()`

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv2.0.0
    • addedInput schema / properties / expression / description
      Added value: +"JS source evaluated as-is. A function is not called — wrap it: `(() => { ... })()`"
  2. First observedv1.1.0

TDQS

A4.6/5.0
Behavior4/5

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

Only a title annotation exists, so the description carries the behavioral burden and does so richly: serialization vs. preview for DOM nodes/Errors/Maps, top-level await semantics, returned-promise non-awaiting, and microtask timing. It stops short of noting any permissions/limits or error behavior when the expression throws, which keeps it from a 5.

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?

Information is front-loaded — core behavior, then return-value caveats, then the async-timing gotcha, then sibling routing. It is long and sentence-dense with some em-dash nesting, but nearly every clause conveys a distinct operational caveat.

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?

No output schema exists, so the description must explain return values, and it does: real values when serialisable, class-name-plus-first-level previews otherwise, marked truncation. Combined with the async-timing and scope limitations, an agent has everything needed to call it correctly.

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% and already notes functions are not called, so the baseline is 3. The description adds value by specifying the expression is evaluated in global scope with DevTools-console semantics, clarifying how the argument is interpreted beyond the schema's wording.

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?

States a specific verb and resource ('Evaluate a JavaScript expression in the page, in global scope') and immediately scopes it against related capabilities. It names evaluate_at_frame and get_inspected_element explicitly so an agent can distinguish it from siblings without opening a schema.

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?

Gives explicit when-to-use/alternatives: use evaluate_at_frame for local/closure variables at a breakpoint, get_inspected_element for $0, and put `await Promise.resolve()` or make a second call when reading state after a click. The routing conditions are stated, not inferred.

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