Skip to main content
Glama
yogesh-joshi-0333

browser-control-mcp-server

Execute JavaScript

browser_execute

Execute JavaScript in the current page to handle complex browser interactions and return the result. Use it for jQuery widgets, DOM changes, page variables, or custom events.

Instructions

Execute arbitrary JavaScript code on the current page and return the result. Use this for complex interactions that other tools cannot handle: jQuery/Select2 dropdowns (e.g. jQuery("#select").val("value").trigger("change")), reading JavaScript variables, calling page functions, manipulating complex widgets, dispatching custom events, or any DOM manipulation. The code runs in the page context with full access to window, document, jQuery, etc. Return a value from your code and it will be sent back as the result. Examples: Set Select2 dropdown: 'jQuery("#project").val("123").trigger("change")' | Read a value: 'document.querySelector("#total").textContent' | Fill multiple fields: 'jQuery("#name").val("John"); jQuery("#email").val("john@example.com"); "done"' | Trigger form submit: 'document.querySelector("form").submit()' | Check if element exists: '!!document.querySelector(".success-message")'

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesJavaScript code to execute in the page context. Has full access to window, document, jQuery ($), and all page globals. The return value of the last expression is sent back as the result. For async operations, return a Promise.
modeNoForce a specific mode. Defaults to extension.
sessionIdNoPuppeteer session ID for headless mode. Skips mode selection.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.5.0

TDQS

A4.3/5.0
Behavior4/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 meaningful work: it discloses the execution context (page context, full access to window/document/jQuery), how values are returned ('return a value from your code'), and async handling ('return a Promise'). It does not cover failure modes, timeouts, or the fact that arbitrary DOM mutation can leave page state altered.

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?

Front-loaded with purpose and the routing rule, then examples. The five pipe-separated examples are lengthy but each maps to a distinct real interaction pattern, so they earn their space. Minor redundancy: both the description and the schema restate jQuery/window access.

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

Completeness4/5

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

No output schema, so the description correctly explains return-value semantics; no annotations, so it also covers execution context. What remains thin is the mode/sessionId machinery for headless vs. extension operation, which is only in the schema and never tied back to a usage decision.

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, and the description earns above it by supplying concrete code-body examples that demonstrate what belongs in the 'code' parameter (returning values, multi-statement bodies, expressions). mode and sessionId are left entirely to the schema, which is acceptable at full coverage.

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

Purpose5/5

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

States a specific verb and resource ('Execute arbitrary JavaScript code on the current page and return the result') and immediately scopes it against the rest of the toolset ('complex interactions that other tools cannot handle'). An agent can distinguish it from browser_click, browser_type, or browser_form_fill without opening any schema.

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

Usage Guidelines4/5

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

Gives concrete when-to-use conditions: Select2/jQuery dropdowns, reading JS variables, calling page functions, custom events, DOM manipulation. The phrase 'that other tools cannot handle' implies a fallback ordering against siblings, but no sibling is named explicitly and no when-not-to-use exclusion is stated.

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