Codex CLI config.toml: The Complete Guide to Models, Approvals, MCP and Layered Config
Codex CLI centers on ~/.codex/config.toml: model picks the model, approval_policy gates prompts, sandbox_mode sets boundaries, mcp_servers wires tools, profiles switch scenarios.
How to
Create the file
Create or edit ~/.codex/config.toml; project overrides live in <repo>/.codex/config.toml.
Pick model and behavior
Write model = "gpt-6-astra" and optionally model_reasoning_effort and model_verbosity.
Set the safety boundary
Write sandbox_mode = "workspace-write" and approval_policy = "on-request" (use "never" for unattended runs).
Wire MCP (optional)
Add a [mcp_servers.<name>] table with command/args or url — see our MCP config guide for the full field list.
Codex CLI's behavior centers on ~/.codex/config.toml — one TOML file deciding which model it runs, what files it may touch, which tools it can call, and when it stops to ask. This guide maps the keys as defined by the ConfigToml struct in the codex-rs source rather than folklore.
1. File locations and layering
- User level:
~/.codex/config.toml— global defaults - Project level:
.codex/config.tomlat the repo root — overrides same-named keys - Admin level:
requirements.toml— managed/mandatory constraints (e.g.allow_managed_hooks_only = truemakes user and project hook configs inert, keeping only managed hooks)
The layering means: personal preferences go user-level, project rules go project-level (and into git), enterprise policy goes into requirements.toml.
2. Model and reasoning keys
model = "gpt-6-astra"
model_provider = "openai"
model_reasoning_effort = "high"
model_verbosity = "medium"
model— the model namemodel_provider— a key into the[model_providers]table, which can register custom providers for alternate channelsmodel_reasoning_effort— reasoning depthmodel_reasoning_summary/model_verbosity— reasoning summary style and output verbositymodel_context_window/model_auto_compact_token_limit— context window and auto-compaction thresholds (rarely needed)
3. The two safety axes
sandbox_mode = "workspace-write"
approval_policy = "on-request"
sandbox_mode governs filesystem and network boundaries (read-only / workspace-write / external-sandbox / danger-full-access); approval_policy governs when the agent asks (on-request / on-failure / granular / never). See our sandbox guide for the full semantics — the point here is they are independent and combine; there is no single master switch.
4. MCP and profiles
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
[profiles.ci]
model = "gpt-6-astra"
approval_policy = "never"
sandbox_mode = "workspace-write"
[mcp_servers.<name>]— declares an MCP server (full field list in our MCP guide)[profiles.<name>]— named config bundles for scenarios; select withprofile = "ci"or--profile
Profiles are the most underused mechanism in config.toml — packaging "write code", "CI batch", "read-only review" into three profiles beats editing the file every time.
5. Common mistakes
- Writing requirements.toml keys into config.toml:
allow_managed_hooks_onlyonly works in the admin layer — misplaced, it silently does nothing - Defining profiles but never selecting them: a
[profiles.ci]block without--profile ciis dead config - Plaintext secrets on disk: prefer the
*_env_varforms for API keys — project-level files are committed to git - Treating model_provider as a URL: it is a provider key; custom channels must be registered in
[model_providers]first
6. Next steps
Key points
- Main file: ~/.codex/config.toml; project-level .codex/config.toml overrides same-named keys
- model / model_provider pick model and provider; model_reasoning_effort and model_verbosity tune depth and length
- approval_policy + sandbox_mode are the two independent safety axes
- [mcp_servers.<name>] declares MCP servers; [profiles.<name>] defines named config profiles
- requirements.toml is the admin layer: allow_managed_hooks_only = true accepts managed hooks only
Frequently asked questions
Official references
Related articles
Codex Cloud Setup: Environments, Cloud Tasks, and the codex cloud CLI
Codex Cloud (called Codex Web in the source) is the hosted Codex surface: tasks run in cloud environments organized per GitHub repo, and the codex cloud CLI submits, tracks, and pulls diffs back to your machine.
Read articleCodex CLI Sandbox Modes: sandbox_mode and approval_policy Explained
Codex CLI sandbox has four levels — read-only, workspace-write, external-sandbox, danger-full-access — plus a separate approval_policy axis. Every value checked against the codex source enums.
Read articleCodex CLI 0.155, Explained: Experimental /voice, Touch ID for MCP Requests, and the 0.155.1 Revert
Codex CLI 0.155.0/0.155.1 back to back: experimental /voice behind /experimental, streaming reasoning summaries, Touch ID for MCP requests, daemon update schedules, Bedrock credentials — plus the 0.155.1 reasoning-summary revert.
Read articleSubscribe to GPTMap Weekly
One email every Monday: curated OpenAI updates, deep dives, and best practices. No ads, unsubscribe anytime.
Submitting opens Buttondown in a new tab to confirm your subscription.