Skip to main content
Glama

run_js

Execute custom JavaScript in a selected Safari tab and receive the JSON-encoded output, solving cases where dedicated tools do not cover the needed action.

Instructions

Run arbitrary JavaScript in a tab. The escape hatch; prefer the others.

Your code runs as a function body, so return the value you want back. The result is JSON-encoded, so return plain data rather than DOM nodes.

Args: tab: Tab index within window 1, or a substring of its URL or title. code: JavaScript to execute. Use return to produce a result.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tabYes
codeYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.5/5.0
Behavior4/5

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

With no annotations, the description carries the behavioral disclosure burden. It usefully explains that code runs as a function body, requires `return`, and that results are JSON-encoded (so return plain data, not DOM nodes). It does not mention error handling or side effects, but it discloses the key execution semantics an agent needs.

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 tightly organized: a one-line purpose, a short usage hint, two behavioral sentences, and two bullet-style parameter explanations. Every sentence earns its place and the most important information is front-loaded.

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 an arbitrary-JS tool with no annotations and a minimal schema, the description covers tab targeting, code execution, and return-style expectations. It could add notes on error behavior or async handling, but it contains enough to call the tool correctly in typical cases.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description fully compensates. It explains `tab` as a tab index within window 1 or a URL/title substring, and `code` as JavaScript to execute with `return` for results. Both parameters gain meaning beyond their bare string type.

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 ('Run arbitrary JavaScript in a tab') and immediately differentiates itself from siblings with 'The escape hatch; prefer the others.' An agent can tell exactly what it does and how it relates to the other tools.

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 clear usage context by labeling itself an escape hatch and advising to prefer the other tools, which implies using it only when the dedicated siblings do not cover the need. It does not name specific alternative conditions, but the guidance is clear enough for selection.

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