diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index f541a2c7bf..68d02e510c 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -709,6 +709,8 @@ "block2_0.6.2": "{\"dependencies\":[{\"default_features\":false,\"features\":[\"std\"],\"name\":\"objc2\",\"req\":\">=0.6.2, <0.8.0\"}],\"features\":{\"alloc\":[],\"compiler-rt\":[\"objc2/unstable-compiler-rt\"],\"default\":[\"std\"],\"gnustep-1-7\":[\"objc2/gnustep-1-7\"],\"gnustep-1-8\":[\"gnustep-1-7\",\"objc2/gnustep-1-8\"],\"gnustep-1-9\":[\"gnustep-1-8\",\"objc2/gnustep-1-9\"],\"gnustep-2-0\":[\"gnustep-1-9\",\"objc2/gnustep-2-0\"],\"gnustep-2-1\":[\"gnustep-2-0\",\"objc2/gnustep-2-1\"],\"std\":[\"alloc\"],\"unstable-coerce-pointee\":[],\"unstable-objfw\":[],\"unstable-private\":[],\"unstable-winobjc\":[\"gnustep-1-8\"]}}", "blocking_1.6.2": "{\"dependencies\":[{\"name\":\"async-channel\",\"req\":\"^2.0.0\"},{\"name\":\"async-task\",\"req\":\"^4.4.0\"},{\"default_features\":false,\"features\":[\"std\"],\"name\":\"futures-io\",\"req\":\"^0.3.28\"},{\"default_features\":false,\"name\":\"futures-lite\",\"req\":\"^2.0.0\"},{\"kind\":\"dev\",\"name\":\"futures-lite\",\"req\":\"^2.0.0\"},{\"name\":\"piper\",\"req\":\"^0.2.0\"},{\"default_features\":false,\"name\":\"tracing\",\"optional\":true,\"req\":\"^0.1.37\"}],\"features\":{}}", "bm25_2.3.2": "{\"dependencies\":[{\"name\":\"cached\",\"optional\":true,\"req\":\"^0.56.0\"},{\"kind\":\"dev\",\"name\":\"csv\",\"req\":\"^1.3.1\"},{\"name\":\"deunicode\",\"optional\":true,\"req\":\"^1.6.2\"},{\"kind\":\"dev\",\"name\":\"divan\",\"req\":\"^0.1.21\"},{\"name\":\"fxhash\",\"req\":\"^0.2.1\"},{\"kind\":\"dev\",\"name\":\"insta\",\"req\":\"^1.41.1\"},{\"name\":\"rayon\",\"optional\":true,\"req\":\"^1.11.0\"},{\"kind\":\"dev\",\"name\":\"rayon\",\"req\":\"^1.11.0\"},{\"name\":\"rust-stemmers\",\"optional\":true,\"req\":\"^1.2.0\"},{\"default_features\":false,\"features\":[\"nltk\"],\"name\":\"stop-words\",\"optional\":true,\"req\":\"^0.9.0\"},{\"name\":\"unicode-segmentation\",\"optional\":true,\"req\":\"^1.12.0\"},{\"name\":\"whichlang\",\"optional\":true,\"req\":\"^0.1.1\"}],\"features\":{\"default\":[\"default_tokenizer\"],\"default_tokenizer\":[\"dep:cached\",\"dep:stop-words\",\"dep:rust-stemmers\",\"dep:deunicode\",\"dep:unicode-segmentation\"],\"language_detection\":[\"dep:whichlang\",\"default_tokenizer\"],\"parallelism\":[\"dep:rayon\"]}}", + "bon-macros_3.9.1": "{\"dependencies\":[{\"name\":\"darling\",\"req\":\">=0.20.0, <0.24.0\"},{\"kind\":\"dev\",\"name\":\"expect-test\",\"req\":\"^1.4.1\"},{\"name\":\"ident_case\",\"req\":\"^1\"},{\"name\":\"prettyplease\",\"req\":\"^0.2\"},{\"name\":\"proc-macro2\",\"req\":\"^1.0.88\"},{\"name\":\"quote\",\"req\":\"^1\"},{\"name\":\"rustversion\",\"req\":\"^1.0.18\"},{\"features\":[\"full\",\"visit-mut\",\"visit\"],\"name\":\"syn\",\"req\":\"^2.0.56\"}],\"features\":{\"alloc\":[],\"default\":[],\"experimental-generics-setters\":[],\"experimental-overwritable\":[],\"implied-bounds\":[],\"std\":[]}}", + "bon_3.9.1": "{\"dependencies\":[{\"name\":\"bon-macros\",\"req\":\"=3.9.1\"},{\"kind\":\"dev\",\"name\":\"expect-test\",\"req\":\"^1.4.1\"},{\"kind\":\"dev\",\"name\":\"macro_rules_attribute\",\"req\":\"^0.2\"},{\"name\":\"rustversion\",\"req\":\"^1\"},{\"features\":[\"macros\",\"rt\"],\"kind\":\"dev\",\"name\":\"tokio\",\"req\":\"^1.29.1\"},{\"kind\":\"dev\",\"name\":\"trybuild\",\"req\":\"^1.0.89\"}],\"features\":{\"alloc\":[\"bon-macros/alloc\"],\"default\":[\"std\"],\"experimental-generics-setters\":[\"bon-macros/experimental-generics-setters\"],\"experimental-getter\":[],\"experimental-overwritable\":[\"bon-macros/experimental-overwritable\"],\"implied-bounds\":[\"bon-macros/implied-bounds\"],\"std\":[\"bon-macros/std\",\"alloc\"]}}", "borsh_1.6.0": "{\"dependencies\":[{\"name\":\"ascii\",\"optional\":true,\"req\":\"^1.1\"},{\"name\":\"borsh-derive\",\"optional\":true,\"req\":\"~1.6.0\"},{\"name\":\"bson\",\"optional\":true,\"req\":\"^2\"},{\"name\":\"bytes\",\"optional\":true,\"req\":\"^1\"},{\"kind\":\"build\",\"name\":\"cfg_aliases\",\"req\":\"^0.2.1\"},{\"name\":\"hashbrown\",\"optional\":true,\"req\":\">=0.11, <0.16.0\"},{\"name\":\"indexmap\",\"optional\":true,\"req\":\"^2\"},{\"kind\":\"dev\",\"name\":\"insta\",\"req\":\"^1.29.0\"},{\"kind\":\"dev\",\"name\":\"serde_json\",\"req\":\"^1\"}],\"features\":{\"de_strict_order\":[],\"default\":[\"std\"],\"derive\":[\"borsh-derive\"],\"rc\":[],\"std\":[],\"unstable__schema\":[\"derive\",\"borsh-derive/schema\"]}}", "bstr_1.12.1": "{\"dependencies\":[{\"default_features\":false,\"name\":\"memchr\",\"req\":\"^2.7.1\"},{\"default_features\":false,\"kind\":\"dev\",\"name\":\"quickcheck\",\"req\":\"^1\"},{\"default_features\":false,\"features\":[\"dfa-search\"],\"name\":\"regex-automata\",\"optional\":true,\"req\":\"^0.4.1\"},{\"default_features\":false,\"name\":\"serde\",\"optional\":true,\"req\":\"^1.0.85\"},{\"kind\":\"dev\",\"name\":\"ucd-parse\",\"req\":\"^0.1.3\"},{\"kind\":\"dev\",\"name\":\"unicode-segmentation\",\"req\":\"^1.2.1\"}],\"features\":{\"alloc\":[\"memchr/alloc\",\"serde?/alloc\"],\"default\":[\"std\",\"unicode\"],\"serde\":[\"dep:serde\"],\"std\":[\"alloc\",\"memchr/std\",\"serde?/std\"],\"unicode\":[\"dep:regex-automata\"]}}", "bumpalo_3.19.1": "{\"dependencies\":[{\"default_features\":false,\"name\":\"allocator-api2\",\"optional\":true,\"req\":\"^0.2.8\"},{\"kind\":\"dev\",\"name\":\"blink-alloc\",\"req\":\"=0.4.0\"},{\"kind\":\"dev\",\"name\":\"criterion\",\"req\":\"^0.3.6\"},{\"kind\":\"dev\",\"name\":\"quickcheck\",\"req\":\"^1.0.3\"},{\"kind\":\"dev\",\"name\":\"rand\",\"req\":\"^0.8.5\"},{\"kind\":\"dev\",\"name\":\"rayon\",\"req\":\"=1.10.0\"},{\"kind\":\"dev\",\"name\":\"rayon-core\",\"req\":\"=1.12.1\"},{\"name\":\"serde\",\"optional\":true,\"req\":\"^1.0.171\"},{\"features\":[\"derive\"],\"kind\":\"dev\",\"name\":\"serde\",\"req\":\"^1.0.197\"},{\"kind\":\"dev\",\"name\":\"serde_json\",\"req\":\"^1.0.115\"}],\"features\":{\"allocator_api\":[],\"bench_allocator_api\":[\"allocator_api\",\"blink-alloc/nightly\"],\"boxed\":[],\"collections\":[],\"default\":[],\"serde\":[\"dep:serde\"],\"std\":[]}}", diff --git a/codex-rs/Cargo.lock b/codex-rs/Cargo.lock index 745feb93be..e0edfb3fe3 100644 --- a/codex-rs/Cargo.lock +++ b/codex-rs/Cargo.lock @@ -1390,6 +1390,31 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "bon" +version = "3.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f47dbe92550676ee653353c310dfb9cf6ba17ee70396e1f7cf0a2020ad49b2fe" +dependencies = [ + "bon-macros", + "rustversion", +] + +[[package]] +name = "bon-macros" +version = "3.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "519bd3116aeeb42d5372c29d982d16d0170d3d4a5ed85fc7dd91642ffff3c67c" +dependencies = [ + "darling 0.23.0", + "ident_case", + "prettyplease", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.114", +] + [[package]] name = "borsh" version = "1.6.0" @@ -2452,6 +2477,7 @@ dependencies = [ "anyhow", "async-trait", "base64 0.22.1", + "bon", "codex-app-server-protocol", "codex-execpolicy", "codex-features", @@ -10299,7 +10325,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes", - "heck 0.4.1", + "heck 0.5.0", "itertools 0.11.0", "log", "multimap", @@ -10319,7 +10345,7 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "343d3bd7056eda839b03204e68deff7d1b13aba7af2b2fd16890697274262ee7" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "itertools 0.14.0", "log", "multimap", @@ -11453,7 +11479,7 @@ dependencies = [ "security-framework 3.5.1", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] diff --git a/codex-rs/Cargo.toml b/codex-rs/Cargo.toml index f0c9b601f9..800d6df63b 100644 --- a/codex-rs/Cargo.toml +++ b/codex-rs/Cargo.toml @@ -263,6 +263,7 @@ aws-types = "1" axum = { version = "0.8", default-features = false } base64 = "0.22.1" bm25 = "2.3.2" +bon = "3.9.1" bytes = "1.10.1" chardetng = "0.1.17" chrono = "0.4.43" diff --git a/codex-rs/cli/src/mcp_cmd.rs b/codex-rs/cli/src/mcp_cmd.rs index 0103782653..2c2125baac 100644 --- a/codex-rs/cli/src/mcp_cmd.rs +++ b/codex-rs/cli/src/mcp_cmd.rs @@ -340,27 +340,17 @@ async fn run_add(config_overrides: &CliConfigOverrides, add_args: AddArgs) -> Re AddMcpTransportArgs { .. } => bail!("exactly one of --command or --url must be provided"), }; - let new_entry = McpServerConfig { - transport: transport.clone(), - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: oauth_client_id - .clone() - .map(|client_id| McpServerOAuthConfig { - client_id: Some(client_id), - }), - oauth_resource: oauth_resource.clone(), - tools: HashMap::new(), - }; + let new_entry = McpServerConfig::builder() + .transport(transport.clone()) + .maybe_oauth( + oauth_client_id + .clone() + .map(|client_id| McpServerOAuthConfig { + client_id: Some(client_id), + }), + ) + .maybe_oauth_resource(oauth_resource.clone()) + .build(); servers.insert(name.clone(), new_entry); diff --git a/codex-rs/codex-mcp/src/connection_manager_tests.rs b/codex-rs/codex-mcp/src/connection_manager_tests.rs index 60a0026eeb..bbcd110579 100644 --- a/codex-rs/codex-mcp/src/connection_manager_tests.rs +++ b/codex-rs/codex-mcp/src/connection_manager_tests.rs @@ -1116,54 +1116,30 @@ async fn no_local_runtime_fails_local_stdio_but_keeps_local_http_server() { let mcp_servers = HashMap::from([ ( "stdio".to_string(), - EffectiveMcpServer::configured(McpServerConfig { - transport: McpServerTransportConfig::Stdio { - command: "echo".to_string(), - args: Vec::new(), - env: None, - env_vars: Vec::new(), - cwd: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }), + EffectiveMcpServer::configured( + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { + command: "echo".to_string(), + args: Vec::new(), + env: None, + env_vars: Vec::new(), + cwd: None, + }) + .build(), + ), ), ( "http".to_string(), - EffectiveMcpServer::configured(McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { - url: "http://127.0.0.1:1".to_string(), - bearer_token_env_var: None, - http_headers: None, - env_http_headers: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }), + EffectiveMcpServer::configured( + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { + url: "http://127.0.0.1:1".to_string(), + bearer_token_env_var: None, + http_headers: None, + env_http_headers: None, + }) + .build(), + ), ), ]); @@ -1241,28 +1217,16 @@ fn elicitation_capability_advertises_url_support_when_enabled() { fn mcp_init_error_display_prompts_for_github_pat() { let server_name = "github"; let entry = McpAuthStatusEntry { - config: Some(McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { - url: "https://api.githubcopilot.com/mcp/".to_string(), - bearer_token_env_var: None, - http_headers: None, - env_http_headers: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }), + config: Some( + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { + url: "https://api.githubcopilot.com/mcp/".to_string(), + bearer_token_env_var: None, + http_headers: None, + env_http_headers: None, + }) + .build(), + ), auth_status: McpAuthStatus::Unsupported, }; let err: StartupOutcomeError = anyhow::anyhow!("OAuth is unsupported").into(); @@ -1294,28 +1258,16 @@ fn mcp_init_error_display_prompts_for_login_when_auth_required() { fn mcp_init_error_display_reports_generic_errors() { let server_name = "custom"; let entry = McpAuthStatusEntry { - config: Some(McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { - url: "https://example.com".to_string(), - bearer_token_env_var: Some("TOKEN".to_string()), - http_headers: None, - env_http_headers: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }), + config: Some( + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { + url: "https://example.com".to_string(), + bearer_token_env_var: Some("TOKEN".to_string()), + http_headers: None, + env_http_headers: None, + }) + .build(), + ), auth_status: McpAuthStatus::Unsupported, }; let err: StartupOutcomeError = anyhow::anyhow!("boom").into(); diff --git a/codex-rs/codex-mcp/src/mcp/mod.rs b/codex-rs/codex-mcp/src/mcp/mod.rs index 51a6f18686..93295fa7a1 100644 --- a/codex-rs/codex-mcp/src/mcp/mod.rs +++ b/codex-rs/codex-mcp/src/mcp/mod.rs @@ -451,28 +451,15 @@ fn codex_apps_mcp_server_config(config: &McpConfig) -> McpServerConfig { HashMap::from([("X-OpenAI-Product-Sku".to_string(), product_sku.clone())]) }); - McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { url, bearer_token_env_var: codex_apps_mcp_bearer_token_env_var(), http_headers, env_http_headers: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: Some(Duration::from_secs(30)), - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - } + }) + .startup_timeout_sec(Duration::from_secs(30)) + .build() } fn protocol_tool_from_rmcp_tool(name: &str, tool: &rmcp::model::Tool) -> Option { diff --git a/codex-rs/codex-mcp/src/mcp/mod_tests.rs b/codex-rs/codex-mcp/src/mcp/mod_tests.rs index d4d888f202..4fc44a4e8b 100644 --- a/codex-rs/codex-mcp/src/mcp/mod_tests.rs +++ b/codex-rs/codex-mcp/src/mcp/mod_tests.rs @@ -310,53 +310,25 @@ async fn effective_mcp_servers_preserve_user_servers_and_add_codex_apps() { config.configured_mcp_servers.insert( "sample".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { url: "https://user.example/mcp".to_string(), bearer_token_env_var: None, http_headers: None, env_http_headers: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .build(), ); config.configured_mcp_servers.insert( "docs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { url: "https://docs.example/mcp".to_string(), bearer_token_env_var: None, http_headers: None, env_http_headers: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .build(), ); let effective = effective_mcp_servers(&config, Some(&auth)); diff --git a/codex-rs/codex-mcp/src/runtime.rs b/codex-rs/codex-mcp/src/runtime.rs index 5404bf1eb5..8f3d7efa7b 100644 --- a/codex-rs/codex-mcp/src/runtime.rs +++ b/codex-rs/codex-mcp/src/runtime.rs @@ -118,8 +118,6 @@ pub(crate) fn emit_duration(metric: &str, duration: Duration, tags: &[(&str, &st #[cfg(test)] mod tests { - use std::collections::HashMap; - use codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID; use codex_config::McpServerConfig; use codex_config::McpServerTransportConfig; @@ -129,42 +127,28 @@ mod tests { use super::*; fn stdio_server(environment_id: &str) -> McpServerConfig { - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "echo".to_string(), args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: environment_id.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - } + }) + .environment_id(environment_id.to_string()) + .build() } fn http_server(environment_id: &str) -> McpServerConfig { - McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { url: "http://127.0.0.1:1".to_string(), bearer_token_env_var: None, http_headers: None, env_http_headers: None, - }, - environment_id: environment_id.to_string(), - ..stdio_server(environment_id) - } + }) + .environment_id(environment_id.to_string()) + .build() } #[test] diff --git a/codex-rs/config/Cargo.toml b/codex-rs/config/Cargo.toml index f77a76b764..b50ca99535 100644 --- a/codex-rs/config/Cargo.toml +++ b/codex-rs/config/Cargo.toml @@ -15,6 +15,7 @@ workspace = true anyhow = { workspace = true } async-trait = { workspace = true } base64 = { workspace = true } +bon = { workspace = true } codex-app-server-protocol = { workspace = true } codex-execpolicy = { workspace = true } codex-features = { workspace = true } diff --git a/codex-rs/config/src/mcp_edit_tests.rs b/codex-rs/config/src/mcp_edit_tests.rs index 030b0a0233..ff8047fbcd 100644 --- a/codex-rs/config/src/mcp_edit_tests.rs +++ b/codex-rs/config/src/mcp_edit_tests.rs @@ -15,28 +15,17 @@ async fn replace_mcp_servers_serializes_per_tool_approval_overrides() -> anyhow: )); let servers = BTreeMap::from([( "docs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "docs-server".to_string(), args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: crate::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: true, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: Some(AppToolApproval::Auto), - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::from([ + }) + .supports_parallel_tool_calls(true) + .default_tools_approval_mode(AppToolApproval::Auto) + .tools(HashMap::from([ ( "search".to_string(), McpServerToolConfig { @@ -49,8 +38,8 @@ async fn replace_mcp_servers_serializes_per_tool_approval_overrides() -> anyhow: approval_mode: Some(AppToolApproval::Prompt), }, ), - ]), - }, + ])) + .build(), )]); ConfigEditsBuilder::new(&codex_home) @@ -94,30 +83,17 @@ async fn replace_mcp_servers_serializes_oauth_client_id() -> anyhow::Result<()> )); let servers = BTreeMap::from([( "maas_outlook".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { url: "https://example.com/mcp".to_string(), bearer_token_env_var: None, http_headers: None, env_http_headers: None, - }, - environment_id: crate::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: Some(McpServerOAuthConfig { + }) + .oauth(McpServerOAuthConfig { client_id: Some("eci-prd-pub-codex-123".to_string()), - }), - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .build(), )]); ConfigEditsBuilder::new(&codex_home) diff --git a/codex-rs/config/src/mcp_types.rs b/codex-rs/config/src/mcp_types.rs index 0d30ba8b23..737b178fc8 100644 --- a/codex-rs/config/src/mcp_types.rs +++ b/codex-rs/config/src/mcp_types.rs @@ -126,24 +126,28 @@ pub struct McpServerOAuthConfig { pub client_id: Option, } -#[derive(Serialize, Debug, Clone, PartialEq)] +#[derive(Serialize, Debug, Clone, PartialEq, bon::Builder)] pub struct McpServerConfig { #[serde(flatten)] pub transport: McpServerTransportConfig, /// Effective environment id for where Codex should start this MCP server. + #[builder(default = DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string())] pub environment_id: String, /// When `false`, Codex skips initializing this MCP server. #[serde(default = "default_enabled")] + #[builder(default = true)] pub enabled: bool, /// When `true`, `codex exec` exits with an error if this MCP server fails to initialize. #[serde(default, skip_serializing_if = "std::ops::Not::not")] + #[builder(default)] pub required: bool, /// When `true`, every tool from this server is advertised as safe for parallel tool calls. #[serde(default, skip_serializing_if = "std::ops::Not::not")] + #[builder(default)] pub supports_parallel_tool_calls: bool, /// Reason this server was disabled after applying requirements. @@ -188,6 +192,7 @@ pub struct McpServerConfig { /// Per-tool approval settings keyed by tool name. #[serde(default, skip_serializing_if = "HashMap::is_empty")] + #[builder(default)] pub tools: HashMap, } diff --git a/codex-rs/config/src/mcp_types_tests.rs b/codex-rs/config/src/mcp_types_tests.rs index 5f3933ce43..2f4ef2be81 100644 --- a/codex-rs/config/src/mcp_types_tests.rs +++ b/codex-rs/config/src/mcp_types_tests.rs @@ -450,29 +450,15 @@ fn deserialize_ignores_unknown_server_fields() { assert_eq!( cfg, - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "echo".to_string(), args: vec![], env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: crate::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - } + }) + .build() ); } diff --git a/codex-rs/core-plugins/src/manager_tests.rs b/codex-rs/core-plugins/src/manager_tests.rs index f9fae56318..57cfca852d 100644 --- a/codex-rs/core-plugins/src/manager_tests.rs +++ b/codex-rs/core-plugins/src/manager_tests.rs @@ -212,30 +212,17 @@ async fn load_plugins_loads_default_skills_and_mcp_servers() { has_enabled_skills: true, mcp_servers: HashMap::from([( "sample".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { url: "https://sample.example/mcp".to_string(), bearer_token_env_var: None, http_headers: None, env_http_headers: None, - }, - environment_id: "local".to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: Some(McpServerOAuthConfig { + }) + .oauth(McpServerOAuthConfig { client_id: Some("client-id".to_string()), - }), - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .build(), )]), apps: vec![AppConnectorId("connector_example".to_string())], hook_sources: Vec::new(), @@ -715,28 +702,14 @@ async fn load_plugins_uses_manifest_configured_component_paths() { outcome.plugins()[0].mcp_servers, HashMap::from([( "custom".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { url: "https://custom.example/mcp".to_string(), bearer_token_env_var: None, http_headers: None, env_http_headers: None, - }, - environment_id: "local".to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .build(), )]) ); assert_eq!( @@ -827,28 +800,14 @@ async fn load_plugins_ignores_manifest_component_paths_without_dot_slash() { outcome.plugins()[0].mcp_servers, HashMap::from([( "default".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { url: "https://default.example/mcp".to_string(), bearer_token_env_var: None, http_headers: None, env_http_headers: None, - }, - environment_id: "local".to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .build(), )]) ); assert_eq!( @@ -1033,27 +992,15 @@ async fn effective_apps_preserves_app_config_order() { fn capability_index_filters_inactive_and_zero_capability_plugins() { let codex_home = TempDir::new().unwrap(); let connector = |id: &str| AppConnectorId(id.to_string()); - let http_server = |url: &str| McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { - url: url.to_string(), - bearer_token_env_var: None, - http_headers: None, - env_http_headers: None, - }, - environment_id: "local".to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), + let http_server = |url: &str| { + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { + url: url.to_string(), + bearer_token_env_var: None, + http_headers: None, + env_http_headers: None, + }) + .build() }; let plugin = |config_name: &str, dir_name: &str, manifest_name: &str| LoadedPlugin { config_name: config_name.to_string(), diff --git a/codex-rs/core/src/config/config_tests.rs b/codex-rs/core/src/config/config_tests.rs index 70719843ba..0abd40c264 100644 --- a/codex-rs/core/src/config/config_tests.rs +++ b/codex-rs/core/src/config/config_tests.rs @@ -110,54 +110,26 @@ use std::time::Duration; use tempfile::TempDir; fn stdio_mcp(command: &str) -> McpServerConfig { - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: command.to_string(), args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - } + }) + .build() } fn http_mcp(url: &str) -> McpServerConfig { - McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { url: url.to_string(), bearer_token_env_var: None, http_headers: None, env_http_headers: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - } + }) + .build() } async fn derive_legacy_sandbox_policy_for_test( @@ -4170,16 +4142,14 @@ async fn rebuild_preserving_session_layers_refreshes_requirements() -> std::io:: "fresh_project".to_string(), stdio_mcp("fresh-project-command"), ), - ( - "blocked_session".to_string(), - McpServerConfig { - enabled: false, - disabled_reason: Some(McpServerDisabledReason::Requirements { - source: RequirementSource::Unknown, - }), - ..stdio_mcp("blocked-session-command") - }, - ), + ("blocked_session".to_string(), { + let mut server = stdio_mcp("blocked-session-command"); + server.enabled = false; + server.disabled_reason = Some(McpServerDisabledReason::Requirements { + source: RequirementSource::Unknown, + }); + server + },), ]) ); @@ -5150,29 +5120,18 @@ async fn replace_mcp_servers_round_trips_entries() -> anyhow::Result<()> { let mut servers = BTreeMap::new(); servers.insert( "docs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "echo".to_string(), args: vec!["hello".to_string()], env: None, env_vars: Vec::new(), cwd: Some(codex_home.path().to_path_buf()), - }, - environment_id: "remote".to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: Some(Duration::from_secs(3)), - tool_timeout_sec: Some(Duration::from_secs(5)), - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .environment_id("remote".to_string()) + .startup_timeout_sec(Duration::from_secs(3)) + .tool_timeout_sec(Duration::from_secs(5)) + .build(), ); apply_blocking( @@ -5513,8 +5472,8 @@ async fn replace_mcp_servers_serializes_env_sorted() -> anyhow::Result<()> { let servers = BTreeMap::from([( "docs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "docs-server".to_string(), args: vec!["--verbose".to_string()], env: Some(HashMap::from([ @@ -5523,22 +5482,8 @@ async fn replace_mcp_servers_serializes_env_sorted() -> anyhow::Result<()> { ])), env_vars: Vec::new(), cwd: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .build(), )]); apply_blocking( @@ -5592,29 +5537,15 @@ async fn replace_mcp_servers_serializes_env_vars() -> anyhow::Result<()> { let servers = BTreeMap::from([( "docs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "docs-server".to_string(), args: Vec::new(), env: None, env_vars: vec!["ALPHA".into(), "BETA".into()], cwd: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .build(), )]); apply_blocking( @@ -5647,8 +5578,8 @@ async fn replace_mcp_servers_serializes_sourced_env_vars() -> anyhow::Result<()> let servers = BTreeMap::from([( "docs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "docs-server".to_string(), args: Vec::new(), env: None, @@ -5660,22 +5591,8 @@ async fn replace_mcp_servers_serializes_sourced_env_vars() -> anyhow::Result<()> }, ], cwd: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .build(), )]); apply_blocking( @@ -5704,29 +5621,15 @@ async fn replace_mcp_servers_serializes_cwd() -> anyhow::Result<()> { let cwd_path = PathBuf::from("/tmp/codex-mcp"); let servers = BTreeMap::from([( "docs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "docs-server".to_string(), args: Vec::new(), env: None, env_vars: Vec::new(), cwd: Some(cwd_path.clone()), - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .build(), )]); apply_blocking( @@ -5759,28 +5662,15 @@ async fn replace_mcp_servers_streamable_http_serializes_bearer_token() -> anyhow let servers = BTreeMap::from([( "docs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { url: "https://example.com/mcp".to_string(), bearer_token_env_var: Some("MCP_TOKEN".to_string()), http_headers: None, env_http_headers: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: Some(Duration::from_secs(2)), - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .startup_timeout_sec(Duration::from_secs(2)) + .build(), )]); apply_blocking( @@ -5826,8 +5716,8 @@ async fn replace_mcp_servers_streamable_http_serializes_custom_headers() -> anyh let servers = BTreeMap::from([( "docs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { url: "https://example.com/mcp".to_string(), bearer_token_env_var: Some("MCP_TOKEN".to_string()), http_headers: Some(HashMap::from([("X-Doc".to_string(), "42".to_string())])), @@ -5835,22 +5725,9 @@ async fn replace_mcp_servers_streamable_http_serializes_custom_headers() -> anyh "X-Auth".to_string(), "DOCS_AUTH".to_string(), )])), - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: Some(Duration::from_secs(2)), - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .startup_timeout_sec(Duration::from_secs(2)) + .build(), )]); apply_blocking( codex_home.path(), @@ -5908,8 +5785,8 @@ async fn replace_mcp_servers_streamable_http_removes_optional_sections() -> anyh let mut servers = BTreeMap::from([( "docs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { url: "https://example.com/mcp".to_string(), bearer_token_env_var: Some("MCP_TOKEN".to_string()), http_headers: Some(HashMap::from([("X-Doc".to_string(), "42".to_string())])), @@ -5917,22 +5794,9 @@ async fn replace_mcp_servers_streamable_http_removes_optional_sections() -> anyh "X-Auth".to_string(), "DOCS_AUTH".to_string(), )])), - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: Some(Duration::from_secs(2)), - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .startup_timeout_sec(Duration::from_secs(2)) + .build(), )]); apply_blocking( @@ -5946,28 +5810,14 @@ async fn replace_mcp_servers_streamable_http_removes_optional_sections() -> anyh servers.insert( "docs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { url: "https://example.com/mcp".to_string(), bearer_token_env_var: None, http_headers: None, env_http_headers: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .build(), ); apply_blocking( codex_home.path(), @@ -6013,8 +5863,8 @@ async fn replace_mcp_servers_streamable_http_isolates_headers_between_servers() let servers = BTreeMap::from([ ( "docs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { url: "https://example.com/mcp".to_string(), bearer_token_env_var: Some("MCP_TOKEN".to_string()), http_headers: Some(HashMap::from([("X-Doc".to_string(), "42".to_string())])), @@ -6022,48 +5872,21 @@ async fn replace_mcp_servers_streamable_http_isolates_headers_between_servers() "X-Auth".to_string(), "DOCS_AUTH".to_string(), )])), - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: Some(Duration::from_secs(2)), - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .startup_timeout_sec(Duration::from_secs(2)) + .build(), ), ( "logs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "logs-server".to_string(), args: vec!["--follow".to_string()], env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .build(), ), ]); @@ -6129,29 +5952,16 @@ async fn replace_mcp_servers_serializes_disabled_flag() -> anyhow::Result<()> { let servers = BTreeMap::from([( "docs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "docs-server".to_string(), args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: false, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .enabled(false) + .build(), )]); apply_blocking( @@ -6179,29 +5989,16 @@ async fn replace_mcp_servers_serializes_required_flag() -> anyhow::Result<()> { let servers = BTreeMap::from([( "docs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "docs-server".to_string(), args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: true, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .required(true) + .build(), )]); apply_blocking( @@ -6229,29 +6026,17 @@ async fn replace_mcp_servers_serializes_tool_filters() -> anyhow::Result<()> { let servers = BTreeMap::from([( "docs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "docs-server".to_string(), args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: Some(vec!["allowed".to_string()]), - disabled_tools: Some(vec!["blocked".to_string()]), - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .enabled_tools(vec!["allowed".to_string()]) + .disabled_tools(vec!["blocked".to_string()]) + .build(), )]); apply_blocking( @@ -6284,30 +6069,18 @@ async fn replace_mcp_servers_streamable_http_serializes_oauth_resource() -> anyh let servers = BTreeMap::from([( "docs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { url: "https://example.com/mcp".to_string(), bearer_token_env_var: None, http_headers: None, env_http_headers: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: Some(McpServerOAuthConfig { + }) + .oauth(McpServerOAuthConfig { client_id: Some("eci-prd-pub-codex-123".to_string()), - }), - oauth_resource: Some("https://resource.example.com".to_string()), - tools: HashMap::new(), - }, + }) + .oauth_resource("https://resource.example.com".to_string()) + .build(), )]); apply_blocking( diff --git a/codex-rs/core/src/config/edit_tests.rs b/codex-rs/core/src/config/edit_tests.rs index dce192831b..d60f1645e9 100644 --- a/codex-rs/core/src/config/edit_tests.rs +++ b/codex-rs/core/src/config/edit_tests.rs @@ -872,8 +872,8 @@ fn blocking_replace_mcp_servers_round_trips() { let mut servers = BTreeMap::new(); servers.insert( "stdio".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "cmd".to_string(), args: vec!["--flag".to_string()], env: Some( @@ -886,28 +886,16 @@ fn blocking_replace_mcp_servers_round_trips() { ), env_vars: vec!["FOO".into()], cwd: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: true, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: Some(vec!["one".to_string(), "two".to_string()]), - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .supports_parallel_tool_calls(true) + .enabled_tools(vec!["one".to_string(), "two".to_string()]) + .build(), ); servers.insert( "http".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { + McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { url: "https://example.com".to_string(), bearer_token_env_var: Some("TOKEN".to_string()), http_headers: Some( @@ -916,24 +904,15 @@ fn blocking_replace_mcp_servers_round_trips() { .collect(), ), env_http_headers: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: false, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: Some(std::time::Duration::from_secs(5)), - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: Some(vec!["forbidden".to_string()]), - scopes: None, - oauth: Some(McpServerOAuthConfig { + }) + .enabled(false) + .startup_timeout_sec(std::time::Duration::from_secs(5)) + .disabled_tools(vec!["forbidden".to_string()]) + .oauth(McpServerOAuthConfig { client_id: Some("eci-prd-pub-codex-123".to_string()), - }), - oauth_resource: Some("https://resource.example.com".to_string()), - tools: HashMap::new(), - }, + }) + .oauth_resource("https://resource.example.com".to_string()) + .build(), ); apply_blocking( @@ -980,34 +959,22 @@ fn blocking_replace_mcp_servers_serializes_tool_approval_overrides() { let mut servers = BTreeMap::new(); servers.insert( "docs".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "docs-server".to_string(), args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: Some(AppToolApproval::Prompt), - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::from([( + }) + .default_tools_approval_mode(AppToolApproval::Prompt) + .tools(HashMap::from([( "search".to_string(), McpServerToolConfig { approval_mode: Some(AppToolApproval::Approve), }, - )]), - }, + )])) + .build(), ); apply_blocking(codex_home, &[ConfigEdit::ReplaceMcpServers(servers)]).expect("persist"); @@ -1040,29 +1007,15 @@ foo = { command = "cmd" } let mut servers = BTreeMap::new(); servers.insert( "foo".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "cmd".to_string(), args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .build(), ); apply_blocking(codex_home, &[ConfigEdit::ReplaceMcpServers(servers)]).expect("persist"); @@ -1090,29 +1043,16 @@ foo = { command = "cmd" } # keep me let mut servers = BTreeMap::new(); servers.insert( "foo".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "cmd".to_string(), args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: false, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .enabled(false) + .build(), ); apply_blocking(codex_home, &[ConfigEdit::ReplaceMcpServers(servers)]).expect("persist"); @@ -1139,29 +1079,15 @@ foo = { command = "cmd", args = ["--flag"] } # keep me let mut servers = BTreeMap::new(); servers.insert( "foo".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "cmd".to_string(), args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .build(), ); apply_blocking(codex_home, &[ConfigEdit::ReplaceMcpServers(servers)]).expect("persist"); @@ -1189,29 +1115,16 @@ foo = { command = "cmd" } let mut servers = BTreeMap::new(); servers.insert( "foo".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: "cmd".to_string(), args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: false, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .enabled(false) + .build(), ); apply_blocking(codex_home, &[ConfigEdit::ReplaceMcpServers(servers)]).expect("persist"); diff --git a/codex-rs/core/src/mcp_skill_dependencies.rs b/codex-rs/core/src/mcp_skill_dependencies.rs index 936f1b5fb5..ce6679473b 100644 --- a/codex-rs/core/src/mcp_skill_dependencies.rs +++ b/codex-rs/core/src/mcp_skill_dependencies.rs @@ -354,28 +354,14 @@ fn mcp_dependency_to_server_config( .url .as_ref() .ok_or_else(|| "missing url for streamable_http dependency".to_string())?; - return Ok(McpServerConfig { - transport: McpServerTransportConfig::StreamableHttp { + return Ok(McpServerConfig::builder() + .transport(McpServerTransportConfig::StreamableHttp { url: url.clone(), bearer_token_env_var: None, http_headers: None, env_http_headers: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }); + }) + .build()); } if transport.eq_ignore_ascii_case("stdio") { @@ -383,29 +369,15 @@ fn mcp_dependency_to_server_config( .command .as_ref() .ok_or_else(|| "missing command for stdio dependency".to_string())?; - return Ok(McpServerConfig { - transport: McpServerTransportConfig::Stdio { + return Ok(McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: command.clone(), args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: None, - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }); + }) + .build()); } Err(format!("unsupported transport {transport}")) diff --git a/codex-rs/core/tests/suite/code_mode.rs b/codex-rs/core/tests/suite/code_mode.rs index 9881869313..cfcaed5c2f 100644 --- a/codex-rs/core/tests/suite/code_mode.rs +++ b/codex-rs/core/tests/suite/code_mode.rs @@ -251,8 +251,8 @@ async fn run_code_mode_turn_with_rmcp_config( let mut servers = config.mcp_servers.get().clone(); servers.insert( "rmcp".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: rmcp_test_server_bin, args: Vec::new(), env: Some(HashMap::from([( @@ -261,22 +261,9 @@ async fn run_code_mode_turn_with_rmcp_config( )])), env_vars: Vec::new(), cwd: None, - }, - environment_id: "local".to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: Some(Duration::from_secs(10)), - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .startup_timeout_sec(Duration::from_secs(10)) + .build(), ); config .mcp_servers diff --git a/codex-rs/core/tests/suite/hooks_mcp.rs b/codex-rs/core/tests/suite/hooks_mcp.rs index 00f1546a7c..7830dc1612 100644 --- a/codex-rs/core/tests/suite/hooks_mcp.rs +++ b/codex-rs/core/tests/suite/hooks_mcp.rs @@ -1,4 +1,3 @@ -use std::collections::HashMap; use std::fs; use std::path::Path; use std::time::Duration; @@ -183,29 +182,17 @@ fn insert_rmcp_test_server(config: &mut Config, command: String, approval_mode: let mut servers = config.mcp_servers.get().clone(); servers.insert( RMCP_SERVER.to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command, args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: Some(Duration::from_secs(10)), - tool_timeout_sec: None, - default_tools_approval_mode: Some(approval_mode), - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .startup_timeout_sec(Duration::from_secs(10)) + .default_tools_approval_mode(approval_mode) + .build(), ); if let Err(err) = config.mcp_servers.set(servers) { panic!("test mcp servers should accept any configuration: {err}"); diff --git a/codex-rs/core/tests/suite/rmcp_client.rs b/codex-rs/core/tests/suite/rmcp_client.rs index c3d598c7ba..d3629c8f43 100644 --- a/codex-rs/core/tests/suite/rmcp_client.rs +++ b/codex-rs/core/tests/suite/rmcp_client.rs @@ -316,23 +316,13 @@ fn insert_mcp_server( let mut servers = config.mcp_servers.get().clone(); servers.insert( server_name.to_string(), - McpServerConfig { - transport, - environment_id: options.environment_id, - enabled: true, - required: false, - supports_parallel_tool_calls: options.supports_parallel_tool_calls, - disabled_reason: None, - startup_timeout_sec: Some(Duration::from_secs(10)), - tool_timeout_sec: options.tool_timeout_sec, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + McpServerConfig::builder() + .transport(transport) + .environment_id(options.environment_id) + .supports_parallel_tool_calls(options.supports_parallel_tool_calls) + .startup_timeout_sec(Duration::from_secs(10)) + .maybe_tool_timeout_sec(options.tool_timeout_sec) + .build(), ); if let Err(err) = config.mcp_servers.set(servers) { panic!("test mcp servers should accept any configuration: {err}"); diff --git a/codex-rs/core/tests/suite/search_tool.rs b/codex-rs/core/tests/suite/search_tool.rs index 42b1b6bb3f..7d08a08456 100644 --- a/codex-rs/core/tests/suite/search_tool.rs +++ b/codex-rs/core/tests/suite/search_tool.rs @@ -51,7 +51,6 @@ use core_test_support::wait_for_mcp_server; use pretty_assertions::assert_eq; use serde_json::Value; use serde_json::json; -use std::collections::HashMap; use std::time::Duration; const SEARCH_TOOL_DESCRIPTION_SNIPPETS: [&str; 2] = [ @@ -1085,29 +1084,18 @@ async fn tool_search_indexes_only_enabled_non_app_mcp_tools() -> Result<()> { let mut servers = config.mcp_servers.get().clone(); servers.insert( "rmcp".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: rmcp_test_server_bin, args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: "local".to_string(), - enabled: true, - required: false, - disabled_reason: None, - startup_timeout_sec: Some(Duration::from_secs(10)), - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: Some(vec!["echo".to_string(), "image".to_string()]), - disabled_tools: Some(vec!["image".to_string()]), - scopes: None, - oauth: None, - oauth_resource: None, - supports_parallel_tool_calls: false, - tools: HashMap::new(), - }, + }) + .startup_timeout_sec(Duration::from_secs(10)) + .enabled_tools(vec!["echo".to_string(), "image".to_string()]) + .disabled_tools(vec!["image".to_string()]) + .build(), ); config .mcp_servers @@ -1215,29 +1203,17 @@ async fn tool_search_surfaced_mcp_tool_errors_are_returned_to_model() -> Result< let mut servers = config.mcp_servers.get().clone(); servers.insert( "rmcp".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: rmcp_test_server_bin, args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: "local".to_string(), - enabled: true, - required: false, - disabled_reason: None, - startup_timeout_sec: Some(Duration::from_secs(10)), - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: Some(vec!["echo".to_string()]), - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - supports_parallel_tool_calls: false, - tools: HashMap::new(), - }, + }) + .startup_timeout_sec(Duration::from_secs(10)) + .enabled_tools(vec!["echo".to_string()]) + .build(), ); config .mcp_servers @@ -1364,29 +1340,17 @@ async fn tool_search_uses_non_app_mcp_server_instructions_as_namespace_descripti let mut servers = config.mcp_servers.get().clone(); servers.insert( "rmcp".to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: rmcp_test_server_bin, args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: "local".to_string(), - enabled: true, - required: false, - disabled_reason: None, - startup_timeout_sec: Some(Duration::from_secs(10)), - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: Some(vec!["echo".to_string()]), - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - supports_parallel_tool_calls: false, - tools: HashMap::new(), - }, + }) + .startup_timeout_sec(Duration::from_secs(10)) + .enabled_tools(vec!["echo".to_string()]) + .build(), ); config .mcp_servers diff --git a/codex-rs/core/tests/suite/sqlite_state.rs b/codex-rs/core/tests/suite/sqlite_state.rs index aecb9a392e..0007da2c1e 100644 --- a/codex-rs/core/tests/suite/sqlite_state.rs +++ b/codex-rs/core/tests/suite/sqlite_state.rs @@ -429,8 +429,8 @@ async fn mcp_call_marks_thread_memory_mode_polluted_when_configured() -> Result< let mut servers = config.mcp_servers.get().clone(); servers.insert( server_name.to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: rmcp_test_server_bin, args: Vec::new(), env: Some(HashMap::from([( @@ -439,22 +439,9 @@ async fn mcp_call_marks_thread_memory_mode_polluted_when_configured() -> Result< )])), env_vars: Vec::new(), cwd: None, - }, - environment_id: "local".to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: Some(Duration::from_secs(10)), - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .startup_timeout_sec(Duration::from_secs(10)) + .build(), ); config .mcp_servers diff --git a/codex-rs/core/tests/suite/truncation.rs b/codex-rs/core/tests/suite/truncation.rs index db90b663e0..fb4314e948 100644 --- a/codex-rs/core/tests/suite/truncation.rs +++ b/codex-rs/core/tests/suite/truncation.rs @@ -380,29 +380,16 @@ async fn mcp_tool_call_output_exceeds_limit_truncated_for_model() -> Result<()> let mut servers = config.mcp_servers.get().clone(); servers.insert( server_name.to_string(), - codex_config::types::McpServerConfig { - transport: codex_config::types::McpServerTransportConfig::Stdio { + codex_config::types::McpServerConfig::builder() + .transport(codex_config::types::McpServerTransportConfig::Stdio { command: rmcp_test_server_bin, args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: "local".to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: Some(std::time::Duration::from_secs(10)), - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .startup_timeout_sec(std::time::Duration::from_secs(10)) + .build(), ); config .mcp_servers @@ -478,8 +465,8 @@ async fn mcp_image_output_preserves_image_and_no_text_summary() -> Result<()> { let mut servers = config.mcp_servers.get().clone(); servers.insert( server_name.to_string(), - McpServerConfig { - transport: McpServerTransportConfig::Stdio { + McpServerConfig::builder() + .transport(McpServerTransportConfig::Stdio { command: rmcp_test_server_bin, args: Vec::new(), env: Some(HashMap::from([( @@ -488,22 +475,9 @@ async fn mcp_image_output_preserves_image_and_no_text_summary() -> Result<()> { )])), env_vars: Vec::new(), cwd: None, - }, - environment_id: "local".to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: Some(Duration::from_secs(10)), - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .startup_timeout_sec(Duration::from_secs(10)) + .build(), ); config .mcp_servers @@ -771,29 +745,16 @@ async fn mcp_tool_call_output_not_truncated_with_custom_limit() -> Result<()> { let mut servers = config.mcp_servers.get().clone(); servers.insert( server_name.to_string(), - codex_config::types::McpServerConfig { - transport: codex_config::types::McpServerTransportConfig::Stdio { + codex_config::types::McpServerConfig::builder() + .transport(codex_config::types::McpServerTransportConfig::Stdio { command: rmcp_test_server_bin, args: Vec::new(), env: None, env_vars: Vec::new(), cwd: None, - }, - environment_id: "local".to_string(), - enabled: true, - required: false, - supports_parallel_tool_calls: false, - disabled_reason: None, - startup_timeout_sec: Some(std::time::Duration::from_secs(10)), - tool_timeout_sec: None, - default_tools_approval_mode: None, - enabled_tools: None, - disabled_tools: None, - scopes: None, - oauth: None, - oauth_resource: None, - tools: HashMap::new(), - }, + }) + .startup_timeout_sec(std::time::Duration::from_secs(10)) + .build(), ); config .mcp_servers