Run a command in a session
terminal_execExecute commands in an existing persistent shell session, wait for completion, and return output plus exit code. Use it for multi-step work while preserving working directory and environment.
Instructions
Type a command into an existing session, wait for it to finish and return its output and exit code. The session keeps its working directory and environment, so use this for multi-step work. Waits up to 2 minutes by default. Set waitForCompletion to false for interactive programs or long-running servers.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"id": "<id>",
"command": "<command>"
},
"name": "terminal_exec"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Session id (for example "term_1a2b3c4d") or the friendly name given at spawn time. | |
| raw | No | Return raw output with ANSI escapes. Default false. | |
| idleMs | No | Consider the command finished after this many ms without new output. Default 400. | |
| command | Yes | Command line to execute in the session shell. | |
| timeoutMs | No | Maximum time to wait in milliseconds. Default 120000 for terminal_exec, 15000 for terminal_write, 30000 for terminal_run. | |
| waitForCompletion | No | Wait for the command to finish and report its exit code. Default true. Set false for REPLs, prompts or servers that keep running. |