Skip to main content

remove_codex_mcp_config

Function remove_codex_mcp_config 

Source
pub fn remove_codex_mcp_config() -> Result<Option<(PathBuf, bool)>>
Expand description

Remove sqz’s MCP entry from Codex’s user-level config.toml.

Surgical: only removes [mcp_servers.sqz]. Other [mcp_servers.*] entries and unrelated keys are preserved. Uses toml_edit to keep the user’s comments, key order, and formatting intact.

If removing sqz empties out [mcp_servers], the now-empty table is dropped so the config file doesn’t end up with dangling headers. If the file would become empty after the surgery (only sqz’s entry existed) we delete it entirely — a zero-byte config.toml is just noise.

Returns Ok((path, changed)):

  • changed = true — sqz’s entry was removed or the file deleted
  • changed = false — no sqz entry found; nothing changed

Returns Ok(None) if the config file does not exist at all.