Skip to main content
Glama

browser_execute_script

Execute JavaScript expressions in the active page to automate tasks, extract data, or manipulate DOM. Wrap multi-step logic in an IIFE to return results.

Instructions

Execute JavaScript in the current page. IMPORTANT: the parameter is code (NOT script — though that alias is accepted), and it must be an EXPRESSION, not statements: use an IIFE (() => { ...; return x; })(). Top-level return is a syntax error (the handler wraps code in parentheses).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesJavaScript EXPRESSION to evaluate in page context. For multi-statement logic use an IIFE: (() => { ...; return result; })()
Install Server

TDQS

A4.1/5.0
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It does so well by explaining the wrapper behavior, the accepted `script` alias, the expression-only requirement, and the top-level `return` syntax error. It does not mention side effects or return-value handling, which prevents a 5.

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?

The description is two dense, front-loaded sentences. The purpose appears immediately, and every subsequent phrase adds critical caveats. There is no filler or redundancy with the schema.

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 single-required-parameter tool with 100% schema coverage, the description covers the essential syntax traps and invocation requirements. It does not state whether the expression's value is returned, but this is a minor gap for such a low-complexity tool.

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% and the schema already documents the expression/IIFE requirement, so the baseline is 3. The description adds value beyond the schema by warning about the `script` alias, prohibiting statements, and explaining why top-level `return` fails.

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?

The description states the action and resource precisely: 'Execute JavaScript in the current page.' It is clear and unambiguous, though it does not explicitly contrast with sibling tools. Since it is the only script-execution sibling, ambiguity is low.

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?

The description makes the intended use clear: run JavaScript in the live page, with strict invocation constraints. It does not name alternatives or exclusion cases, but the 'current page' scoping is enough to separate it from most sibling tools.

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

Other Tools

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/Agent360dk/browser-mcp'

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