e2b_run_command
Execute a command inside an E2B sandbox and capture its output, errors, and exit code within a set timeout to verify behavior or retrieve results.
Instructions
Run a command in a sandbox and wait (up to timeoutMs) for it to finish, returning collected stdout/stderr/exit status. Uses the streaming process.Process/Start RPC under the hood.
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": {
"sandboxId": "<sandboxId>",
"cmd": "<cmd>"
},
"name": "e2b_run_command"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cmd | Yes | Executable to run, e.g. 'bash' | |
| cwd | No | ||
| args | No | Arguments, e.g. ['-lc', 'echo hi'] | |
| envs | No | ||
| port | No | Optional envd port; defaults to 49983 | |
| username | No | ||
| sandboxId | Yes | E2B sandbox ID | |
| timeoutMs | No | How long to wait for the command to finish before returning partial output | |
| accessToken | No | Optional sandbox access token |