Skip to main content
Glama

execute_javascript

Execute JavaScript in a loaded browser page to extract data, modify content, or automate actions, returning JSON-serializable values and supporting persistent tab reuse.

Instructions

Execute arbitrary JavaScript in the context of a loaded web page. The script runs in the browser and must return a JSON-serializable value. Supports persistent sessions via tab_id — when using a tab_id, the url parameter is optional (executes on the current page).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlNoThe URL to load before executing the script (optional if tab_id is provided)
scriptYesJavaScript code to execute. The last expression is returned, or use 'return' explicitly.
tab_idNoReuse a persistent tab (from open_tab) instead of opening a new one
timeoutNoTimeout in ms (default: 30000)

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv1.0.0

TDQS

A4/5.0
Behavior3/5

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

No annotations are present, so the description carries the transparency burden. It usefully discloses that the script runs in the browser and must return a JSON-serializable value, but it does not mention error behavior, timeout/async semantics, or the potentially page-mutating side effects of arbitrary JS.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

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

Two sentences with no filler; the primary action and the most important usage caveat are front-loaded. Every clause adds functional information.

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?

For a four-parameter tool with no output schema or annotations, the description covers execution context, return-type constraint, and tab/session behavior. It leaves minor gaps around error handling and asynchronous behavior, but an agent can reasonably decide how to invoke the tool.

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 the baseline is 3. The description adds a little context (persistent sessions and the current-page behavior when tab_id is used), but those details mostly duplicate the existing parameter descriptions rather than substantially expanding them.

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 in the context of a loaded web page') and clarifies the return contract. This clearly differentiates it from sibling tools like fetch_page, open_tab, or click_and_navigate, which do not run custom JS.

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 clear invocation context by explaining persistent sessions via tab_id and when the url parameter may be omitted. It does not explicitly compare to sibling tools or state when not to use this tool, so it falls just short of full alternative guidance.

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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wgarrido/mcp-browser'

If you have feedback or need assistance with the MCP directory API, please join our Discord server