Skip to main content
Glama
pssrh
by pssrh

browser_execute_script

Run JavaScript expressions in the current page to extract data, modify the DOM, or simulate user actions. For multi-step logic, wrap code in an IIFE and return the result.

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; })()

Schema Changelog

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

  1. First observedv1.0.1

TDQS

A3.9/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 of behavioral disclosure. It usefully explains that the handler wraps code in parentheses, that only expressions are allowed, and that top-level return is a syntax error. However, it does not mention that executing arbitrary JS can mutate the page, trigger navigation, initiate network requests, or that promise results and thrown errors need handling. These are material behavioral gaps for an unannotated 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.

Conciseness5/5

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

Three sentences with high information density. The core function comes first, followed immediately by the two most critical pitfalls: parameter name and expression-vs-statement syntax. Every sentence earns its place, and the structure front-loads the most actionable guidance.

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?

The description gives the essential invocation pattern but omits return-value semantics, error handling, async/promise behavior, and side-effect warnings. Since there is no output schema, an agent is left guessing whether the expression's result is returned directly, serialized, or wrapped. This is adequate for simple cases but not fully complete for a powerful, unrestricted script-execution 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?

The input schema already documents that `code` must be a JavaScript expression and recommends an IIFE. The description adds valuable semantics beyond the schema: the alias `script` is accepted, and the handler wraps code in parentheses, explaining why top-level return fails. This meaningfully helps an agent produce valid inputs.

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?

The description states a specific verb and resource: 'Execute JavaScript in the current page.' This clearly distinguishes it from sibling browser automation tools, none of which execute arbitrary JavaScript. It is immediately obvious what the tool does even without reading the schema.

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?

The description implies when to use the tool: whenever you need to run JavaScript in the current page. However, it does not explicitly mention alternatives or when not to use it, such as preferring browser_fetch for network requests or browser_get_page_content for reading page state. The usage context is clear but not fully articulated.

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

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