Skip to main content
Glama

code_execute

Destructive

Execute JavaScript in an isolated QuickJS WASM heap with checked OS/MCP helpers, enabling controlled file, shell, and MCP tool operations with optional Docker isolation.

Instructions

Execute JavaScript in an isolated QuickJS WASM heap. Node.js globals, imports and direct network access are unavailable. Every OS/MCP operation uses checked helpers. With CODE_MODE_ISOLATION=docker shell/file helpers run in a container; configured MCP tools and policy hooks run on the host through a checked bridge. Without Docker, permitted shell commands run with the current user's OS permissions. cwd is the absolute project directory, passed as this tool's cwd argument: required for a new session (do not define cwd inside the code); omit it only when sessionId continues an existing session. Async APIs: read(file), write(file,text), edit(file,oldText,newText), run(command,{cwd,timeoutMs}), listMcpServers(), listMcpTools(server), callMcp(server,tool,args), log(...values), and tagged $ commands with .text()/.nothrow(). Return explicitly or end with an expression. Optional sessionId persists explicit JSON state; normal variables are not retained. Default autoApprove executes without classifier calls, approval queues or human prompts. Deny rules and blocking hooks still apply. Recorded operations cover helpers; shell programs' internal actions are not individually recorded.

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": "code_execute"
  }
}

Input Schema

NameRequiredDescriptionDefault
cwdNo
codeYes
sessionIdNo
timeoutMsNo
reviewAfterNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.12.0

TDQS

A4.1/5.0
Behavior5/5

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

Annotations already declare destructive/openWorld, but the description adds substantial context beyond them: no Node globals or direct network, checked helpers, Docker vs non-Docker permission differences, host-vs-container split for MCP bridge and policy hooks, autoApprove bypassing prompts while deny rules still apply, and the caveat that shell programs' internal actions are not individually recorded.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

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

The core purpose is front-loaded and most sentences carry real information, but the definition is a single dense paragraph mixing sandboxing, permissions, async API inventory, and session semantics with no structural separation. The API enumeration in particular reads as a list flattened into prose.

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?

For a high-complexity, destructive, open-world tool with no output schema and 0% schema coverage, the description covers execution semantics well but leaves two of five parameters (timeoutMs, reviewAfter) entirely undefined and gives no hint about return values beyond 'return explicitly or end with an expression.'

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 0%, so the description carries the burden. It explains code, cwd (with precise new-session vs continuation rules), and sessionId state persistence, but never mentions the top-level timeoutMs parameter (its timeoutMs reference belongs to the run helper) and says nothing about the nested reviewAfter object with base/mode/intent/autoChecks/checkCommands.

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 runtime: 'Execute JavaScript in an isolated QuickJS WASM heap.' The sandbox identity, helper-only OS access, and session model make it distinguishable from siblings like code_start or code_status without opening a schema.

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?

Gives a concrete rule for the main usage decision: cwd is required for a new session and must be omitted only when sessionId continues an existing one, and cwd must not be defined inside the code. It stops short of explicitly routing between this tool and siblings such as code_session_resume, so the session-resume boundary is left implicit.

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