How to load project config and MCP servers in codex exec with --trust
Starting with Codex CLI 0.169.0, codex exec keeps project configuration and MCP servers disabled in untrusted directories, even with --sandbox workspace-write. If a codex exec call in a script or CI lost your project's .codex/config.toml or its MCP tools after updating, this is why.
For a repository you trust, add --trust to save trust for that project explicitly. codex review takes the same option.
npm install -g @openai/codex@0.169.0
codex exec --trust "run the tests and fix the failures"
Instead of the flag, you can list the project path in your user config ahead of time. The value is "trusted" or "untrusted".
# ~/.codex/config.toml
[projects."/path/to/project"]
trust_level = "trusted"
In an untrusted project Codex skips the project-scoped .codex/ layers (project config, hooks and rules) and reads only user and system config. Trusting it loads all of those, so don't pass --trust on someone else's pull request or a repository you just cloned.
Sources
Get notified when a new tip lands
Tip alerts only go out in the app. Install it and turn notifications on.