macOS: Shell execution silently fails in workspace-write and read-only sandboxes via mcp-server; danger-full-access works

Resolved 💬 4 comments Opened Apr 17, 2026 by easyshot Closed Aug 26, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

macOS: Shell execution silently fails in workspace-write and read-only sandboxes when launched via mcp-server; danger-full-access works

Summary

When running codex mcp-server (stdio) on macOS and calling the codex tool with sandbox: workspace-write or sandbox: read-only, shell command execution is blocked at sandbox setup before any exec_command_begin event is emitted. The model reasons, produces plans, and acknowledges the failure ("The failure is happening before command execution, at sandbox setup itself"), but never actually runs the command. The same session with sandbox: danger-full-access works correctly.

This makes Codex unusable as an MCP server for any code task on macOS unless the caller opts into danger-full-access, which defeats the purpose of sandboxing.

Environment

  • macOS 26.4.0 (arm64, Apple Silicon)
  • Codex CLI: codex-cli 0.99.0-alpha.5
  • Binary: /Applications/Codex.app/Contents/Resources/codex
  • Model: gpt-5.4
  • Transport: stdio (codex mcp-server)
  • Client: custom stdio JSON-RPC client (issue also reproduces from Kiro CLI + AIM agent setup)

Reproduction

Send this sequence to codex mcp-server via stdio:

{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}
{"jsonrpc":"2.0","method":"notifications/initialized","params":{}}
{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"codex","arguments":{"prompt":"Run: ls -la in the current directory. Just do it. Report what you see.","cwd":"/tmp","sandbox":"workspace-write","approval-policy":"never"}}}

Expected

  • exec_command_begin event with ["/bin/zsh","-lc","ls -la"]
  • exec_command_end with stdout + exit_code 0
  • Agent message reporting the directory contents

Actual

  • No exec_command_begin is ever emitted
  • The model produces 4 sequential agent_message events attempting workarounds:
  1. "I'm going to load the required workspace context first, then I'll run ls -la..."
  2. "The shell tool is being blocked by the local sandbox wrapper, so I'm trying a narrower invocation..."
  3. "I can't get a sandboxed shell at all. I'm testing whether the tool will allow a direct non-sandboxed ls -la..."
  4. "The failure is happening before command execution, at sandbox setup itself. I'm checking whether it's specific to this workspace or a broader shell outage."
  • Model falls back to list_mcp_resources and list_mcp_resource_templates (both empty), eventually gives up or resorts to web search

Control: danger-full-access works correctly

Identical request with "sandbox":"danger-full-access":

CMD: ['/bin/zsh', '-lc', 'ls /tmp']
  STDOUT: Kiro-45ddc189-fc1f-46ce-96d5-ebfb5530d2d1.sock
MacSpoolerService
a62ed1c1-e1a9-5495-9038-16bd49ec7341
...
  EXIT: 0

→ exec_command_begin + exec_command_end fire normally, stdout is captured, agent reports results.

Session configuration echoed by server

{
  "type": "session_configured",
  "session_id": "019d98dd-df2c-7421-b2cf-52ecb2711d25",
  "model": "gpt-5.4",
  "model_provider_id": "openai",
  "approval_policy": "never",
  "sandbox_policy": {
    "type": "workspace-write",
    "network_access": false,
    "exclude_tmpdir_env_var": false,
    "exclude_slash_tmp": false
  },
  "cwd": "/Users/asulgrov/.openclaw/workspace/claudia-cockpit"
}

Sandbox policy is parsed correctly and set to workspace-write, but shell execution still fails.

Impact

  • Renders Codex unusable as an MCP-driven subagent for autonomous code tasks on macOS (the primary use case for the MCP surface) unless callers grant danger-full-access.
  • In my setup (Kiro CLI + AIM agent package registering Codex as a subagent), every code-analysis task fails this way — Codex cannot rg, ls, or cat to inspect the workspace it was given.
  • Silent failure: no error is returned to the MCP client. The model just gives up after several reasoning cycles. Clients that don't inspect reasoning traces see only an unresponsive agent.

Suggested fixes

  1. Emit an explicit error event (e.g., exec_command_error with a clear sandbox-setup message) when seatbelt/landlock setup fails, so MCP clients can surface the problem.
  2. Verify that workspace-write + approval-policy: never correctly wraps shell commands via Seatbelt on macOS in mcp-server mode (parity with codex exec / interactive CLI, where the same sandbox modes work fine).

Related

  • #13987 ([Windows] read-only sandbox mode causes MCP shell_command to stall indefinitely — same category of issue, different platform)
  • #14115 (codex exec on macOS initializes external MCP and lists tools but never sends tools/call — related macOS + MCP stall pattern)

Happy to provide full JSONL event logs (~2500 lines per run) if useful.

View original on GitHub ↗

4 Comments

github-actions[bot] contributor · 4 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #16619
  • #16908
  • #17112

Powered by Codex Action

SylvainWinning · 3 months ago

I took another pass through this thread and the current repo behavior, and this still looks like a useful place to separate two failure modes that currently appear identical to MCP clients.

The key diagnostic signal in the report is that no exec_command_begin event is emitted for workspace-write / read-only, while the same request works under danger-full-access. That suggests the useful first split is not “did the command fail?”, but “did Codex fail before creating the command execution item?”. If sandbox setup fails before the exec item exists, MCP clients currently only see an agent that reasons around the problem and eventually gives up.

A narrow maintainer-friendly check might be:

  1. Run the same ls -la request through codex exec and through codex mcp-server on macOS with workspace-write + approval-policy: never.
  2. Assert that both paths either emit an exec_command_begin/exec_command_end pair, or both return an explicit sandbox setup error.
  3. Add a negative-path event or tool result for Seatbelt setup failure before command launch, so MCP clients can surface a concrete error instead of a silent stall.

The MVP here does not need to change sandbox policy or relax safety. It could simply make the failure observable and verify parity between CLI/exec and MCP-server launch paths.

Per docs/contributing.md, I’m sharing analysis rather than opening an unsolicited PR, but I’d be happy to help narrow this into a focused repro or test case if maintainers want that direction.

etraut-openai contributor · 2 days ago

Note: We've announced that the mcp-server is deprecated and will be removed in a future release. We recommend using the app server interface instead. We won't be prioritizing any bug fixes in the mcp-server, so I'm going to close this issue.

fmilz · 2 days ago

But it's their rp, they should fix it

On Wed, 26 Aug 2026, 12:57 Eric Traut, @.***> wrote:

etraut-openai left a comment (openai/codex#18243) <https://github.com/openai/codex/issues/18243#issuecomment-5421992008> Note: We've announced that the mcp-server is deprecated and will be removed in a future release. We recommend using the app server interface instead. We won't be prioritizing any bug fixes in the mcp-server, so I'm going to close this issue. — Reply to this email directly, view it on GitHub <https://github.com/openai/codex/issues/18243?email_source=notifications&email_token=CMRTITEWKMNY4TNVTM6CMET5L2GLNA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKNBSGE4TSMRQGA4KM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#issuecomment-5421992008>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/CMRTITCLJH5QPIGT5ZYPAET5L2GLNAVCNFSNUABFKJSXA33TNF2G64TZHM4TMNJUGE2TMNBZHNEXG43VMU5TIMRXHEZTMNBQGIZ2C5QC> . Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS <https://github.com/notifications/mobile/ios/CMRTITBY5YAQCUWYKSMVH535L2GLNA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKNBSGE4TSMRQGA4KM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSVGM33PORSXEX3JN5ZQ> and Android <https://github.com/notifications/mobile/android/CMRTITHSOLVDLZZPLQAJPDT5L2GLNA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKNBSGE4TSMRQGA4KM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSXGM33PORSXEX3BNZSHE33JMQ>. Download it today! You are receiving this because you are subscribed to this thread.Message ID: @.> This email was forwarded via AliasFleet Note: kok Original sender: Eric Traut @.>