codex mcp remove missing exited 0. The line it printed was No MCP server named 'missing' found. The same absence, handed to codex mcp get missing, exited 1. That line was Error: No MCP server named 'missing' found. The name was not in the file either time. Only get treated the absence as a failure.
A cleanup job that removes a server and then checks the exit code will treat a name that was never configured the same as a name it just deleted. The text is the field that says which one happened. Exit status on remove does not.
What this binary did
The binary was Codex CLI 0.163.0 on Linux x86_64, on 22 November 2026. codex --version printed codex-cli 0.163.0. Each case used a new CODEX_HOME. The empty homes had no config.toml until a command wrote one. No codex login was run. No session was started. No prompt was sent to a model. The operator Codex home was not one of the homes under test.
The commands were codex mcp add, codex mcp list, codex mcp list --json, codex mcp get, codex mcp get --json, and codex mcp remove. The stdio command was /bin/true or /bin/false. Those binaries exit immediately. They are not MCP servers, and this run did not start them. The point of the command string is the string that landed in the file, not a handshake.
The MCP page, fetched the same night, says codex mcp add takes a name, optional --env pairs, and a stdio command after --. It says codex mcp list shows configured servers. It says a server can also be written by hand under [mcp_servers.<name>] in ~/.codex/config.toml, or in a project .codex/config.toml for a trusted project. It does not say remove exits 0 when the name is absent. It does not say a second add of the same name replaces the table and drops env. It does not say the table redacts a value that --json prints.
Remove is not get
The missing-name remove was the first check, on a home that already held one server named keepme with command /bin/true. The file also held a sibling key, marker = "keep-me", so a rewrite would have been visible.
codex mcp remove missing
Exit 0. Standard output was the one sentence above. The keepme table was still in the file. The sibling key was still there. A job that treats any zero as “the named server is gone” is wrong on this output. The server that was present is the one the command did not name.
Removing the server that was present exited 0 as well, and the sentence was different:
Removed global MCP server 'keepme'.
The table was gone. The sibling key remained. A second codex mcp remove keepme on that same home exited 0 again, and the sentence was back to No MCP server named 'keepme' found. The file did not change. The successful delete and the repeated delete are the same exit. They are not the same sentence.
codex mcp get is the command that already fails this case. On a home that had a different server and no name missing:
codex mcp get missing
Exit 1. Standard output was empty. Standard error was Error: No MCP server named 'missing' found. The word Error: is not decoration. It is the difference between the two commands. Remove prints the absence as a status line and exits 0. Get prints it as an error and exits 1. A script that wants to know whether the name is configured should run get, or should read the file, and should not infer that fact from remove.
The parser still has a real failure exit. codex mcp add both --url https://example.invalid/mcp -- /bin/true exited 2. Standard error said the --url argument cannot be used with a command. No config.toml was created. Exit 2 here is the argument parser. It is not the missing-name case, and it is not a successful remove.
The second add is a replace
A home with no config file was given:
codex mcp add probebin --env PROBE_MARK=alpha -- /bin/true
Exit 0. The sentence was Added global MCP server 'probebin'. The file gained:
[mcp_servers.probebin]
command = "/bin/true"
[mcp_servers.probebin.env]
PROBE_MARK = "alpha"
The same name was then added again, with a different command and no --env:
codex mcp add probebin -- /bin/false
Exit 0. The sentence was the same sentence: Added global MCP server 'probebin'. It did not say replaced, updated, or that an environment table had been dropped. The file after that command was:
[mcp_servers.probebin]
command = "/bin/false"
PROBE_MARK was gone. codex mcp list --json reported env as null and command as /bin/false. A job that adds a server to make sure it exists, and that passes --env only on the first run, will wipe the values on the second run and still exit 0. The success line does not distinguish a first write from a replacement.
That is the opposite of a merge. The second command did not keep the old command and add nothing. It wrote the new command and omitted every env key the new command did not repeat. If the value has to survive a later add, the later add has to pass it again, or the edit has to be made in the file instead of through add.
Sibling keys outside the server table were not the thing that moved. On the home that started with model = "probe-model" and marker = "keep-me", both keys were still present after the first add, after the replacing add, and after remove. This binary does not do what Claude Code 2.1.308 did to a project .mcp.json on 18 November, where a successful project add dropped sibling keys. The Codex loss on this run was inside the named server table, not beside it.
The table hides the value JSON prints
A third home added one server with two env pairs, PROBE_MARK=alpha and OTHER=beta, command /bin/true. codex mcp list exited 0. The env cell was:
OTHER=*****, PROBE_MARK=*****
codex mcp get redactbin exited 0 and printed the same stars: env: OTHER=*****, PROBE_MARK=*****. Neither human command printed alpha or beta.
codex mcp list --json exited 0 and printed both values. The env object was OTHER set to beta and PROBE_MARK set to alpha. codex mcp get redactbin --json exited 0 and printed the same object. The help text for both commands says --json emits the configuration as JSON. It does not say the human form redacts env and the JSON form does not.
The stars are a display choice, not a stored hash. The file held the literal strings. A log that keeps codex mcp list can keep the stars. A log that keeps codex mcp list --json or codex mcp get --json keeps the values that were passed to --env. Those values are whatever the operator put on the command line. On this run they were short markers. On a real server they are often tokens. Do not treat --json as a redacted report because the table next to it is redacted.
The bearer field is a different slot, and this run did not see it leak a value. codex mcp add bearerurl --url https://example.invalid/mcp --bearer-token-env-var PROBE_TOKEN exited 0 and wrote bearer_token_env_var = "PROBE_TOKEN". codex mcp get bearerurl printed that name. The field is the name of a variable, which is what the MCP page says it is. --env is the field that stores the value. The JSON leak is that field, not every credential-shaped key in the table.
The name is case-sensitive
ProbeBin and probebin were two servers. The first add used /bin/true. The second add, with the lowercase name and /bin/false, exited 0 and said it had added probebin. The file held both tables. codex mcp list --json returned two objects. codex mcp remove probebin exited 0, printed Removed global MCP server 'probebin'., and left the ProbeBin table in place with command /bin/true.
A wrapper that lowercases the name before remove will not remove the mixed-case server, and the exit code will not say so if the lowercase name was also present. If only the mixed-case name is present, remove of the lowercase form exits 0 and prints the missing-name sentence. Read the name back from codex mcp list --json and compare it as a string, not as a folded key.
Add writes the global file
The success line says Added global MCP server. That word is the file, not a mood. From a git checkout whose .codex/config.toml already named a server projectbin, codex mcp add fromrepo -- /bin/false exited 0, printed the global sentence, and wrote fromrepo into the CODEX_HOME config. The project file was unchanged.
codex mcp list --json in that checkout, before any trust row existed, printed fromrepo and did not print projectbin. The MCP page says project servers apply to trusted projects only. That omission matches the page. It is not evidence that list never reads a project file.
A second home wrote the trust row by hand:
[projects."<project>"]
trust_level = "trusted"
<project> was the absolute path of that checkout. codex mcp list --json from the checkout then printed projectbin. The same home, still trusted, was then given codex mcp add fromtrusted -- /bin/false from inside the checkout. Exit 0. The sentence still said global. fromtrusted appeared in the home config. The project file was byte-for-byte the file it had been before the add. Trust made list show the project server. It did not make add write one.
There is no --scope flag on codex mcp add in this help text. A project server is a file edit, or a tool that writes that file. It is not a side effect of running add in the checkout. After add, read the home config.toml if the sentence said global. Read .codex/config.toml only if something else was supposed to write it.
This is not the 14 November note on project trust and codex exec. That note is about which binary starts a project MCP command during a headless turn. The commands here did not start a command. They wrote and printed configuration. A trusted row in this run changed what list printed. It did not change where add wrote.
Verification
Point CODEX_HOME at a directory created for the check. Do not point it at a home that already holds tokens. The JSON forms below print env values.
Confirm the binary with codex --version. On 0.163.0 the missing-name split is:
codex mcp remove <absent>
codex mcp get <absent>
Require exit 0 and No MCP server named '<absent>' found. from remove, with no Error: prefix, and require the other servers in the file to be unchanged. Require exit 1 and Error: No MCP server named '<absent>' found. from get. If remove starts exiting 1, the cleanup job that treated 0 as “already absent” has to be read again. If get starts exiting 0, the presence check has moved.
For a name that is present, require Removed global MCP server '<name>'. and require that table to be gone. Run remove a second time and require the missing-name sentence, still with exit 0. Those two exits match. The sentences do not.
For a repeated add, write the server once with --env, read the file, add the same name again without --env, and read the file again. On this binary the second sentence is still Added global MCP server '<name>'., the command is the second command, and the env table is gone. A job that must keep the values has to pass them on every add, or stop calling add once the table exists. codex mcp get <name> before the second add is the presence check. Remove’s exit code is not.
For redaction, compare the three prints of the same server. The table and the human get should show stars in the env cell. codex mcp list --json and codex mcp get --json should be treated as secret-bearing if --env was used, unless a later binary starts redacting those objects too. This run did not install a newer Codex. Do not infer a fix from a version number that was not executed.
For names, compare the JSON name field to the string you intend to remove, including case. ProbeBin and probebin were both enabled after two adds. Removing one left the other.
For scope, if the server has to live in the project file, do not use codex mcp add and then look for it there. On this binary add wrote the home file and said global, including in a checkout whose trust row was trusted. Confirm the project server with list only after that row exists. An empty list in an untrusted checkout is the trust gate, not a statement that the project file has no servers.
The measured boundary is the CLI that edits and prints config.toml. It is not a connected MCP session, not an OAuth login, and not a model turn. auth_status in the JSON was unsupported for the /bin/true rows. That field is not a handshake result. Nothing in this run spoke MCP.
Sources
- Codex CLI 0.163.0,
codex --versionoutputcodex-cli 0.163.0, Linux x86_64, 22 November 2026. IsolatedCODEX_HOMEdirectories. No login, no session, no model turn.codex mcp removeof an absent name exited 0.codex mcp getof an absent name exited 1. A secondcodex mcp addof the same name exited 0, printedAdded global MCP server, replaced the command, and droppedenv. Human list and get redacted env values as*****.list --jsonandget --jsonprinted them.ProbeBinandprobebinwere distinct.codex mcp addwrote the home file, including from a trusted checkout, and left.codex/config.tomlunchanged. - OpenAI Codex MCP page, fetched 22 November 2026: https://developers.openai.com/codex/mcp. It documents
codex mcp add,codex mcp list, hand-written[mcp_servers.<name>]tables, project scope for trusted projects, andbearer_token_env_varas a variable name. It does not document the remove exit, the replacing add, or the JSON env values.