Skip to content

Codex config.toml completely overwritten: custom MCP and UI settings lost (cc-switch)

Quick fix

Most related issues remain unresolved. Put custom sections in cc-switch’s common configuration or provider template, then upgrade to the latest version. (MCP)

Error output
cc-switch 完整重启后,Codex 的 config.toml 被全量覆盖,用户自定义的 MCP 和 UI 设置丢失
English translation

After a full cc-switch restart, Codex config.toml is completely overwritten, and the user’s custom MCP and UI settings are lost.

When cc-switch’s Codex local proxy takeover (local routing) is enabled, it saves a snapshot of the entire ~/.codex/config.toml to the database’s proxy_live_backup table, then rebuilds config.toml by fully replacing it with the stored provider template rather than merging changes. Sections absent from the template—[mcp_servers.*], [desktop], [features], [memories], [windows], [projects], permissions settings, and manually added [model_providers.*] aliases—are lost whenever providers are switched, cc-switch restarts, or takeover is restored after an unexpected exit. On exit, the old snapshot is written back unchanged, causing deleted MCP servers to reappear and be imported again.

There are related variants. In some versions, a restart overwrites auth.json with experimental_bearer_token="PROXY_MANAGED", breaking official OAuth sign-in. Maintainers said targeted fixes began in v3.16.1/v3.16.3; upgrade to v3.16.4+ and enable “Preserve Codex Official Authentication”. When local routing is enabled, official providers are hard-coded to the cc-switch-official bucket, while third-party sessions are in the custom bucket and cannot see each other. Codex CLI and Desktop share ~/.codex/config.toml, so CLI takeover also affects Desktop. Reports conflict on whether “Application Common Configuration” works: some users preserved settings with it, but #6017 reported that common configuration fragments were not merged during recovery after an unexpected exit.

  1. Upgrade cc-switch to the latest version. The maintainer confirmed in #3423 that v3.16.1 fixed Codex OAuth authentication during proxy takeover, and v3.16.3 fixed takeover residue recovery across configuration directories and OAuth token preservation. Use at least v3.16.4, enable “Preserve Codex Official Authentication”, then restart and verify sign-in and plugins.

  2. Put custom sections that must persist—MCP servers, [windows], [projects], [desktop], [memories], permissions, and others—into cc-switch’s “Application Common Configuration” (CLI: cc-switch -a codex config common) or the provider template. They can then be merged or projected back when config.toml is rewritten. Note: #6017 reports that common configuration may not be merged during recovery after an unexpected exit; back up important settings yourself.

    ~/.codex/config.toml 中会被覆盖、应迁移到「应用通用配置」的段落示例
    [windows]
    sandbox = "elevated"
    [projects."/path/to/your/repo"]
    trust_level = "trusted"
  3. Temporary workaround from #4368: directly edit ~/.cc-switch/cc-switch.db, append missing TOML sections to the original_config field in proxy_live_backup, and they will remain when settings are restored on exit. The drawback is that the database must be edited after every settings change.

  4. If a deleted MCP server reappears after restart, deleting only the mcp_servers table and config.toml is insufficient. Also remove old MCP definitions from the proxy_live_backup snapshot and providers.settings_config (#4012, #6377), or restart and “Import Existing MCP” will write them back.

  5. If proxy configuration remains after disabling or uninstalling cc-switch and Codex cannot connect directly (#1422, #1423), add an official provider in cc-switch and switch to it. If that fails, delete the ~/.codex directory and reopen Codex so it initializes config.toml again.

  6. For plugin or session loss reports (#3423), one user reported that plugins did not disappear after restart when installed with routing disabled. Sync working settings into common configuration, including after switching providers.

ToolCodex(CLI 与 Desktop,二者共用 ~/.codex/config.toml)
Version报告覆盖 3.11.1 - 5.10.1(v3.16.1/v3.16.3 起部分修复 auth.json 覆盖问题,config.toml 全量覆盖问题在 3.19.2 及更新版本中仍有报告)
PlatformsWindowsmacOS

This page is distilled from 15 real issues

I deleted an MCP server in cc-switch. Why did it return after I restarted my computer?
The deletion only cleared the mcp_servers table and config.toml; the full pre-takeover snapshot in proxy_live_backup still contains the servers. The snapshot is written back unchanged on exit or restart, and “Import Existing MCP” stores them again. Also remove remaining definitions from proxy_live_backup and providers.settings_config.
After disabling or even uninstalling cc-switch, Codex still uses a proxy and my free account does not work. What should I do?
The proxy configuration written during takeover remains in ~/.codex/config.toml. Add an official provider in cc-switch and switch to it so it restores direct-connection configuration. If it is already uninstalled, delete the ~/.codex directory and reopen Codex so it initializes config.toml.
Why are Codex Desktop requests also intercepted when I configured a proxy only for Codex CLI?
Codex Desktop and Codex CLI share ~/.codex/config.toml by default. After cc-switch rewrites this file, both clients use the local proxy route.
After restart, official Codex OAuth sign-in fails and all plugins appear uninstalled. How do I fix it?
This happens when auth.json is overwritten with the PROXY_MANAGED placeholder token. The maintainer confirmed targeted fixes from v3.16.1/v3.16.3; upgrade to the latest version and enable “Preserve Codex Official Authentication”. Install plugins with routing disabled.
After switching providers, Codex Desktop’s session history list is empty. Is the data lost?
In most cases, session files remain on disk (the jsonl files under ~/.codex/sessions are not deleted). This is a session-bucketing or index-display issue. With local routing enabled, official sessions are stored in the cc-switch-official bucket and are invisible to the third-party custom bucket. Try enabling “Unified Codex Session History”.

This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.