[1/8] Add MCP server environment config (#18085)

## Summary
- Add an MCP server environment setting with local as the default.
- Thread the default through config serialization, schema generation,
and existing config fixtures.

## Stack
```text
o  #18027 [8/8] Fail exec client operations after disconnect
│
o  #18025 [7/8] Cover MCP stdio tests with executor placement
│
o  #18089 [6/8] Wire remote MCP stdio through executor
│
o  #18088 [5/8] Add executor process transport for MCP stdio
│
o  #18087 [4/8] Abstract MCP stdio server launching
│
o  #18020 [3/8] Add pushed exec process events
│
o  #18086 [2/8] Support piped stdin in exec process API
│
@  #18085 [1/8] Add MCP server environment config
│
o  main
```

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Ahmed Ibrahim
2026-04-16 08:50:03 -07:00
committed by GitHub
parent b178d1cf17
commit b4be3617f9
23 changed files with 69 additions and 0 deletions

View File

@@ -174,6 +174,9 @@ fn serialize_mcp_server(config: &McpServerConfig) -> TomlItem {
if !config.enabled {
entry["enabled"] = value(false);
}
if let Some(environment) = &config.experimental_environment {
entry["experimental_environment"] = value(environment.clone());
}
if config.required {
entry["required"] = value(true);
}

View File

@@ -22,6 +22,7 @@ async fn replace_mcp_servers_serializes_per_tool_approval_overrides() -> anyhow:
env_vars: Vec::new(),
cwd: None,
},
experimental_environment: None,
enabled: true,
required: false,
supports_parallel_tool_calls: true,

View File

@@ -61,6 +61,10 @@ pub struct McpServerConfig {
#[serde(flatten)]
pub transport: McpServerTransportConfig,
/// Experimental environment selector for where Codex should start this MCP server.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub experimental_environment: Option<String>,
/// When `false`, Codex skips initializing this MCP server.
#[serde(default = "default_enabled")]
pub enabled: bool,
@@ -139,6 +143,8 @@ pub struct RawMcpServerConfig {
// shared
#[serde(default)]
pub experimental_environment: Option<String>,
#[serde(default)]
pub startup_timeout_sec: Option<f64>,
#[serde(default)]
pub startup_timeout_ms: Option<u64>,
@@ -181,6 +187,7 @@ impl TryFrom<RawMcpServerConfig> for McpServerConfig {
url,
bearer_token,
bearer_token_env_var,
experimental_environment,
startup_timeout_sec,
startup_timeout_ms,
tool_timeout_sec,
@@ -246,6 +253,7 @@ impl TryFrom<RawMcpServerConfig> for McpServerConfig {
Ok(Self {
transport,
experimental_environment,
startup_timeout_sec,
tool_timeout_sec,
enabled: enabled.unwrap_or_else(default_enabled),

View File

@@ -297,6 +297,7 @@ fn deserialize_ignores_unknown_server_fields() {
env_vars: Vec::new(),
cwd: None,
},
experimental_environment: None,
enabled: true,
required: false,
supports_parallel_tool_calls: false,