codex exec ignores project config and MCP servers: --trust fix

Server rack with amber status LEDs in a dim data center aisle

Last verified: 2026-11-15 · version 0.169.0

Quick Answer

Codex 0.169.0 stopped treating --sandbox workspace-write as trust. codex exec now skips a repo's .codex/config.toml and its MCP servers in any directory you have not trusted. Fix it with --trust, or pre-seed [projects."<repo>"] trust_level = "trusted" in ~/.codex/config.toml.

A pipeline that ran green on Friday ran green again on Monday, except the agent had no tools. The logs were clean, the exit code was 0, and the MCP server the job depends on was never started.

That is not a bug in your config. Codex CLI 0.169.0 (published 2026-11-13) changed which configuration a non-interactive run is allowed to read. The release notes say it plainly: “codex exec keeps project configuration and MCP servers disabled in untrusted directories, even with --sandbox workspace-write. Use --trust with codex exec or codex review to explicitly save project trust. (#60041)”

The strings you will actually see

Four failures come out of one change, and they mean four different things. Match your line first.

Output on stderr What it means
warning: Untrusted project-local configuration is disabled. Run codex exec --trust to allow… The repo has a .codex/ layer and it was skipped. The run continues and exits 0.
required MCP servers failed to initialize: name A server marked required = true could not start. Exit code 1.
/path/to/repo is marked as untrusted. Update its trust setting first. --trust was refused because the project is explicitly untrusted.
--trust cannot be combined with --ignore-user-config Two flags fought. The run stops before it starts.

The first row is the expensive one. Nothing is red, so nothing gets fixed, and the agent quietly answers with the tools it happens to have.

Sandbox permission and project trust are two gates

A writable sandbox says what the agent may do to the workspace. Trust says whether the repository's config, hooks, and MCP startup commands load at all. Until 0.169.0 a writable sandbox was enough to pull the project layer in; pull request #60041 closed that, and added the flag that reopens it deliberately.

Keycard reader beside a steel server room door with a red access denied light

Fix 1: pass --trust where you own the repo

codex exec --trust --sandbox workspace-write "run the test suite and report failures"

The flag does exactly three things, and the difference matters in CI. If the project already has a saved decision of trusted, it writes nothing. If there is no decision yet, it writes one into your user config as the run starts. If the project is explicitly untrusted, it refuses and exits instead of overriding the refusal.

The same flag exists on codex review. The grant is persistent, not per-run: it survives --ephemeral, so a one-off command leaves a lasting trust entry behind. It also cannot ride along with --ignore-user-config, because that flag hides the very file where the decision is stored.

Fix 2: pre-seed trust on a throwaway runner

On an ephemeral runner the entry dies with the machine. If you would rather not grow the command, write it yourself first (use $CODEX_HOME/config.toml if you set that variable):

mkdir -p ~/.codex
printf '[projects."%s"]\ntrust_level = "trusted"\n' "$PWD" >> ~/.codex/config.toml

Two traps hide in those three lines. First, the key is matched as a path, not a prefix: Codex looks up your working directory first, then the resolved git repository root, and a key that matches neither is simply ignored. Second, there is no wildcard and no recursive parent entry, so a single trusted folder does not cover the repos beneath it. One entry per repository is still the only supported shape. Run the snippet from the repository root, or use the output of git rev-parse --show-toplevel as the key.

Fix 3: make a missing server fail the build

Trust the check, not the flag. Mark the servers the job cannot live without:

[mcp_servers.playwright]
command = "npx"
args = ["-y", "@playwright/mcp"]
required = true

A required server that fails to initialize ends the run with exit code 1 and the message in the table above. The catch is placement: that guard only works if the config carrying it actually loads. Put it in a project file that is still untrusted and you have written a guard that guards nothing. Keep the required server in your user-level config if it must fire on every machine, or grant trust first and then test it.

Where not to use this

Fork pull requests, third-party repos, and anything you have not read: leave trust off. The change exists because a writable sandbox was letting an unreviewed repository start MCP commands outside its own sandbox. Keep the refusal, and let the run lose the tools.

If the job dies before it reaches any of this, check the checkout first. codex exec outside a git repository stops with Not inside a trusted directory and --skip-git-repo-check was not specified. and exit code 1, which is a different problem with a different flag.

Verify it in four lines

codex --version                                   # expect 0.169.0 or later
git rev-parse --show-toplevel                     # the exact path your trust key needs
grep -A1 '^\[projects' ~/.codex/config.toml       # trust_level = "trusted" on the right path
codex exec --trust "list your MCP tools" 2>&1 | tail -5

Warning gone and tools present: the project layer is loading. Warning gone and tools still missing: the failure is upstream of trust, in the server's own command, and required = true is how you make it shout. The same silent tool loss happens in an editor — Cursor AI not reading your local codebase came down to exactly which layer was skipped.

Keep going
Verified 2026-11-15 against the 0.169.0 release notes, pull request #60041, the codex-rs source at tag rust-v0.169.0 (exec/src/cli.rs, exec/src/lib.rs), and the repo's own exec tests. Not reproduced on a signed-in account.

Start with these

Comments

Popular posts from this blog

v0 vs Bolt.new vs Lovable: Which AI App Builder Should You Pay For? (2026)

How to Stop ChatGPT from Sounding Like AI: 3 Negative Constraints

Zapier vs Make vs n8n: Enterprise AI Automation Benchmark & TCO Breakdown (2026)