---
title: "corestack_exec_command"
url: https://docs.corefinity.com/mcp/tools/corestack_exec_command
type: tool
last_updated: 2026-11-13
feature: commands
related:
  - https://docs.corefinity.com/mcp/long-running-tasks.md
---
# corestack_exec_command

**Run a command.** Run a shell command in the environment as the site user (web), with the same login shell as the browser terminal: php, composer, wp (WordPress), bin/magento, mariadb, rsync, git, node. It runs beside the control panel's own work and is never blocked by it. The call waits up to wait_seconds and then answers a task that keeps running for up to timeout_seconds. A process the command leaves in the background keeps running after it ends; one that clears its environment and leaves its process group cannot be stopped from here (use SSH or the terminal). Scope: exec. Long-running: answers with a task.

- Scope: `exec`
- Runs as a task: yes

## When to use it

Run a shell command in the environment as the site user (web), with the same login shell as the browser terminal: php, composer, wp (WordPress), bin/magento, mariadb, rsync, git, node. It runs beside the Control Panel's own work and is never blocked by it. The call waits up to wait_seconds and then answers a task that keeps running for up to timeout_seconds. A process the command leaves in the background keeps running after it ends; one that clears its environment and leaves its process group cannot be stopped from here (use SSH or the terminal).

## Inputs

- `site_id` (integer, ≥ 1, required)
- `command` (string, 1–262144 characters, required): The shell script to run (bash). It is uploaded as a file, never put on a command line.
- `wait_seconds` (integer, 0–60, default `30`): How long the call waits before it answers a task. 0 answers a task at once.
- `timeout_seconds` (integer, 1–86400, default `3600`)
- `cwd` (string, up to 1024 characters): Relative to the site root, or absolute under it. Default htdocs.
- `env` (object): Environment variables for the command: NAME => value.

### Input schema

```json
{
  "additionalProperties": false,
  "properties": {
    "command": {
      "description": "The shell script to run (bash). It is uploaded as a file, never put on a command line.",
      "maxLength": 262144,
      "minLength": 1,
      "type": "string"
    },
    "cwd": {
      "description": "Relative to the site root, or absolute under it. Default htdocs.",
      "maxLength": 1024,
      "type": "string"
    },
    "env": {
      "description": "Environment variables for the command: NAME => value.",
      "type": "object"
    },
    "site_id": {
      "minimum": 1,
      "type": "integer"
    },
    "timeout_seconds": {
      "default": 3600,
      "maximum": 86400,
      "minimum": 1,
      "type": "integer"
    },
    "wait_seconds": {
      "default": 30,
      "description": "How long the call waits before it answers a task. 0 answers a task at once.",
      "maximum": 60,
      "minimum": 0,
      "type": "integer"
    }
  },
  "required": [
    "site_id",
    "command"
  ],
  "type": "object"
}
```

## Refusals

- `command_failed`: an MCP command exited non-zero — any non-zero exit of a payload that was started, 125 included — ran out of time, ended without a status, or lost its container; status and exit code in `details`; read the output (`corestack_command_output_get`).
- `launch_interrupted`: an MCP command never started: its launch stopped before anything was claimed or ran, or — `launch_failed` — its start gate never released the payload: `run.sh` recorded `unlaunched` or a reconciler took the release token first — nothing ran; call again.
- `launch_failed`: an MCP command never started: its launch stopped before anything was claimed or ran, or — `launch_failed` — its start gate never released the payload: `run.sh` recorded `unlaunched` or a reconciler took the release token first — nothing ran; call again.
- `cancelled`: the command or transfer was stopped — by `tasks/cancel` / `corestack_command_cancel` / the Control Panel's Stop, or because its grant ended; reported only once the run is proven stopped; nothing to do; a revoked grant cannot read it anyway.
- `timed_out`: an MCP command exited non-zero — any non-zero exit of a payload that was started, 125 included — ran out of time, ended without a status, or lost its container; status and exit code in `details`; read the output (`corestack_command_output_get`).
- `managed_elsewhere` (message: "This site is managed by another control panel"): another control panel manages this site, so use that control panel for it. This is refused before anything else about the site, as in the Control Panel and the API. Nothing was done.
- The refusals every tool can answer: `invalid_arguments`, `tenant_mismatch`, `scope_required`, `pin_refused`, `rate_limited`, `temporarily_unavailable`, `internal_error` (corestack://guides/how-this-server-works).

## Example

```json
{
  "name": "corestack_exec_command",
  "arguments": {
    "site_id": 4211,
    "command": "php -v"
  }
}
```

## Prompt

```text
Using the Corefinity MCP server, call corestack_exec_command with site_id 4211, command php -v. (Run a command.) Tell me what it returned.
```

## The same task elsewhere

- Guide: [Long-running tasks](https://docs.corefinity.com/mcp/long-running-tasks.md)
