Skip to main content
Glama

execute_script

Run arbitrary JavaScript in the active browser tab to inspect or modify page state and return the evaluated result; optionally capture console output and set a timeout.

Instructions

Execute arbitrary JavaScript code in the active browser tab and return the result

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": {
      "code": "<code>"
    },
    "name": "execute_script"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesJavaScript expression to evaluate
worldNoExecution world hint (currently accepted but not enforced)
timeoutMsNoTimeout in milliseconds
captureConsoleNoCapture console output during evaluation

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.0.0

TDQS

C2.9/5.0
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It says 'arbitrary JavaScript' and 'return the result', but discloses nothing about side effects on page state, permission or security constraints, error behavior, or what happens when the result is non-serializable — all critical for an arbitrary-code-execution 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?

A single tight sentence with the verb and scope front-loaded and no filler. Its brevity is appropriate even if it leaves useful behavior unstated.

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

Completeness2/5

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

For a four-parameter arbitrary-code-execution tool with no annotations and no output schema, the description should explain return value handling and side-effect semantics. The schema covers the inputs well, but the behavioral picture an agent needs before running arbitrary code is missing.

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?

Schema description coverage is 100%, so all four parameters including the 'world' enum and its 'accepted but not enforced' caveat are already documented in the schema. The description adds no parameter meaning beyond that, which is the expected baseline when the schema does the work.

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 (execute) and resource (arbitrary JavaScript in the active browser tab) plus the return behavior. An agent can distinguish it from the narrower browser_execute_in_frame and from action tools like browser_click, though the description never names those siblings explicitly.

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

Usage Guidelines2/5

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

There is no guidance on when to reach for this tool versus the purpose-built siblings (browser_click, browser_type, browser_get_text, browser_execute_in_frame) or when not to use it. The agent must infer that this is a fallback for cases no dedicated tool covers.

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