shell_exec
Run shell commands and wait for completion, returning exit code, stdout, and stderr. Ideal for short-lived tasks needing full system access via the default shell.
Instructions
Run a shell command and wait for it to finish. Returns exit code, stdout and stderr. Full system access via the default shell (or the one you name). Use for anything short-lived.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | Working directory. Relative paths resolve against the server cwd. Default: server cwd. | |
| env | No | Extra environment variables. | |
| login | No | Run through a login shell so ~/.profile aliases and PATH apply. | |
| quiet | No | Return only the exit code line, no output. Default false. | |
| shell | No | Override shell for this call: auto|bash|gitbash|zsh|fish|sh|cmd|powershell|pwsh|wsl, a configured name, or an absolute path. | |
| stdin | No | Text piped to the command on stdin. | |
| assign | No | Store the trimmed stdout in the server variable of this name, reusable later as ${vars.<name>} without passing it back. See the vars tool. | |
| command | Yes | Command line to run in the shell. Multi-line scripts are supported. | |
| timeout_ms | No | Kill the command (whole process tree) after this many ms. 0 = no limit. | |
| merge_streams | No | Report stderr inside stdout as one block (fewer tokens). Default false. | |
| max_output_bytes | No | Byte cap on returned output before middle-truncation. Lower it to save tokens. |