Skip to main content
Glama
Browser MCP Server

Browser MCP Server

evaluate_javascript

Run custom JavaScript in the current browser page context to read or modify page state, trigger actions, and support dynamic web automation.

Instructions

Run JavaScript in page context.

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": "evaluate_javascript"
  }
}

Input Schema

NameRequiredDescriptionDefault
pageIdNo
scriptYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.0.0

TDQS

C2.1/5.0
Behavior2/5

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

No annotations are supplied, so the description carries the full burden. 'In page context' hints at the execution world, but it says nothing about whether the script's return value is propagated, whether execution is synchronous, how errors/syntax failures surface, or whether page CSP or sandboxing can block the script — all critical for a 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.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The single sentence is front-loaded and free of padding, which is good structurally. But the brevity here is under-specification rather than efficiency — the same sentence count could have carried a usage condition or return-value note at no structural cost.

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

Completeness1/5

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

With no annotations, no output schema, and 0% parameter documentation, the description is the only channel for behavioral and parameter detail and it provides neither. For an arbitrary-code-execution tool this leaves an agent unable to predict results or errors.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0% for both parameters, and the description adds no meaning: it never explains that 'script' is the JS source string to evaluate or what 'pageId' selects (and what happens if it is omitted, given it is optional). The description does not compensate for the coverage gap at all.

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

Purpose3/5

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

The description names a specific verb ('Run') and resource ('JavaScript') plus an execution scope ('in page context'), so the basic action is identifiable. However, it does nothing to separate this from the sibling 'execute_in_frame', which appears to run code in a frame rather than the top-level page, so the distinction is left to inference.

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 when-to-use guidance, no preconditions, and no mention of alternatives. The agent must guess whether this requires an attached browser/page, whether it is preferable to the dedicated element tools like click or get_element_text, and when frame execution should be used instead.

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