fix(codex): preserve nested MCP env tables when updating config#361
fix(codex): preserve nested MCP env tables when updating config#361yukaidi1220 wants to merge 4 commits into
Conversation
Review Summary by QodoPreserve nested MCP env tables during config updates
WalkthroughsDescription• Refactored MCP service config updates to preserve nested env tables • Replaced individual field edits with section-based replacement approach • Enhanced section regex to match and remove nested child sections together • Added regression test for existing node_repl.env config preservation Diagramflowchart LR
A["MCP Service Update"] --> B["upsertMcpSection"]
B --> C["createMcpSectionRegex"]
C --> D["Match parent and nested sections"]
D --> E["renderMcpSection"]
E --> F["Format inline tables"]
F --> G["Updated TOML content"]
File Changes1. src/utils/code-tools/codex-toml-updater.ts
|
Code Review by Qodo
1.
|
|
Addressed the follow-up review items in the latest commits. Changes included:
Re-ran the related tests and they pass. |
|
ci fail @yukaidi1220 |
Summary
This fixes Codex MCP config updates when
~/.codex/config.tomlalready contains nested MCP env tables such as[mcp_servers.node_repl.env].Before this change, updating MCP services could break existing Codex config in two ways:
env[mcp_servers.<id>.env]andenv = {...}for the same service, which caused duplicate key errorsIn practice, this showed up during MCP installation in Codex on Windows.
What changed
mcp_servers.*.envupdates[mcp_servers.node_repl.env]are updated or removed together with the parent MCP service sectionnode_repl.envconfigWhy
Codex may already contain MCP entries that use nested env tables.
The previous update path could rewrite those entries into an incompatible shape, which led to TOML parse failures and duplicate key errors.
This change keeps the update behavior predictable for MCP config while avoiding corruption of existing nested env tables.
Verification
Ran: