Run Command in Sandbox
sandbox_run_commandExecute shell commands inside a sandbox and capture stdout, stderr, exit code, and execution time. Use background mode for long-running processes and follow with logs/status tools.
Instructions
Execute a shell command inside a sandbox. Returns stdout, stderr, exit_code, and execution_time_ms. By default this blocks until the command exits. For anything long-running (dev servers, builds, watchers) pass background: true — it returns a command_id immediately. Follow it with sandbox_get_command_logs / sandbox_get_command_status and stop it with sandbox_interrupt_command.
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": {
"sandbox_id": "<sandbox_id>",
"command": "<command>"
},
"name": "sandbox_run_command"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | Working directory for the command | |
| env | No | Additional environment variables for this command | |
| command | Yes | Shell command to execute, e.g. "python3 -c 'print(1+1)'" or "ls -la /tmp" | |
| background | No | Return as soon as the command starts instead of waiting for it to exit. stdout/stderr come back empty; follow it with the returned command_id. | |
| sandbox_id | Yes | ID of the target sandbox | |
| timeout_seconds | No | Max execution time in seconds |