| 439 | } |
| 440 | |
| 441 | fn format_to_string(&self, servers: &BTreeMap<&str, &McpServerConfig>) -> Result<String> { |
| 442 | let mut doc = TomlTable::new(); |
| 443 | let mut mcp_servers = TomlTable::new(); |
| 444 | |
| 445 | for (name, config) in servers { |
| 446 | mcp_servers.insert((*name).to_string(), server_to_codex_toml(config)); |
| 447 | } |
| 448 | |
| 449 | doc.insert("mcp_servers".to_string(), TomlValue::Table(mcp_servers)); |
| 450 | |
| 451 | toml::to_string_pretty(&TomlValue::Table(doc)).context("Failed to serialize Codex config") |
| 452 | } |
| 453 | |
| 454 | fn parse_existing(&self, content: &str) -> Result<BTreeMap<String, Value>> { |
| 455 | let mut doc = parse_codex_doc(content)?; |