MCPcopy Create free account
hub / github.com/dallay/agentsync / server_to_codex_toml

Function server_to_codex_toml

src/mcp.rs:1028–1064  ·  view source on GitHub ↗

Convert McpServerConfig into a Codex CLI TOML server table

(config: &McpServerConfig)

Source from the content-addressed store, hash-verified

1026
1027/// Convert McpServerConfig into a Codex CLI TOML server table
1028fn server_to_codex_toml(config: &McpServerConfig) -> TomlValue {
1029 let mut table = TomlTable::new();
1030
1031 if let Some(ref cmd) = config.command {
1032 table.insert("command".to_string(), TomlValue::String(cmd.clone()));
1033 }
1034
1035 if !config.args.is_empty() {
1036 table.insert(
1037 "args".to_string(),
1038 TomlValue::Array(config.args.iter().cloned().map(TomlValue::String).collect()),
1039 );
1040 }
1041
1042 if !config.env.is_empty() {
1043 let mut env_table = TomlTable::new();
1044 for (k, v) in &config.env {
1045 env_table.insert(k.clone(), TomlValue::String(v.clone()));
1046 }
1047 table.insert("env".to_string(), TomlValue::Table(env_table));
1048 }
1049
1050 if let Some(ref url) = config.url {
1051 table.insert("url".to_string(), TomlValue::String(url.clone()));
1052 }
1053
1054 if !config.headers.is_empty() {
1055 let mut headers_table = TomlTable::new();
1056 for (k, v) in &config.headers {
1057 headers_table.insert(k.clone(), TomlValue::String(v.clone()));
1058 }
1059 // Codex MCP schema uses `http_headers` for static headers.
1060 table.insert("http_headers".to_string(), TomlValue::Table(headers_table));
1061 }
1062
1063 TomlValue::Table(table)
1064}
1065
1066// =============================================================================
1067// MCP Generator

Callers 3

format_to_stringMethod · 0.85
mergeMethod · 0.85

Calls 1

collectMethod · 0.80

Tested by

no test coverage detected