execute_shell
Execute shell commands on the host system with directory validation and timeout controls, capturing output and exit codes safely.
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 command arguments are validated against allowed directories
Command substitution and dangerous patterns may be restricted
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. | |
| 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. | |
| 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. | |
| timeout | No | Timeout in milliseconds for command execution. Defaults to 30000 (30 seconds). Commands exceeding this duration will be terminated. | |
| requiresApproval | No | Indicates if this command requires explicit user approval. Set to true for potentially dangerous operations (installing packages, deleting files, etc.). |