Skip to main content
Glama

Execute JavaScript

execute_js

Execute JavaScript code directly in browser pages to interact with elements, fill forms, or call functions for debugging and automation tasks.

Instructions

Execute JavaScript code in the page context. Returns the result of the expression. Useful for clicking buttons, filling forms, or calling page functions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesJavaScript code to execute in page context
targetIndexNoTarget index from list_targets
portNoChrome CDP port
Behavior2/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 mentions that the tool 'Returns the result of the expression,' which is helpful, but lacks critical details such as execution context (e.g., sandboxing, permissions), error handling, timeout behavior, or security implications. For a tool that executes arbitrary JavaScript code, this is a significant gap in transparency.

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?

The description is appropriately sized with three sentences that are front-loaded: the first states the core functionality, the second explains the return value, and the third provides usage examples. There's no wasted text, though the examples could be more structured or prioritized.

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

Completeness2/5

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

Given the complexity of executing JavaScript code in a page context (with no annotations and no output schema), the description is incomplete. It lacks details on execution safety, error responses, or output formatting. The examples help but don't compensate for missing behavioral context, making this inadequate for a tool with such potential impact.

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%, providing clear documentation for all three parameters (code, targetIndex, port). The description doesn't add any parameter-specific information beyond what's in the schema, such as code examples or constraints. With high schema coverage, the baseline score of 3 is appropriate as the schema handles the heavy lifting.

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 clearly states the action ('Execute JavaScript code') and resource ('in the page context'), with a specific verb+resource combination. However, it doesn't explicitly distinguish this tool from its siblings (get_console_logs, list_targets, navigate), which all operate in the same browser automation context but serve different purposes.

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 provides implied usage guidance through examples ('clicking buttons, filling forms, or calling page functions'), suggesting this tool is for interacting with page elements. However, it doesn't explicitly state when to use this tool versus alternatives like navigate for page navigation or list_targets for target selection, nor does it mention any exclusions or prerequisites.

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/tznthou/simple-console-mcp'

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