Skip to main content
Glama
chrome-dev-mcp

chrome-dev-mcp

evaluate_js

Run JavaScript expressions in the inspected page's global scope like the DevTools console, returning real values or readable previews for objects that cannot serialize.

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 (30s max), 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.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "expression": "<expression>"
    },
    "name": "evaluate_js"
  }
}

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.4/5.0
Behavior4/5

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

Annotations carry only a title, so the description does the full disclosure work and does it well: serialisation fallback behavior for DOM nodes/Errors/Maps/class instances, the `…` truncation marker, the 30s cap on top-level await, the fact that returning a promise is not awaited, and the synchronous-completion/microtask boundary. The only small gap is that it does not say what happens on thrown exceptions or syntax errors, which matters for a code-evaluation tool.

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?

Front-loaded with purpose and the console-equivalence anchor, then layers caveats in a logical order (return shape, await semantics, timing, breakpoint scope, siblings). It is dense and long-ish for a one-parameter tool, but nearly every clause carries operational information an agent would otherwise get wrong; only the microtask explanation is slightly over-elaborated.

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?

With no output schema and no meaningful annotations, the definition supplies exactly what is missing: what the return value looks like, when it is a lossy preview, and the timing model. Nothing an agent needs in order to call this correctly and interpret the result is absent.

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?

There is one required parameter with 100% schema description coverage, so the schema already explains that the string is evaluated as-is and that functions must be wrapped. The description adds no additional parameter-level detail beyond that baseline, which is acceptable at this coverage level but is not additive.

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 pins the semantics to the DevTools console, which is a precise and familiar reference point. It explicitly separates itself from evaluate_at_frame and get_inspected_element in the final sentences, so an agent can choose confidently without opening another 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?

Names two alternatives with the exact condition that selects each: evaluate_at_frame for local/closure variables at a breakpoint, get_inspected_element for $0. It also gives actionable guidance on microtask timing (insert `await Promise.resolve()` or read in a second call), which is a when-to-use rule in practice.

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