run_safe_command
Run shell commands safely in project directories, blocking dangerous operations and disallowed paths. Use for tests, builds, and typechecks.
Instructions
Executes a safe command inside the project folder. This is the default command execution tool — use it whenever you are not sure whether a command is dangerous. Commands outside the project or that look dangerous are rejected automatically. If the tool returns isError:true with a rejection message (dangerous or directory_escape), DO NOT try to bypass it by rewriting the command or immediately switching to run_destructive_command without asking the user first. For dangerous operations use run_destructive_command with confirm:true. NOTE: 60s limit (optionally extend via timeoutMs) — not suitable for dev servers / watch mode. Run test suites (jest/npm test), typecheck and builds through this tool or run_command_grep, NOT through the built-in terminal. If the task targets a project other than the primary one (MCP_PROJECT_ROOT), always pass the "cwd" parameter. Get the list of allowed roots via the "list_allowed_roots" tool.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | The directory in which the command will be run (must be inside MCP_PROJECT_ROOT / MCP_EXTRA_ROOTS). Default: the primary project (MCP_PROJECT_ROOT). | |
| command | Yes | The command to execute (runs in the directory given by the cwd parameter) | |
| maxLines | No | Maximum number of output lines (default: 200) | |
| timeoutMs | No | Timeout in milliseconds (1,000 – 600,000, default 60,000). You can extend it for longer tests/builds, e.g. 180,000 for jest. |