Delegate task to Codex CLI
delegate_to_codexExecute a coding task using Codex CLI non-interactively and receive the final output. Use when you need to assign a programming task to a sub-agent.
Instructions
Runs OpenAI's Codex CLI non-interactively (codex exec) to execute a coding task and returns its final message.
Args:
prompt (string, required): task instructions for Codex
cwd (string, optional): absolute working directory for the task
model (string, optional): model override (e.g. "gpt-5.6-luna")
timeout_seconds (number, optional, default 600): kill the process after this many seconds
auto_approve (boolean, optional, default false): bypass Codex's shell/edit approval prompts. Without this, tasks that need to run a command or edit a file will fail immediately since there is no terminal to approve from.
Returns structured JSON: { success, final_message, exit_code, timed_out, stderr? }.
Error Handling:
success=false with a non-zero exit_code and stderr populated means Codex reported an error (e.g. auth, invalid model, sandbox denial)
timed_out=true means the task exceeded timeout_seconds and was killed
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | Absolute path to the working directory the sub-agent should operate in. Defaults to this MCP server's own working directory if omitted. | |
| model | No | Model override for this run (e.g. 'gpt-5.6-luna', 'claude-opus-4-8'). Omit to use the CLI's own configured default. | |
| prompt | Yes | Task instructions for the sub-agent to execute, exactly as it should receive them. | |
| auto_approve | No | Bypass the sub-agent's interactive tool-permission prompts (shell commands, file edits, etc). This call has no terminal attached, so without auto_approve most non-trivial tasks will fail immediately the first time the sub-agent needs to use a tool. Set true when you trust the task to run unattended. | |
| timeout_seconds | No | How long to wait for the sub-agent to finish, in seconds (10-1800, default 600). The process is killed if it runs longer. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stderr | No | Captured stderr, included only when the run was not successful. | |
| success | Yes | True if the sub-agent process exited with code 0 and did not time out. | |
| exit_code | Yes | Process exit code, or null if the process could not be spawned. | |
| timed_out | Yes | True if the process was killed after exceeding timeout_seconds. | |
| final_message | Yes | The sub-agent's final response text. |