Skip to main content
Glama

run_script

Destructive

Run a short JavaScript program on this computer that calls several BCD tools in a row and returns only what it logs or returns, in one round trip. Use it for multi-step work (read several files and pick lines, search then read the matches, check then write) instead of calling the tools one by one. Inside, call tools as await tools.read_file({ path }) (same names and arguments as the tools themselves); each returns its result (structured fields plus .text, the text you would have read) and throws when the tool fails. console.log(...) and the returned value come back; sleep(ms) waits. Each call is checked against this computer's permissions and recorded like a direct call. Not available inside: run_script, workflows, shutdown. At most 200 calls; no require/import, network only through tools such as read_url.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>"
    },
    "name": "run_script"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesThe body of an async function: use await, log with console.log, and optionally return a value
deviceIdNoComputer name or id
workSessionIdNoFrom create_work_session
timeoutSecondsNoStop after this many seconds; calls already made are not undone

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changed
    • removedInput schema / properties / code / maxLength
      Removed value: -20000
    • removedInput schema / properties / code / minLength
      Removed value: -1
    • changedInput schema / properties / deviceId / description
      Previous value: -"Computer name or id; optional with one computer or a default"New value: +"Computer name or id"
  2. Added

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already flag destructiveHint=true and openWorldHint=true, and the description adds far more: how inner calls are made, that each returns structured fields plus .text and throws on failure, that console.log and return values come back, that every call is permission-checked and recorded, a 200-call cap, no require/import, and network only via tools. That is materially more than the annotations provide.

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?

Purpose is front-loaded in the first sentence, followed by usage, invocation contract, and limits in descending order of importance. Despite being dense, every clause carries a distinct operational fact; there is no filler or repetition.

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 destructive, open-world, multi-step orchestration tool with no output schema, the description covers invocation contract, error semantics, return shape, limits, and permission/recording behavior. What remains thin is mid-script failure recovery (whether already-executed writes persist) and sandbox/timeout interaction, though the schema does state that timed-out calls are not undone.

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%, so parameter documentation is already handled. The description nevertheless adds real semantic value about the code payload — async-function body, await-based tool invocation with identical names/arguments, sleep(ms), console.log capture — which the schema does not spell out. The timeout/undo semantics live in the schema rather than the description.

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 opens with a specific verb and resource ('Run a short JavaScript program on this computer') and immediately states the mechanism and payoff: batched BCD tool calls returning only logged/returned values in one round trip. This clearly distinguishes it from single-call siblings like run_command or read_url without needing to name them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit when-to-use guidance with concrete examples ('read several files and pick lines, search then read the matches, check then write') and an explicit alternative it replaces ('instead of calling the tools one by one'). It also names exclusions ('Not available inside: run_script, workflows, shutdown'), so the agent knows the boundaries of the inner execution context.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources