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)
Symptom
Section titled “Symptom”cc-switch 完整重启后,Codex 的 config.toml 被全量覆盖,用户自定义的 MCP 和 UI 设置丢失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.
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.
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"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.
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.
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.
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.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 15 real issues
- #1423codex 配置问题
- #1755貌似最新版的cc switch设置了codex CLI 配置代理后会劫持桌面codex版本的请求
- #3423重启电脑后 Codex 插件全部失效,需要重新安装
- #3895Codex Desktop history temporarily disappears after provider/proxy switch
- #4012bug: stale Codex MCP servers resurrected from provider config and takeover backup
- #4254[Codex] Proxy takeover overwrites entire config.toml, silently destroying all user settings (UI preferences, MCP servers, memories, etc.)
- #4368codex重启会被cc-switch覆盖config.foml文件
- #5886Codex common_config_codex and route backup can be replaced by a partial config while proxy routing is active
- #5974[Bug] 开启 Codex 本地路由后 unifyCodexSessionHistory 对 OpenAI Official 失效:官方路由硬编码 cc-switch-official 桶导致官方/第三方会话历史分裂
- #6017[Bug] 代理接管(异常退出恢复路径)重写 config.toml 时不合并「应用通用配置」,导致 sandbox_mode/web_search 等设置丢失
- #6183Codex config.toml 在启动时被自动热切换覆盖,丢失 [windows] 和 [projects] 段
- #6265[Bug] 开启 Codex 本地代理接管后,重启 CC Switch 会清空 MCP 配置
- #6377[BUG]删除 MCP 服务器后,代理接管备份 (proxy_live_backup) 在退出时将其写回 config.toml,导致删除无效、再次导入时复活
- #6558bug(codex): CLI provider switch rewrites live config.toml from provider blob and drops permission profiles + compaction/reasoning keys
- #6860Config writer strips non-managed [model_providers.*] sections on takeover/switch, breaking old Codex threads
- 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”.
Related problems
Section titled “Related problems”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.