AI agents on the Mac
OpenAI Codex CLI on a Mac: config, sandbox and secrets
Configure the OpenAI Codex CLI on macOS: config.toml, the sandbox and approval modes, and MCP servers, without leaving API keys in plain text.
Updated 8 October 2026 3 min read
The short answer
Codex CLI reads ~/.codex/config.toml. Keep its sandbox on (workspace-write limits it to the project), keep approvals on request, and add MCP servers under [mcp_servers.<name>]. Don’t put API keys in the env table of that file; it’s plain text.
Install and sign in
npm install -g @openai/codex
codex loginYou can sign in with a ChatGPT account or use an API key.
A safer config.toml
# confine file writes to the current project
sandbox_mode = "workspace-write"
# ask before anything the sandbox does not allow
approval_policy = "on-request"On macOS the sandbox is enforced by the system’s Seatbelt profiles, so it applies to the commands Codex runs, not just to Codex itself. Check codex --help for the modes your version supports.
MCP servers
[mcp_servers.business]
command = "/usr/local/bin/my-mcp-server"
args = []The safe way to do this
MoltenRock Connect
One local MCP server for 30 business platforms
Connect holds every key; your agents read Stripe, Shopify and 28 more over MCP and never see one. On Stripe they can only propose, and you approve with Touch ID.
Get MoltenRock ConnectQuestions developers ask
Where is the Codex CLI config file on Mac?
In ~/.codex/config.toml.
Does Codex CLI run commands in a sandbox on macOS?
Yes, depending on sandbox_mode; on macOS it uses the system’s Seatbelt sandbox.
Can Codex use MCP servers?
Yes. Add them under [mcp_servers.<name>] in config.toml.