Skip to main content
Glama
Chrome Testing MCP Server

Chrome Testing MCP Server

by prabhubng

Execute JavaScript

chrome_execute_script
Destructive

Run custom JavaScript in the current browser page to check application state, test UI behavior, or extract data from web content.

Instructions

Execute custom JavaScript in the browser context.

Runs arbitrary JavaScript code on the current page. Useful for custom testing scenarios or data extraction.

Args:

  • script (string): JavaScript code to execute (required)

  • args (array): Arguments to pass to the script (optional)

Returns: Result of the script execution.

Examples:

  • Get element count: { script: "return document.querySelectorAll('.item').length" }

  • Check state: { script: "return window.myApp.isReady" }

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": {
      "script": "<script>"
    },
    "name": "chrome_execute_script"
  }
}

Input Schema

NameRequiredDescriptionDefault
argsNoArguments to pass to the script
scriptYesJavaScript code to execute in the browser context

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.6/5.0
Behavior3/5

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

Annotations already declare destructiveHint=true, readOnlyHint=false, and non-idempotent, so the safety profile is covered elsewhere. The description adds that code runs against the current page state and that the script's result is returned, but it says nothing about error handling, timeouts, or the fact that arbitrary execution can mutate page state — a notable omission for an arbitrary-code tool.

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?

Front-loaded with the core action, then structured Args/Returns/Examples sections with no filler. The two short examples each demonstrate a distinct capability (DOM query and app-state read) and earn their space.

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

Completeness3/5

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

With no output schema, 'Returns: Result of the script execution' is too vague to tell the agent what shape to expect or how errors surface. For a destructive arbitrary-execution tool, more detail on failure behavior and return serialization would be needed for full completeness.

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 examples genuinely add meaning: they demonstrate that the script body must use an explicit `return` to surface a value, which is not expressible in the schema. Examples also show how `args` is intended to be consumed by the script.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Execute custom JavaScript in the browser context') and clarifies it runs on the current page, which distinguishes it from navigation or interaction siblings like chrome_click and chrome_type. It does not explicitly name those siblings as alternatives, so it falls just short of a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

'Useful for custom testing scenarios or data extraction' implies a usage context but gives no conditions for choosing this over chrome_click, chrome_type, or chrome_wait_for_element, and no when-not-to-use guidance. The agent must infer that this is the general-purpose escape hatch.

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