Skip to main content
Glama

execute_js

Destructive

Run JavaScript in the page's main world to read or alter the DOM, extract data, or test interactions. Returns the result of the last executed expression.

Instructions

Run JavaScript in the page (MAIN world). Requires the extension's "Allow user scripts" toggle; errors explain setup if disabled.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesJS evaluated in the page; the value of the last expression is returned
tab_idNoTarget tab; omitted = last tab navigated in this session, else the active one
frame_idNoTarget iframe id from get_frames; omitted = main frame
max_lengthNoMax output chars
Behavior4/5

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

Annotations already indicate destructive and non-readonly behavior. The description adds important context about MAIN world execution and the permission toggle, complementing annotations without contradiction.

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?

Extremely concise two sentences: first sentence states core purpose, second sentence adds essential setup requirement. No wasted words, every sentence earns its place.

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?

Covers core purpose and setup requirement well. Schema already documents that the return value is the last expression result. Could mention async behavior, but overall sufficiently complete given the tool's simplicity.

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?

All parameters are fully documented in the schema with 100% coverage. The description adds no additional semantics beyond what the schema provides, meeting the baseline expectation.

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 clearly states the tool runs JavaScript in the MAIN world of the page, using specific verb 'run' and resource 'JavaScript in the page', distinguishing it from similar sibling tools that may operate in other contexts.

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?

Provides a clear precondition (requires 'Allow user scripts' toggle) and a helpful note about error messages explaining setup if disabled. However, it does not explicitly compare with alternative tools like query_dom or modify_dom.

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

Install Server

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/frsorrentino/chrome-bridge'

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