Run a shell command
execRun a shell command on the server and return its output. Pass project_id to run inside that project's workspace folder, with PORT set to the project's routed port; omit it to run at the server workspace root. For one-off work: installing dependencies, building, inspecting files. Runs as the workspace user, the same one the agent and the apps run as, so what it creates stays editable by both; prefix a command with sudo when it needs root. A project command also gets the project's secrets as env. The command's session ends with the call, so do not use it to start an app or any other long-running process: use start_app, which keeps it running, brings it back after a restart, and tells you whether it answered. Output comes back for about 20 seconds: a command that runs longer keeps going on the server, but its output does not return, and the server's other commands wait for it. Start long work (a big install, a long build) in the background with its output in a file, then read the file.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | The shell command to run, e.g. "npm install" or "ls -la". | |
| server_id | Yes | The server's id, as returned by create_server or list_servers. | |
| project_id | No | Optional. Run the command inside this project's workspace folder instead of the server workspace root. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stdout | Yes | What the command printed, stdout and stderr together. |