Skip to main content
Glama
Browser Control MCP Server

Browser Control MCP Server

by lostmind008

execute_javascript

Run JavaScript code directly in a browser page context to inspect or modify the DOM, read variables, or trigger page actions. Optionally target a specific tab by ID.

Instructions

Execute JavaScript in the 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": {
      "code": "<code>"
    },
    "name": "execute_javascript"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesJavaScript code to execute
tabIdNoTab ID (optional)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv3.1.0

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations, the description carries the full behavioral burden yet says nothing about whether execution is awaited, whether the script's return value is surfaced, how errors or exceptions are reported, or whether the code persists in the page. The only real disclosure is the execution scope (page context), which is valuable but minimal 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 front-loaded sentence with zero wasted words, which is structurally sound. It is terse to the point of under-specification, but the phrasing itself is efficient and clear.

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 tool that runs arbitrary code with no annotations and no output schema, the description should explain return-value handling, error behavior, and any safety implications. None of that is present, leaving the agent unable to predict what it gets back after invoking it.

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 both `code` and `tabId` are documented in the schema, which sets the baseline at 3. The description adds no extra meaning, notably leaving unstated what happens when `tabId` is omitted (presumably the current tab).

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 JavaScript") and scopes it to "the page context," which distinguishes it from non-page execution environments. It does not differentiate itself from sibling tools such as click/fill, but those are obviously different operations, so the purpose is still clear.

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 use this instead of dedicated tools like click, fill, or get_page_content, and no mention of the intended use case (escape hatch for one-off automation). An agent must infer that this is a general-purpose fallback.

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