execute_shell
Run shell commands on the host with security controls: validate working directories, enforce timeouts, and capture stdout, stderr, and exit codes. Requires user approval.
Instructions
Execute shell commands on the host system with security controls. Commands are executed as 'bash -c ' on Unix/Mac.
The tool captures stdout, stderr, exit codes, and signals. Commands exceeding the timeout will be automatically terminated.
⚠️ SECURITY REQUIREMENTS:
At least ONE approved directory must be configured before executing any shell commands
Working directory (workdir parameter or process.cwd()) MUST be within allowed directories
All file/directory paths in arguments and redirections are validated against allowed directories (symlinks are resolved)
Every command in a chain must be approved; chain with ';', '&&', '||' or '|' on a single line
Not allowed: newlines, command substitution, backticks, a lone '&', ( ) { } grouping or script blocks, heredocs, escaped quotes (" ')
Commands matching dangerous patterns are blocked unless the server operator allowed them
If no workdir is specified, the server's current working directory will be used and validated.
No pre-approved commands. All commands require user approval before execution.
IMPORTANT: Always provide a clear description of what the command does and why it's needed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | Shell command to execute. For Windows: executed as 'powershell.exe -Command <command>'. For Unix/Mac: executed as 'bash -c <command>'. *** WARNING: Command substitution using $(), ``, <(), or >() may be restricted for security. | |
| timeout | No | Timeout in milliseconds for command execution. Defaults to 30000 (30 seconds). Commands exceeding this duration will be terminated. | |
| workdir | No | Optional absolute path to the directory where the command should be executed. Must be within allowed directories. If not provided, uses current working directory. | |
| description | No | Brief description of what the command does and why it's needed. Be specific and concise. Ideally a single sentence. Can be up to 3 sentences for clarity. No line breaks. | |
| requiresApproval | No | Deprecated and ignored. Kept for backward compatibility. Commands matching dangerous patterns can only be allowed by the server operator (--allow-dangerous-commands). |