Skip to main content
Glama

browser_js

Runs JavaScript in a browser tab or iframe context to inspect or manipulate the DOM. Choose an isolated world for safe DOM access or the page context to reach the page's own JS globals.

Instructions

Evaluate JavaScript in the tab (or an iframe target_id). world "isolated" (default) shares the DOM but not the page's JS globals and is invisible to the page; "page" runs in the page's own context. tab: the handle browser_new_tab returned ("t3"). Pass it on every call: several agents can share this server, and the tab is how each one keeps to its own page.

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

Input Schema

NameRequiredDescriptionDefault
tabNo
worldNoisolated
target_idNo
expressionYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.5/5.0
Behavior3/5

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

With no annotations, the description carries the full burden and does disclose meaningful behavior: the isolated world shares the DOM but not page JS globals and is invisible to the page, while "page" runs in the page's own context. It says nothing about what the call returns, whether the expression is awaited, how results are serialized, or how errors surface — significant gaps 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?

Three sentences, front-loaded with the action, then world semantics, then the tab-handle rule. Dense but every sentence carries information; the parenthetical handle example is slightly compressed but not wasteful.

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?

For a four-parameter tool with no annotations and no output schema, parameter coverage is good, but the return contract is entirely absent — an agent cannot tell whether it gets the evaluated value, a serialized JSON blob, or nothing. That omission matters more here than for a read-only sibling because the result is the whole point of the call.

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 description coverage is 0%, so the description must compensate, and it largely does: it explains the two `world` values and their consequences, defines `tab` as the handle returned by browser_new_tab ("t3") and why it must be passed every call, and identifies `target_id` as an iframe selector. Only `expression` is left without added meaning beyond its name.

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: "Evaluate JavaScript in the tab (or an iframe `target_id`)." That is enough to distinguish it from the interaction siblings (browser_click, browser_fill, browser_read), though it never contrasts itself with the closer alternatives like browser_cdp or browser_observe.

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?

Offers real operational guidance: pass the `tab` handle on every call because several agents share the server, and choose `world` based on whether page globals are needed. It gives no explicit when-to-use-this-instead-of guidance against siblings such as browser_cdp or browser_read, and no when-not-to-use conditions.

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