Codex CLI config.toml Deep Dive: Profiles, MCP Servers and Reasoning Effort
As of 2026-11-25, Codex configuration comes in layers: the user file ~/.codex/config.toml, optional profile files ~/.codex/<name>.config.toml, a project .codex/config.toml that loads only in trusted projects, and -c key=value overrides plus dedicated flags on the command line. The change that breaks most older tutorials: since 0.134.0, [profiles.<name>] tables and the top-level profile = "..." selector are no longer supported. Each profile is now its own file, chosen with --profile <name>. This guide covers profiles, model_providers, mcp_servers, the reasoning-effort keys and how config.toml divides work with AGENTS.md, with a complete example for QCode's Responses endpoint.
QCode is an independent third-party API service and is not affiliated with OpenAI. Config keys below were checked against OpenAI's Codex docs (Advanced Configuration, Sample Configuration, MCP and AGENTS.md pages) on 2026-11-25. Sources: OpenAI Codex docs (Advanced Configuration, Sample Configuration, Model Context Protocol, Custom instructions with AGENTS.md), the Codex changelog and QCode's Codex docs, all read 2026-11-25.
Updated 2026-11-26
Key facts
CODEX_HOMEsets the config directory (default~/.codex); the main file is$CODEX_HOME/config.toml.- Profiles are separate files:
codex --profile deeploads~/.codex/config.toml, then overlays~/.codex/deep.config.toml. Write top-level keys in the profile file; don't nest them under[profiles.deep]. - A project
.codex/config.tomlloads only when the project is trusted. Codex walks from the project root to the current directory, and the file closest to your working directory wins. Keys such asmodel_provider,model_providers,profile,profiles,notifyandotelare ignored in project config with a startup warning. - Custom providers live in
[model_providers.<id>];wire_api = "responses"is the only supported value; choose eitherrequires_openai_auth = trueorenv_key. - MCP servers live in
[mcp_servers.<name>], over stdio (command) or streamable HTTP (url), with a 10-second startup timeout and 60-second tool timeout by default.codex mcp addwrites the entry for you. - AGENTS.md says how to work in this repo; config.toml says which model and permissions Codex runs with. The combined AGENTS.md size is capped by
project_doc_max_bytes, 32 KiB by default.
Config layers and precedence
| Layer | Location | Applies when | Typical content |
|---|---|---|---|
| CLI | -c key=value, --model, --sandbox and other flags |
This invocation only | Temporary overrides |
| Project | .codex/config.toml in the repo (can be nested) |
The project is trusted | Project default model, MCP, sandbox |
| Profile | ~/.codex/<name>.config.toml |
You pass --profile <name> |
A fixed bundle (fast, deep, CI) |
| User | ~/.codex/config.toml |
Always | Providers, auth method, global defaults |
Per the docs, the profile layer sits above your base user config and below project and CLI config, and -c overrides take precedence for that invocation. Admin-managed policies in an organization can restrict settings further, and user config cannot loosen them.
Common traps:
- Project config has no effect. Usually the project isn't trusted. Trust it during onboarding or via
/permissionsin the TUI; forcodex exec,--trustsaves trust. - A provider set in project config is ignored. That's deliberate: a repository shouldn't be able to reroute your requests silently. Provider, notification and telemetry keys belong in user config.
- Relative paths. Relative paths inside a project config resolve against the
.codex/folder.
Base config for QCode
Here is a user-level config you can use as is. It reads the key from ~/.codex/auth.json via requires_openai_auth = true and defines a second provider for the Asia host; asia.qcode.cc and us.qcode.cc use the same paths, and one key works on all of them.
# ~/.codex/config.toml
model_provider = "qcode"
model = "gpt-6.2-sol"
model_reasoning_effort = "high"
model_reasoning_summary = "concise"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
project_doc_max_bytes = 65536
[model_providers.qcode]
name = "qcode"
base_url = "https://api.qcode.cc/openai"
wire_api = "responses"
requires_openai_auth = true
request_max_retries = 4
stream_idle_timeout_ms = 300000
[model_providers.qcode-asia]
name = "qcode-asia"
base_url = "https://asia.qcode.cc/openai"
wire_api = "responses"
requires_openai_auth = true
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
startup_timeout_sec = 20
{
"OPENAI_API_KEY": "cr_your_key"
}
The second block is ~/.codex/auth.json; on macOS and Linux, chmod 600 it. For the full first-time setup see Codex CLI third-party API setup.
model_providers keys you'll actually use
| Key | Purpose | Notes |
|---|---|---|
name |
Display name | Free text |
base_url |
Endpoint | For QCode https://api.qcode.cc/openai, no /v1, no trailing slash |
wire_api |
Protocol | Only "responses" |
requires_openai_auth |
Use OpenAI-style auth (the key in auth.json) | env_key is ignored when set |
env_key |
Read the key from a named environment variable | Good for CI; see codex exec in CI |
http_headers / env_http_headers |
Static headers / headers read from env vars | Maps |
query_params |
Extra query parameters | For example an api-version some clouds need |
request_max_retries |
Request retries | Default 4 |
stream_max_retries |
Stream reconnects | Default 5 |
stream_idle_timeout_ms |
Stream idle timeout | Default 300000 |
Built-in IDs such as openai, ollama, lmstudio, amazon-bedrock and gcp are reserved; pick a unique ID for custom providers.
Profiles: the new format and migration
Since 0.134.0, it's one file per profile. The old form:
# Old form, ignored since 0.134.0
profile = "deep"
[profiles.deep]
model = "gpt-6.2-astra"
The new form is a file per profile in ~/.codex/, with top-level keys:
# ~/.codex/fast.config.toml
model = "gpt-6.2-sol"
model_reasoning_effort = "low"
model_reasoning_summary = "none"
# ~/.codex/deep.config.toml
model = "gpt-6.2-astra"
model_reasoning_effort = "xhigh"
plan_mode_reasoning_effort = "xhigh"
# ~/.codex/asia.config.toml
model_provider = "qcode-asia"
# ~/.codex/review.config.toml
model = "gpt-6.2-sol"
model_reasoning_effort = "medium"
approval_policy = "never"
sandbox_mode = "read-only"
Usage:
codex --profile fast # small edits, questions
codex --profile deep # hard bugs, big refactors
codex --profile asia # try the Asia host (test the provider switch first)
codex exec --profile review "Review the uncommitted changes and list risks"
Migration notes:
- Profile names may contain letters, numbers, hyphens and underscores.
- Leftover
[profiles.x]tables in config.toml are not resolved without--profile, socodex doctorcan report success while the settings are silently ignored. Delete the old tables after migrating. codex doctorandcodex featuresdon't accept--profile.- Profile files use top-level keys. The official example does not show
model_providerin a profile, so if the switch has no effect in your version, pass it on the command line instead:codex -c model_provider="qcode-asia". - For a single temporary change you don't need a profile:
codex -c 'model_reasoning_effort="high"'. Values parse as TOML, so quote them against shell splitting.
Reasoning effort and output keys
| Key | Values | Purpose |
|---|---|---|
model_reasoning_effort |
Per QCode docs, gpt-6.2-sol and gpt-6.2-astra support low, medium, high, xhigh; none is rejected |
Main reasoning effort |
plan_mode_reasoning_effort |
Same; must be a level the model supports | Plan mode only |
model_reasoning_summary |
auto, concise, detailed, none |
How much reasoning summary you see |
model_verbosity |
low, medium, high |
Answer length; Responses API only |
agents.default_subagent_reasoning_effort |
A supported level | Default effort for spawned agents |
Practical defaults:
- Everyday coding:
gpt-6.2-solwithhighbalances quality and speed. - Questions, renames, comments:
lowormediumfor faster answers and fewer output tokens. - Cross-module refactors and nasty bugs:
gpt-6.2-astrawithxhigh. At OpenAI's list prices (2026-11-17), Astra is $8 input / $40 output per million tokens, about 4× Sol ($2 / $10), so keep it in the deep profile. - Subagents: plan with a strong model on the main thread and let subagents run at
mediumto cut the total cost of multi-agent work.
Higher effort usually means more output tokens, reasoning included. QCode currently bills OpenAI models at the official price ×1.0; live prices are on /models.
mcp_servers: giving Codex tools
The quickest route is the CLI, which writes the entry into config.toml:
codex mcp add context7 -- npx -y @upstash/context7-mcp
codex mcp list
Written by hand, stdio and HTTP servers look like this:
# stdio server
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
env_vars = ["LOCAL_TOKEN"] # variables allowed to pass through
startup_timeout_sec = 20 # default 10
tool_timeout_sec = 60 # default 60
# streamable HTTP server
[mcp_servers.docs]
url = "https://mcp.example.com/mcp"
bearer_token_env_var = "DOCS_MCP_TOKEN"
enabled_tools = ["search", "fetch"]
default_tools_approval_mode = "prompt"
required = false
Keys that matter:
enabled = falsekeeps the entry but disables the server; for one run usecodex -c mcp_servers.context7.enabled=false.required = truemakes startup fail if the server can't initialize, which suits tools a CI job depends on.enabled_tools/disabled_toolsare an allow list and a deny list; the deny list applies after the allow list.default_tools_approval_modetakesauto,prompt,writes(prompts for tools not marked read-only) orapprove; override per tool withapproval_modeunder[mcp_servers.<name>.tools.<tool>].- For OAuth servers,
codex mcp login <name>; add--no-browseron a machine without a local browser.
Security note: MCP servers defined in a project .codex/config.toml load only for trusted projects, because they can run commands outside the sandbox. The sandbox's network rules cover commands Codex runs, not an MCP server's own traffic. Read the MCP security and sandboxing guide before adding third-party servers. In the TUI, /mcp shows live connections.
Project config vs AGENTS.md
Both travel with the repo, but they do different jobs:
Project .codex/config.toml |
AGENTS.md |
|
|---|---|---|
| Holds | Runtime settings: model, effort, sandbox, MCP | Build and test commands, conventions, layout notes |
| Loaded when | The project is trusted | Discovered automatically on each run |
| Never put | Restricted keys such as providers, profile, notify, otel | Secrets or personal paths |
How Codex finds AGENTS.md:
- Global: in
$CODEX_HOME,AGENTS.override.mdif present and non-empty, otherwiseAGENTS.md; one file only. - Project: from the project root (usually the Git root) down to the current directory. In each directory it checks
AGENTS.override.md, thenAGENTS.md, then names inproject_doc_fallback_filenames, taking at most one file per directory. - Concatenation: files join from the root downward, so files closer to the current directory come later and override earlier guidance.
- Cap: the total stops at
project_doc_max_bytes(default 32768 bytes); nothing more is added after that.
# Also read the instruction file your team already has
project_doc_fallback_filenames = ["TEAM_GUIDE.md", ".agents.md"]
project_doc_max_bytes = 65536
To see what actually loaded, run codex --ask-for-approval never "Summarize the current instructions." from the repo root, or codex --cd subdir to check that nested overrides win. For writing conventions see the AGENTS.md spec guide.
Troubleshooting checklist
codex doctorprints a diagnostic report (it ignores--profile)./statusin the TUI shows the current model, provider, sandbox and workspace roots.codex login statusexits 0 when credentials are present.- 404
not_found: checkbase_urlfor an extra/v1or trailing slash. - 401: confirm
auth.jsonuses the field nameOPENAI_API_KEYand the provider setsrequires_openai_auth = true. - Startup error mentioning
untrusted:approval_policy = "untrusted"is retired; switch toon-request. See Codex sandbox and approval modes. - Behaviour didn't change after an edit: restart Codex. The AGENTS.md chain rebuilds on every run, but MCP changes need a restart.
FAQ
Can I still define Codex profiles inside config.toml?
No. Since 0.134.0, [profiles.<name>] tables and the top-level profile = "..." selector are unsupported. Each profile is a file ~/.codex/<name>.config.toml, selected with --profile <name>.
Can a profile file define a new provider?
Keep every [model_providers.*] table in the user config.toml and let profile files select one with top-level keys such as model, model_reasoning_effort and model_provider. All profiles then share one set of provider definitions, which is easier to debug. Whether model_provider itself is honored in a profile is not shown in the official example; test it, or pass -c model_provider=... on the command line.
Why is model_provider in my repo's .codex/config.toml ignored?
model_provider and model_providers are restricted keys that project config ignores with a warning, so a repository can't send your requests to an unknown endpoint. Set providers in user config only.
What should model_reasoning_effort be?
high for everyday coding, low or medium for quick questions, xhigh for hard problems. Per QCode's docs, gpt-6.2-sol and gpt-6.2-astra accept low, medium, high and xhigh, and reject none.
How do I turn off one MCP server temporarily?
Set enabled = false in its table, or add -c mcp_servers.<name>.enabled=false for one run. There's no need to delete the entry.
My AGENTS.md is truncated. What now?
The combined cap is 32 KiB by default and content past it isn't loaded. Raise project_doc_max_bytes, or better, split guidance into AGENTS.md files in subdirectories.
What goes in config.toml versus AGENTS.md?
config.toml holds runtime settings (model, effort, sandbox, MCP); AGENTS.md holds working instructions (build and test commands, conventions, layout). Neither should contain secrets.
Recommended plan: Daily 35
If you code with Codex every day and switch between fast and deep profiles, QCode's Daily 35 plan gives you $35 of usage per day (reset at 00:00 Beijing time) for $53.57 per 30 days; OpenAI and Anthropic models are billed at the official price ×1.0. See /pricing for current prices, or pay-as-you-go packs for occasional use.