code_execute
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
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | ||
| code | Yes | ||
| sessionId | No | ||
| timeoutMs | No | ||
| reviewAfter | No |