The runProcess tool allows you to execute system commands in two modes: Shell Mode (using a single command string) or Executable Mode (using an array of arguments).
Execution Modes
- Shell Mode: Provide a
command_line string. This is useful for complex commands involving pipes or shell built-ins. You cannot use argv in this mode. - Executable Mode: Provide an
argv array where the first element is the executable and subsequent elements are arguments. You cannot use command_line in this mode.
Arguments
When calling runProcess, you can pass the following keys in the arguments object:
command_line (string): The full shell command to execute.argv (string[]): An array of strings representing the command and its arguments.cwd (string): The working directory where the command should run.stdin_text (string): Text to write to the process's standard input (STDIN).timeout_ms (number): Maximum execution time in milliseconds. Defaults to 30000 (30 seconds).
Constraints
- You must provide either
command_line or argv. Providing both or neither will result in an error. - If
stdin_text is provided, the tool pipes it to the process and then closes the STDIN stream.
// Example: Shell Mode
await runProcess({
command_line: "ls -la /tmp",
cwd: "/home/user"
});
// Example: Executable Mode
await runProcess({
argv: ["grep", "search_term", "file.txt"],
timeout_ms: 5000
});
// Example: Providing STDIN
await runProcess({
argv: ["cat"],
stdin_text: "Hello from STDIN"
});