Skip to content

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

Closed as not planned

Description

@easyshot

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

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

Activity

  1. added
    bug
    CLI
    mcp-server
    sandbox
    tool-calls
    on Apr 17, 2026
  2. removed
    CLI
    on Apr 17, 2026
  3. SylvainWinning commented on May 25, 2026

    @SylvainWinning

    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.

  4. etraut-openai commented on Aug 26, 2026

    @etraut-openai
    Contributor

    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.

  5. fmilz commented on Aug 26, 2026

    @fmilz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmcp-serversandboxtool-calls

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions